Package com.dotmarketing.portlets.contentlet.business

Examples of com.dotmarketing.portlets.contentlet.business.DotContentletStateException


        if(contentlet == null){
            Logger.info(this, "No contents passed to delete so returning");
            return;
        }
        if(contentlet.getInode().equals(""))
            throw new DotContentletStateException(CAN_T_CHANGE_STATE_OF_CHECKED_OUT_CONTENT);
        if(!perAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_PUBLISH, user)){
            throw new DotSecurityException("User: "+ (user != null ? user.getUserId() : "Unknown")
                + " does not have permission to delete some or all of the contentlets");
        }
View Full Code Here



        try {

          if(contentlet.getInode().equals(""))
            throw new DotContentletStateException(CAN_T_CHANGE_STATE_OF_CHECKED_OUT_CONTENT);
          if(!perAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_EDIT, user, respectFrontendRoles)){
            throw new DotSecurityException("User: " + (user != null ? user.getUserId() : "Unknown")
                + " does not have permission to edit the contentlet");
          }
          Contentlet workingContentlet = findContentletByIdentifier(contentlet.getIdentifier(), false, contentlet.getLanguageId(), user, respectFrontendRoles);
          Contentlet liveContentlet = null;
          try{
            liveContentlet = findContentletByIdentifier(contentlet.getIdentifier(), true, contentlet.getLanguageId(), user, respectFrontendRoles);
          }catch (DotContentletStateException ce) {
            Logger.debug(this,"No live contentlet found for identifier = " + contentlet.getIdentifier());
          }




          canLock(contentlet, user);
          User modUser = null;

          try{
            modUser = APILocator.getUserAPI().loadUserById(workingContentlet.getModUser(),APILocator.getUserAPI().getSystemUser(),false);
          }catch(Exception ex){
            if(ex instanceof NoSuchUserException){
              modUser = APILocator.getUserAPI().getSystemUser();
            }
          }

          if(modUser != null){
            workingContentlet.setModUser(modUser.getUserId());
          }


          if (user == null || !workingContentlet.isLocked() || workingContentlet.getModUser().equals(user.getUserId())) {

            if (liveContentlet != null && InodeUtils.isSet(liveContentlet.getInode())) {
              APILocator.getVersionableAPI().removeLive(liveContentlet);
              indexAPI.removeContentFromLiveIndex(liveContentlet);
            }

            // sets deleted to true
            APILocator.getVersionableAPI().setDeleted(workingContentlet, true);

            // Updating lucene index
            indexAPI.addContentToIndex(workingContentlet);

            if(contentlet.getStructure().getStructureType()==Structure.STRUCTURE_TYPE_FILEASSET) {
              Identifier ident = APILocator.getIdentifierAPI().find(contentlet);
              CacheLocator.getCSSCache().remove(ident.getHostId(), ident.getPath(), true);
              CacheLocator.getCSSCache().remove(ident.getHostId(), ident.getPath(), false);
            }

            ContentletServices.invalidate(contentlet);
            ContentletMapServices.invalidate(contentlet);
            publishRelatedHtmlPages(contentlet);
          }else{
            throw new DotContentletStateException("Contentlet is locked: Unable to archive");
          }

        } catch(DotDataException | DotStateException| DotSecurityException e) {
          ActivityLogger.logInfo(getClass(), "Error Archiving Content", "StartDate: " +contentPushPublishDate+ "; "
              + "EndDate: " +contentPushExpireDate + "; User:" + (user != null ? user.getUserId() : "Unknown")
View Full Code Here

            }catch (DotContentletStateException e) {
                stateError = true;
            }
        }
        if(stateError){
            throw new DotContentletStateException("Unable to archive one or more contentlets because it is locked");
        }

    }
View Full Code Here

    }

    public void lock(Contentlet contentlet, User user,  boolean respectFrontendRoles) throws DotContentletStateException, DotDataException,DotSecurityException {
        if(contentlet == null){
            throw new DotContentletStateException("The contentlet cannot Be null");
        }


        String contentPushPublishDate = contentlet.getStringProperty("wfPublishDate");
    String contentPushPublishTime = contentlet.getStringProperty("wfPublishTime");
    String contentPushExpireDate = contentlet.getStringProperty("wfExpireDate");
    String contentPushExpireTime = contentlet.getStringProperty("wfExpireTime");

    contentPushPublishDate = UtilMethods.isSet(contentPushPublishDate)?contentPushPublishDate:"N/D";
    contentPushPublishTime = UtilMethods.isSet(contentPushPublishTime)?contentPushPublishTime:"N/D";
    contentPushExpireDate = UtilMethods.isSet(contentPushExpireDate)?contentPushExpireDate:"N/D";
    contentPushExpireTime = UtilMethods.isSet(contentPushExpireTime)?contentPushExpireTime:"N/D";

    ActivityLogger.logInfo(getClass(), "Locking Content", "StartDate: " +contentPushPublishDate+ "; "
        + "EndDate: " +contentPushExpireDate + "; User:" + (user != null ? user.getUserId() : "Unknown")
        + "; ContentIdentifier: " + (contentlet != null ? contentlet.getIdentifier() : "Unknown"), contentlet.getHost());


    try {

      if(contentlet.getInode().equals(""))
        throw new DotContentletStateException(CAN_T_CHANGE_STATE_OF_CHECKED_OUT_CONTENT);
      if(!perAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_WRITE, user, respectFrontendRoles)){
        throw new DotSecurityException("User cannot edit Contentlet");
      }

      canLock(contentlet, user);
View Full Code Here

    }

    public void unpublish(Contentlet contentlet, User user,boolean respectFrontendRoles) throws DotDataException,DotSecurityException, DotContentletStateException {
        if(contentlet.getInode().equals(""))
            throw new DotContentletStateException(CAN_T_CHANGE_STATE_OF_CHECKED_OUT_CONTENT);
        if(!perAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_PUBLISH, user, respectFrontendRoles)){
            throw new DotSecurityException("User: " + (user != null ? user.getUserId() : "Unknown") + " cannot unpublish Contentlet");
        }

View Full Code Here

        unpublish(contentlet, user);
    }

    private void unpublish(Contentlet contentlet, User user) throws DotDataException,DotSecurityException, DotContentletStateException {
        if(contentlet == null || !UtilMethods.isSet(contentlet.getInode())){
            throw new DotContentletStateException(CAN_T_CHANGE_STATE_OF_CHECKED_OUT_CONTENT);
        }

        String contentPushPublishDate = contentlet.getStringProperty("wfPublishDate");
        String contentPushPublishTime = contentlet.getStringProperty("wfPublishTime");
    String contentPushExpireDate = contentlet.getStringProperty("wfExpireDate");
View Full Code Here

            }catch (DotContentletStateException e) {
                stateError = true;
            }
        }
        if(stateError){
            throw new DotContentletStateException("Unable to unpublish one or more contentlets because it is locked");
        }
    }
View Full Code Here

            + "; ContentIdentifier: " + (contentlet != null ? contentlet.getIdentifier() : "Unknown"), contentlet.getHost());

        try {

          if(contentlet.getInode().equals(""))
            throw new DotContentletStateException(CAN_T_CHANGE_STATE_OF_CHECKED_OUT_CONTENT);
          if(!perAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_PUBLISH, user, respectFrontendRoles)){
            throw new DotSecurityException("User: " + (user != null ? user.getUserId() : "Unknown") + " cannot unpublish Contentlet");
          }
          Contentlet workingContentlet = findContentletByIdentifier(contentlet.getIdentifier(), false, contentlet.getLanguageId(), user, respectFrontendRoles);
          Contentlet liveContentlet = null;
          canLock(contentlet, user);
          try{
            liveContentlet = findContentletByIdentifier(contentlet.getIdentifier(), true, contentlet.getLanguageId(), user, respectFrontendRoles);
          }catch (DotContentletStateException ce) {
            Logger.debug(this,"No live contentlet found for identifier = " + contentlet.getIdentifier());
          }
          if(liveContentlet != null && liveContentlet.getInode().equalsIgnoreCase(workingContentlet.getInode()) && !workingContentlet.isArchived())
            throw new DotContentletStateException("Contentlet is unarchivable");

          APILocator.getVersionableAPI().setDeleted(workingContentlet, false);

          indexAPI.addContentToIndex(workingContentlet);
View Full Code Here

            }catch (DotContentletStateException e) {
                stateError = true;
            }
        }
        if(stateError){
            throw new DotContentletStateException("Unable to unarchive one or more contentlets because it is locked");
        }
    }
View Full Code Here

        if(!perAPI.doesUserHavePermission(contentlet, PermissionAPI.PERMISSION_EDIT, user, respectFrontendRoles)){
            throw new DotSecurityException("User: " + (user != null ? user.getUserId() : "Unknown") + " cannot edit Contentlet");
        }
        List<Relationship> rels = RelationshipFactory.getAllRelationshipsByStructure(contentlet.getStructure());
        if(!rels.contains(relationship)){
            throw new DotContentletStateException("Contentlet: " + (contentlet != null ? contentlet.getInode() : "Unknown") + " does not have passed in relationship");
        }
        List<Contentlet> cons = getRelatedContent(contentlet, relationship, hasParent, user, respectFrontendRoles);
        cons = perAPI.filterCollection(cons, PermissionAPI.PERMISSION_READ, respectFrontendRoles, user);
        RelationshipFactory.deleteRelationships(contentlet, relationship, cons);
    }
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.contentlet.business.DotContentletStateException

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.