Package com.dotmarketing.business

Examples of com.dotmarketing.business.PermissionAPI


  private WorkflowAPI wfAPI = APILocator.getWorkflowAPI();
 
  public void processAction(ActionMapping mapping, ActionForm form,
      PortletConfig config, ActionRequest req, ActionResponse res)
  throws Exception {
    PermissionAPI perAPI = APILocator.getPermissionAPI();
    String cmd = req.getParameter(Constants.CMD);
    String referer = req.getParameter("referer");
    HttpServletRequest request =  ((ActionRequestImpl)req).getHttpServletRequest();
    Logger.debug(this, "EditWorkflowTaskAction cmd=" + cmd);
View Full Code Here


        if ((userId == null) || (c.getUserId() == null)) {
            return;
        }

        User user = APILocator.getUserAPI().loadUserById(userId,APILocator.getUserAPI().getSystemUser(),false);
        PermissionAPI perAPI = APILocator.getPermissionAPI();
        if (c.getUserId().equalsIgnoreCase(userId) || perAPI.doesUserHavePermission(c,PermissionAPI.PERMISSION_WRITE,user))
        {
            List recipients = RecipientFactory.getAllRecipientsByCampaign(c);
            Iterator i = recipients.iterator();

            while (i.hasNext()) {
                Recipient r = (Recipient) i.next();
                List clicks = ClickFactory.getClicksByParent(r);
                Iterator i2 = clicks.iterator();

                while (i2.hasNext()) {
                    Click click = (Click) i2.next();
                    InodeFactory.deleteInode(click);
                }

                InodeFactory.deleteInode(r);
            }
           
            if(perAPI.doesUserHavePermission(c,PermissionAPI.PERMISSION_WRITE,user)){
              perAPI.removePermissions(c);
        }

            InodeFactory.deleteInode(c);
        }
    }
View Full Code Here

   */
  public static void deleteCommunication(Communication c, String userId) throws DotDataException, NoSuchUserException, DotSecurityException {
    if ((userId == null) || (c.getModifiedBy() == null)) {
      return;
    }
    PermissionAPI perAPI = APILocator.getPermissionAPI();
    User user = APILocator.getUserAPI().loadUserById(userId,APILocator.getUserAPI().getSystemUser(),false);
    if(perAPI.doesUserHavePermission(c,PermissionAPI.PERMISSION_WRITE,user)){
      perAPI.removePermissions(c);
    }
    InodeFactory.deleteInode(c);
   
  }
View Full Code Here

 
  public void execute(JobExecutionContext jobContext) throws JobExecutionException {
   
    JobDataMap map = jobContext.getJobDetail().getJobDataMap();

    PermissionAPI permissionAPI = APILocator.getPermissionAPI();
    permissionAPI.clearCache();
    String permissionableId = (String) map.get("permissionableId");
    String roleId = (String) map.get("roleId");
    try {
      RoleAPI roleAPI = APILocator.getRoleAPI();
      Permissionable permissionable = (Permissionable) retrievePermissionable(permissionableId);
      Role role = (Role) roleAPI.loadRoleById(roleId);
      permissionAPI.cascadePermissionUnder(permissionable, role);
    } catch (DotDataException e) {
      Logger.error(this, e.getMessage(), e);
      permissionAPI.clearCache();
      throw new DotRuntimeException(e.getMessage(), e);
    } catch (DotSecurityException e) {
      Logger.error(CascadePermissionsJob.class, e.getMessage(), e);
      permissionAPI.clearCache();
      throw new DotRuntimeException(e.getMessage(), e);
    }
    finally {
        try {
                HibernateUtil.closeSession();
            } catch (DotHibernateException e) {
                Logger.warn(this, e.getMessage(), e);
            }
            finally {
                DbConnectionFactory.closeConnection();
            }
    }
    permissionAPI.clearCache();
  }
View Full Code Here

  private void _setupEditContainerPage(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form,
      User user) throws Exception {

    //Getting the host that can be assigned to the container
    PermissionAPI perAPI = APILocator.getPermissionAPI();
    Container container = (Container) req.getAttribute(WebKeys.CONTAINER_EDIT);

        Host host = hostAPI.findParentHost(container, user, false);

    List<Host> hosts = APILocator.getHostAPI().findAll(user, false);
    hosts.remove(APILocator.getHostAPI().findSystemHost(user, false));
    hosts = perAPI.filterCollection(hosts, PermissionAPI.PERMISSION_CAN_ADD_CHILDREN, false, user);
    if(host != null && !hosts.contains(host)) {
      hosts.add(host);
    }
    req.setAttribute(WebKeys.CONTAINER_HOSTS, hosts);
  }
View Full Code Here

 
  public void execute(JobExecutionContext ctx) throws JobExecutionException {

    ContentletAPI conAPI = APILocator.getContentletAPI();
    FieldAPI fieldAPI = APILocator.getFieldAPI();
    PermissionAPI perAPI = APILocator.getPermissionAPI();
    try {
 
        List<Structure> allStructures = StructureFactory.getStructures();   
        for(Structure structure:allStructures){
         
          boolean isCongigured = false;
          String host = "";
          String username = "";
          String password = "";
          int port = 0;
          boolean isSSL = true;
   
          try{
            host = Config.getStringProperty("pop."+structure.getVelocityVarName()+".host");
            username = Config.getStringProperty("pop."+structure.getVelocityVarName()+".login");
            password = Config.getStringProperty("pop."+structure.getVelocityVarName()+".password");
            port = Config.getIntProperty("pop."+structure.getVelocityVarName()+".port");
            isSSL  = Config.getBooleanProperty("pop."+structure.getVelocityVarName()+".ssl");
          }catch (Exception e) {
           
          }
   
          if(UtilMethods.isSet(host)
              && UtilMethods.isSet(port)
              && UtilMethods.isSet(isSSL)
              && UtilMethods.isSet(username)
              && UtilMethods.isSet(password)){
            isCongigured = true;
          }
   
          if(isCongigured){
           
            String messageIdFieldVarNm = "";
            String subjectFieldVarNm = "";
            String bodyFieldVarNm = "";
            String fromFieldVarNm = "";
            String toFieldVarNm = "";
            String ccFieldVarNm = "";
            String bccFieldVarNm = "";
            String dateFieldVarNm = "";
            String referencesFieldVarNm = "";
            String inReplyToFieldVarNm = "";
            String attachment1FieldVarNm = "";
            String attachment2FieldVarNm = "";
            String attachment3FieldVarNm = "";
            String attachment4FieldVarNm = "";
            String attachment5FieldVarNm = "";
            String attachment6FieldVarNm = "";
            String attachment7FieldVarNm = "";
            String attachment8FieldVarNm = "";
            String attachment9FieldVarNm = "";
            String attachment10FieldVarNm = "";
           
            try{
              messageIdFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".messageId");
              subjectFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".subject");
              bodyFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".body");
              fromFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".from");
              toFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".to");
              ccFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".cc");
              bccFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".bcc");
              dateFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".date");
              referencesFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".references");
              inReplyToFieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".inReplyTo");
              attachment1FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment1");
              attachment2FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment2");
              attachment3FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment3");
              attachment4FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment4");
              attachment5FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment5");
              attachment6FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment6");
              attachment7FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment7");
              attachment8FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment8");
              attachment9FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment9");
              attachment10FieldVarNm = Config.getStringProperty("pop."+structure.getVelocityVarName()+".attachment10");
            }catch (Exception e) {
             
            }
   
            List<Field> fields = FieldsCache.getFieldsByStructureVariableName(structure.getVelocityVarName());
   
            ContentletRelationships contRel;
            ArrayList<Category> cats;
            User systemUser = null;
            try {
              systemUser = APILocator.getUserAPI().getSystemUser();
            } catch (DotDataException e) {
              Logger.error(this, e.getMessage());
            }
   
            try {
              List<Map<String,Object>> emails = EmailUtils.getEmails(host, port, isSSL, username, password);
   
              for(Map<String,Object> email:emails){
                Contentlet contentlet = new Contentlet();
                contentlet.setStructureInode(structure.getInode());
   
                for (Field field : fields){
                  if(fieldAPI.isElementConstant(field)){
                    continue;
                  }
                  Object value = null;
                  // using the standard headers/names from javax.mail.* to retrieve the email headers and field's values below
                  if(UtilMethods.isSet(messageIdFieldVarNm) && field.getVelocityVarName().equals(messageIdFieldVarNm)){
                    if(email.get("Message-ID") != null)
                      value = email.get("Message-ID");
                  }else if(UtilMethods.isSet(subjectFieldVarNm) && field.getVelocityVarName().equals(subjectFieldVarNm)){
                    if(email.get("Subject") != null)
                      value = email.get("Subject");
                  }else if(UtilMethods.isSet(bodyFieldVarNm) && field.getVelocityVarName().equals(bodyFieldVarNm)){
                    if(email.get("Body") != null)
                      value = email.get("Body");
                  }else if(UtilMethods.isSet(fromFieldVarNm) && field.getVelocityVarName().equals(fromFieldVarNm)){
                    if(email.get("From") != null)
                      value = email.get("From");
                  } else if(UtilMethods.isSet(toFieldVarNm) && field.getVelocityVarName().equals(toFieldVarNm)){
                    if(email.get("To") != null)
                      value = email.get("To");
                  }else if(UtilMethods.isSet(ccFieldVarNm) && field.getVelocityVarName().equals(ccFieldVarNm)){
                    if(email.get("Cc") != null)
                      value = email.get("Cc");
                  }else if(UtilMethods.isSet(bccFieldVarNm) && field.getVelocityVarName().equals(bccFieldVarNm)){
                    if(email.get("Bcc") != null)
                      value = email.get("Bcc");
                  }else if(UtilMethods.isSet(dateFieldVarNm) && field.getVelocityVarName().equals(dateFieldVarNm)){
                    if(email.get("Date") != null)
                      value = email.get("Date");
                  }else if(UtilMethods.isSet(referencesFieldVarNm) && field.getVelocityVarName().equals(referencesFieldVarNm)){
                    if(email.get("References") != null)
                      value = email.get("References");
                  }else if(UtilMethods.isSet(inReplyToFieldVarNm) && field.getVelocityVarName().equals(inReplyToFieldVarNm)){
                    if(email.get("In-Reply-To") != null)
                      value = email.get("In-Reply-To");
                  }else if(UtilMethods.isSet(attachment1FieldVarNm) && field.getVelocityVarName().equals(attachment1FieldVarNm)){
                    if(email.get("attachment1") != null)
                      value = email.get("attachment1");
                  }else if(UtilMethods.isSet(attachment2FieldVarNm) && field.getVelocityVarName().equals(attachment2FieldVarNm)){
                    if(email.get("attachment2") != null)
                      value = email.get("attachment2");
                  }else if(UtilMethods.isSet(attachment3FieldVarNm) && field.getVelocityVarName().equals(attachment3FieldVarNm)){
                    if(email.get("attachment3") != null)
                      value = email.get("attachment3");
                  }else if(UtilMethods.isSet(attachment4FieldVarNm) && field.getVelocityVarName().equals(attachment4FieldVarNm)){
                    if(email.get("attachment4") != null)
                      value = email.get("attachment4");
                  }else if(UtilMethods.isSet(attachment5FieldVarNm) && field.getVelocityVarName().equals(attachment5FieldVarNm)){
                    if(email.get("attachment5") != null)
                      value = email.get("attachment5");
                  }else if(UtilMethods.isSet(attachment6FieldVarNm) && field.getVelocityVarName().equals(attachment6FieldVarNm)){
                    if(email.get("attachment6") != null)
                      value = email.get("attachment6");
                  }else if(UtilMethods.isSet(attachment7FieldVarNm) && field.getVelocityVarName().equals(attachment7FieldVarNm)){
                    if(email.get("attachment7") != null)
                      value = email.get("attachment7");
                  }else if(UtilMethods.isSet(attachment8FieldVarNm) && field.getVelocityVarName().equals(attachment8FieldVarNm)){
                    if(email.get("attachment8") != null)
                      value = email.get("attachment8");
                  }else if(UtilMethods.isSet(attachment9FieldVarNm) && field.getVelocityVarName().equals(attachment9FieldVarNm)){
                    if(email.get("attachment9") != null)
                      value = email.get("attachment9");
                  }else if(UtilMethods.isSet(attachment10FieldVarNm) && field.getVelocityVarName().equals(attachment10FieldVarNm)){
                    if(email.get("attachment10") != null)
                      value = email.get("attachment10");
                  }
   
                  String typeField = field.getFieldType();
   
                  /* Validate if the field is read only, if so then check to see if it's a new contentlet
                   * and set the structure field default value, otherwise do not set the new value.
                   */
                  if (!typeField.equals(Field.FieldType.HIDDEN.toString()) &&
                      !typeField.equals(Field.FieldType.IMAGE.toString()) &&
                      !typeField.equals(Field.FieldType.FILE.toString()))
                  {
                    if(field.isReadOnly() && !InodeUtils.isSet(contentlet.getInode()))
                      value = field.getDefaultValue();
                    if (field.getFieldType().equals(Field.FieldType.WYSIWYG.toString())) {
                      //WYSIWYG workaround because the WYSIWYG includes a <br> even if the field was left blank by the user
                      //we have to check the value to leave it blank in that case.
                      if (value instanceof String && ((String)value).trim().toLowerCase().equals("<br>")) {
                        value = "";
                      }
                    }
                  }
                  if ((value != null || field.getFieldType().equals(Field.FieldType.BINARY.toString())) && APILocator.getFieldAPI().valueSettable(field)
                      && !field.getFieldType().equals(Field.FieldType.HOST_OR_FOLDER.toString()))
                    try{
                      conAPI.setContentletProperty(contentlet, field, value);
                    }catch (Exception e) {
                      Logger.info(this, "Unable to set field " + field.getFieldName() + " to value " + value);
                      Logger.debug(this, "Unable to set field " + field.getFieldName() + " to value " + value, e);
                    }
                }
   
                contRel = retrieveRelationshipsData(contentlet,systemUser,email);
   
                cats = new ArrayList<Category>();
   
                Contentlet con = conAPI.checkin(contentlet, contRel,
                    cats, perAPI.getPermissions(contentlet, false, true), systemUser, false);
               
                // When a large number of new mails with a number of replies come in.
                // To relate the content based on lucene query, the new content created must be indexed.
                conAPI.isInodeIndexed(con.getInode());
              }
View Full Code Here

 
  public void execute(JobExecutionContext jobContext) throws JobExecutionException {
   
    JobDataMap map = jobContext.getJobDetail().getJobDataMap();

    PermissionAPI permissionAPI = APILocator.getPermissionAPI();
   
    String permissionableId = (String) map.get("permissionableId");
    try {
      HibernateUtil.startTransaction();
      Permissionable permissionable = (Permissionable) retrievePermissionable(permissionableId);
      permissionAPI.resetPermissionsUnder(permissionable);
      HibernateUtil.commitTransaction();
    } catch (Exception e) {
      Logger.error(this, e.getMessage(), e);
      try {
        HibernateUtil.rollbackTransaction();
View Full Code Here

    APILocator.getVersionableAPI().setWorking(newContainer);
    if(currentContainer.isLive())
        APILocator.getVersionableAPI().setLive(newContainer);

    PermissionAPI perAPI = APILocator.getPermissionAPI();
    //Copy permissions
    perAPI.copyPermissions(currentContainer, newContainer);

    //saves to working folder under velocity
    ContainerServices.invalidate(newContainer, newIdentifier,
        true);
View Full Code Here

        }         
         
      } 

      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);
        }
       
      } else {
        if(options.contains("autoPublish=true")) {
View Full Code Here

      while(!done) {
        dh.setFirstResult(internalOffset);
        dh.setMaxResults(internalLimit);
        resultList = dh.list();
        PermissionAPI permAPI = APILocator.getPermissionAPI();
        toReturn.addAll(permAPI.filterCollection(resultList, PermissionAPI.PERMISSION_READ, false, user));
        if(countLimit > 0 && toReturn.size() >= countLimit + offset)
          done = true;
        else if(resultList.size() < internalLimit)
          done = true;
View Full Code Here

TOP

Related Classes of com.dotmarketing.business.PermissionAPI

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.