Package com.dotmarketing.portlets.calendar.model

Examples of com.dotmarketing.portlets.calendar.model.Event


      {
        //Assuming is a front-end access
        respectCMSAnon = true;
        user = (User)request.getSession().getAttribute(WebKeys.CMS_USER);
      }
      Event event = eventAPI.find(inode, true, user, respectCMSAnon);
      Host host = hostWebAPI.getCurrentHost(request);
      String iCalEvent = eventAPI.createVCalendarInfo(event, startDate, endDate, host);
           
      //response.setContentType("application/octet-stream");
      response.setContentType("text/calendar");     
      response.setHeader("Content-Disposition", "attachment; filename=\"" + event.getTitle() + ".ics\"");
      OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream(), response.getCharacterEncoding());
      out.write(iCalEvent);
   
      out.flush();
      out.close();
View Full Code Here


    String reUseInode = (String) req.getParameter("reUseInode");
    if(!InodeUtils.isSet(contentlet.getInode()) && reUseInode != null){
      contentlet.setInode(reUseInode);
    }
    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());
    }
  }
View Full Code Here

   * @throws NumberFormatException
   */
  private void editEvent (ActionMapping mapping, ActionForm form, PortletConfig config,
      ActionRequest req, ActionResponse res, User user)  {
    EventForm eventForm = (EventForm) form;
    Event event = (Event) req.getAttribute(WebKeys.EVENT_EDIT);
    if(!UtilMethods.isSet(event.getInode()))
      return;
    if (event.getRecurs()) {
      eventForm.setRecurrenceStartsDate(event.getRecurrenceStart());
      eventForm.setRecurrenceDayOfMonth(String.valueOf(event.getRecurrenceDayOfMonth()));
      eventForm.setRecurrenceDayOfWeek(event.getRecurrenceDayOfWeek());

      if(UtilMethods.isSet(event.getRecurrenceEnd())){
        eventForm.setRecurrenceEndsDate(event.getRecurrenceEnd());
        eventForm.setNoEndDate(false);
      }else{
        eventForm.setNoEndDate(true)
      }
      String daysOfWeek = event.getRecurrenceDaysOfWeek();
      if(daysOfWeek == null)
        daysOfWeek = "";
      List<String> daysList = new ArrayList<String>();
      for(String day : daysOfWeek.split(",")) {
        if(UtilMethods.isSet(day)) {
          daysList.add(day);
        }
      }
      String[] daysListArr = new String[daysList.size()];
      for(int i = 0 ; i < daysList.size(); i++)
        daysListArr[i] = daysList.get(i);
      eventForm.setRecurrenceDaysOfWeek(daysListArr);
      eventForm.setRecurrenceInterval((int) event.getRecurrenceInterval());
      if(event.getOccursEnum() == Event.Occurrency.DAILY){
        eventForm.setRecurrenceOccurs("daily");
      }else if(event.getOccursEnum() == Event.Occurrency.WEEKLY){
        eventForm.setRecurrenceOccurs("weekly");
       }else if(event.getOccursEnum() == Event.Occurrency.MONTHLY){
          eventForm.setRecurrenceOccurs("monthly");
          if(UtilMethods.isSet(event.getRecurrenceDayOfMonth()) && event.getRecurrenceDayOfMonth() >0){
            eventForm.setRecurrenceDayOfMonth(String.valueOf(event.getRecurrenceDayOfMonth()));   
            eventForm.setSpecificDate(true);
          }else{
            eventForm.setSpecificDate(false);
            eventForm.setRecurrenceMonthOfYear(event.getRecurrenceMonthOfYear());
            eventForm.setRecurrenceWeekOfMonth(event.getRecurrenceWeekOfMonth());
            eventForm.setRecurrenceDayOfMonth("");
          }
            }else if(event.getOccursEnum() == Event.Occurrency.ANNUALLY){
                  if(UtilMethods.isSet(event.getRecurrenceDayOfMonth()) && event.getRecurrenceDayOfMonth() >0){
                    eventForm.setSpecificDayOfMonthRecY(String.valueOf(event.getRecurrenceDayOfMonth()))
                    eventForm.setSpecificMonthOfYearRecY(String.valueOf(event.getRecurrenceMonthOfYear()));
                    eventForm.setSpecificDate(true);
          }else{
            eventForm.setSpecificDate(false);
            eventForm.setSpecificDayOfMonthRecY("");
            eventForm.setSpecificMonthOfYearRecY("");
            eventForm.setRecurrenceMonthOfYear(event.getRecurrenceMonthOfYear());
            eventForm.setRecurrenceWeekOfMonth(event.getRecurrenceWeekOfMonth());
          }
          eventForm.setRecurrenceOccurs("annually");
            }

    } else {
View Full Code Here

      ActionRequest req, ActionResponse res, User user) throws DotDataException, DotSecurityException {
    HibernateUtil.startTransaction();
    HttpServletRequest request = ((ActionRequestImpl) req).getHttpServletRequest();

    EventForm eventForm = (EventForm) form;
    Event event = (Event) req.getAttribute(WebKeys.EVENT_EDIT);
  }
View Full Code Here

    return events;
  }
 
 
  private Event copyEvent(Event baseEvent) throws DotContentletStateException, DotSecurityException, DotDataException {
    Event newEvent = new Event();
    conAPI.copyProperties(newEvent, baseEvent.getMap());
    newEvent.setInode(baseEvent.getInode());
    newEvent.setIdentifier(baseEvent.getIdentifier());
    return newEvent;
  }
View Full Code Here

    }

    // Create the CalendarReminder
    String userId = user.getUserId();
    try {
      Event event = EFI.find(eventId, true, user, true);
      Date eventDate = event.getStartDate();
      GregorianCalendar gc = new GregorianCalendar();
      gc.setTime(eventDate);
      gc.add(Calendar.DATE,daysInAdvance);
      Date calendarReminderDate = gc.getTime();
View Full Code Here

        }
      }     
     
      //Checking for the folder to store the submitted files
      Host host = hostWebAPI.getCurrentHost(request);
      Event event = new Event();
      Language language = langAPI.getDefaultLanguage();
      Folder folder = APILocator.getFolderAPI().findFolderByPath(path, host,APILocator.getUserAPI().getSystemUser(),false);
            Structure structure = StructureCache.getStructureByName("Event");
            event.setStructureInode(structure.getInode());
      if (!InodeUtils.isSet(folder.getInode())){
        folder = APILocator.getFolderAPI().createFolders(path, host,userAPI.getSystemUser(),false);
      }

      List<Category> categoriesList  =  new ArrayList<Category>();
      if (categoriesArray != null) {
        for (String cat : categoriesArray ) {
            Category node = (Category) catAPI.find(cat, currentUser, respectFrontendRoles);
            if(node!=null){
              categoriesList.add(node);
           }
        }
      }
     
      event.setStartDate(startDate);
      event.setEndDate(endDate);
      event.setTitle(title);
      event.setTags(tags);
      event.setLocation(location);
      event.setLink(link);
      event.setDescription(description);
      event.setLanguageId(language.getId());
       
      FileAsset cmsFile = null;
      FileAsset cmsImage = null;
     
      //Get file type parameters
      if (request instanceof UploadServletRequest)
      {
        UploadServletRequest uploadReq = (UploadServletRequest) request;
       
        java.io.File file = uploadReq.getFile("file");
        java.io.File image = uploadReq.getFile("image");
       
        if(file != null && file.length() > 0) {
          String fileName = uploadReq.getFileName("file");
          cmsFile = saveFile(currentUser, host, file, folder, fileName);
          event.setProperty("file", cmsFile.getIdentifier());
        }
         
        if(image != null && image.length() > 0) {
          String fileName = uploadReq.getFileName("image");
          cmsImage = saveFile(currentUser, host, image, folder, fileName);
          event.setProperty("image", cmsImage.getIdentifier());
        }         
         
      } 

      try {
        PermissionAPI perAPI = APILocator.getPermissionAPI();
        List<Permission> pers = perAPI.getPermissions(event.getStructure());
        APILocator.getContentletAPI().checkin(event, categoriesList, pers, currentUser, false);
        APILocator.getVersionableAPI().setWorking(event);
      } catch (DotContentletValidationException ex) {
       
        Map<String, List<Field>> fields = ex.getNotValidFields();
        List<Field> reqFields = fields.get("required");
        for(Field f : reqFields) {
          if(!f.getFieldType().equals(Field.FieldType.CATEGORY.toString())) {
            ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentlet.required", f.getFieldName()));
          } else {
            ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentlet.category.required", f.getFieldName()));
          }
        }
       
        saveMessages(request, ae);       
        return mapping.findForward("addEvent");
       
      } catch (DotSecurityException e) {
        ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("you-do-not-have-the-required-permissions"));
        saveMessages(request, ae);       
        return mapping.findForward("addEvent");     
      }
       
      Contentlet cont = conAPI.find(event.getInode(), currentUser, respectFrontendRoles);
      if(cmsFile != null) {
        conAPI.addFileToContentlet(cont, cmsFile.getInode(), "Event:file", currentUser, true)
      }
         
      if(cmsImage != null) {
        conAPI.addFileToContentlet(cont, cmsImage.getInode(), "Event:image", currentUser, true);
      }         

      if(!request.getParameter("recurrenceOccurs").equals("never")){

        EventForm ef = (EventForm) lf;
       
     
       
        //EventRecurrence recurrence = new EventRecurrence();
        Date startRecurrenceDate = startDate;
        Date endRecurrenceDate   = ef.getRecurrenceEndsDate();
        event.setRecurs(true);
        event.setRecurrenceStart(startRecurrenceDate);
        event.setRecurrenceEnd(endRecurrenceDate);
        event.setNoRecurrenceEnd(ef.isNoEndDate());
        SimpleDateFormat dateFormatS = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        event.setOriginalStartDate(dateFormatS.parse(ef.getOriginalStartDate()));
              String baseEventId = ef.getDisconnectedFrom();
       
        if(UtilMethods.isSet(baseEventId)){
          event.setDisconnectedFrom(baseEventId);
          event.setOriginalStartDate(dateFormatS.parse(ef.getOriginalStartDate()));
        }

        if(ef.getRecurrenceOccurs().equals("daily")){
          event.setRecurrenceInterval(ef.getRecurrenceIntervalDaily());
          event.setOccursEnum(Event.Occurrency.DAILY);
        }else if(ef.getRecurrenceOccurs().equals("monthly")){
          event.setRecurrenceDayOfWeek(ef.getRecurrenceDayOfWeek());
          event.setRecurrenceWeekOfMonth(ef.getRecurrenceWeekOfMonth());
          event.setRecurrenceInterval(ef.getRecurrenceIntervalMonthly());
          event.setOccursEnum(Event.Occurrency.MONTHLY);
        }else if(ef.getRecurrenceOccurs().equals("weekly")){
          String[] recurrenceDaysOfWeek = ef.getRecurrenceDaysOfWeek();  
          String daysOfWeek = "";
          for (String day : recurrenceDaysOfWeek) {
            daysOfWeek += day + ",";
          }
          event.setRecurrenceDaysOfWeek(daysOfWeek);
          event.setRecurrenceInterval(ef.getRecurrenceIntervalWeekly());
          event.setOccursEnum(Event.Occurrency.WEEKLY);
        }else if(ef.getRecurrenceOccurs().equals("annually")){
          event.setRecurrenceInterval(ef.getRecurrenceIntervalYearly());
          event.setOccursEnum(Event.Occurrency.WEEKLY);
          event.setRecurrenceDayOfWeek(ef.getRecurrenceDayOfWeek());
          event.setRecurrenceWeekOfMonth(ef.getRecurrenceWeekOfMonth());
          event.setRecurrenceMonthOfYear(ef.getRecurrenceMonthOfYear());
        }
       
        List<Category> eventCategories = catAPI.getParents(event, currentUser, true);
        List<Permission> eventPermissions  = perAPI.getPermissions(event);

                APILocator.getContentletAPI().checkin(event, eventCategories, eventPermissions, currentUser, false);
       
        if(UtilMethods.isSet(baseEventId)){
          Event baseEvent  = eventAPI.find(baseEventId, true, currentUser, true);
          baseEvent.addDateToIgnore(dateFormatS.parse(ef.getOriginalStartDate()));
          eventCategories = catAPI.getParents(baseEvent, currentUser, true);
          eventPermissions  = perAPI.getPermissions(baseEvent);
          APILocator.getContentletAPI().checkin(baseEvent, eventCategories, eventPermissions, currentUser, false);
        }
       
View Full Code Here

        String userId = calendarReminder.getUserId();
        User user = APILocator.getUserAPI().loadUserById(userId,APILocator.getUserAPI().getSystemUser(),false);

        // Get the event information
        String eventId = calendarReminder.getEventId();
        Event event = EFI.find(eventId, true, user, true);
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("fullName", user.getFullName());
        parameters.put("eventTitle", event.getTitle());
        parameters.put("eventDate", UtilMethods.dateToHTMLDate(event.getStartDate(), "MM/dd/yyyy HH:mm a"));
        parameters.put("eventId", event.getIdentifier());
       
        //Template
        String reminderTemplate = Config.getStringProperty("CALENDAR_REMINDER_THREAD_TEMPLATE");
        reminderTemplate = (UtilMethods.isSet(reminderTemplate) ?  reminderTemplate : "/calendar/emailTemplate." + Config.getStringProperty("VELOCITY_PAGE_EXTENSION"));
        parameters.put("emailTemplate",reminderTemplate);
View Full Code Here

   * @throws DotDataException
   * @throws DotSecurityException
   *             If the user doesn't have permissions to see this event
   */
  public Event find(String id, boolean live, User user, boolean respectFrontendRoles) throws DotDataException, DotSecurityException {
    Event ev = eventFactory.find(RecurrenceUtil.getBaseEventIdentifier(id), live, user, respectFrontendRoles);
    Contentlet cont = new Contentlet();
    cont = conAPI.find(ev.getInode(), user, respectFrontendRoles);
    if (!perAPI.doesUserHavePermission(cont, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles))
      throw new DotSecurityException("User doesn't have permissions to access this event");

    if(ev.isRecurrent()) {
      String[] recDates = RecurrenceUtil.getRecurrenceDates(id);
      if(recDates!=null && recDates.length==2){
        String startDate = recDates[0];
        String endDate = recDates[1];
        if(UtilMethods.isSet(startDate) && UtilMethods.isSet(endDate)){
          ev.setStartDate(new Date(Long.parseLong(startDate)));
          ev.setEndDate(new Date(Long.parseLong(endDate)));
        }
      }
    }
    return ev;
  }
View Full Code Here

    }
    return ev;
  }

  public Event findbyInode(String inode, User user, boolean respectFrontendRoles) throws DotDataException, DotSecurityException {
    Event ev = eventFactory.findbyInode(inode, user, respectFrontendRoles);
    Contentlet cont = new Contentlet();
    cont = conAPI.find(ev.getInode(), user, respectFrontendRoles);
    if (!perAPI.doesUserHavePermission(cont, PermissionAPI.PERMISSION_READ, user, respectFrontendRoles))
      throw new DotSecurityException("User doesn't have permissions to access this event");
    return ev;
  }
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.calendar.model.Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.