Ejemplo n.º 1
0
  /**
   * Retrieves the event object from storage
   *
   * @param mapping
   * @param form
   * @param config
   * @param req
   * @param res
   * @param user
   * @throws DotSecurityException
   * @throws DotDataException
   * @throws DotSecurityException
   * @throws DotDataException
   * @throws ParseException
   * @throws NumberFormatException
   */
  private void retrieveEvent(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig config,
      ActionRequest req,
      ActionResponse res,
      String command,
      User user)
      throws DotDataException, DotSecurityException, ParseException {
    Contentlet contentlet = (Contentlet) req.getAttribute(WebKeys.CONTENTLET_EDIT);
    if (InodeUtils.isSet(contentlet.getInode())) {
      Event ev = eventAPI.findbyInode(contentlet.getInode(), user, false);
      req.setAttribute(WebKeys.EVENT_EDIT, ev);

    } else {
      EventForm eventForm = (EventForm) form;
      eventForm.setRecurrenceEndsDate(new Date());
      eventForm.setRecurrenceOccurs("never");
      eventForm.setRecurrenceDayOfMonth("");
      eventForm.setNoEndDate(false);
      eventForm.setRecurrenceInterval(1);
      eventForm.setRecurrenceIntervalDaily(1);
      eventForm.setRecurrenceIntervalWeekly(1);
      eventForm.setRecurrenceIntervalMonthly(1);
      eventForm.setRecurrenceIntervalYearly(1);
      String[] daysOfWeekRecurrence = {
        String.valueOf(Calendar.MONDAY),
        String.valueOf(Calendar.TUESDAY),
        String.valueOf(Calendar.WEDNESDAY),
        String.valueOf(Calendar.THURSDAY),
        String.valueOf(Calendar.FRIDAY),
        String.valueOf(Calendar.SATURDAY),
        String.valueOf(Calendar.SUNDAY)
      };
      eventForm.setRecurrenceDaysOfWeek(daysOfWeekRecurrence);
      eventForm.setRecurrenceDayOfWeek(1);
      eventForm.setRecurrenceMonthOfYear(1);
      eventForm.setRecurrenceWeekOfMonth(1);
      eventForm.setSpecificDayOfMonthRecY("1");
      eventForm.setSpecificMonthOfYearRecY("1");
      eventForm.setSpecificDate(false);
      req.setAttribute(WebKeys.EVENT_EDIT, new Event());
    }
  }