Package com.dotmarketing.portlets.contentlet.model

Examples of com.dotmarketing.portlets.contentlet.model.Contentlet$ContentletHashMap


    List<Versionable> result = new ArrayList<Versionable>();

    for(PreviewFileAsset pfa: inodes){
      // check if it's a contentlet
      if(pfa.isContentlet()){
        Contentlet aContentlet = APILocator.getContentletAPI().find(pfa.getInode(), APILocator.getUserAPI().getSystemUser(), false);
        result.add(aContentlet);
      }else{ //a File
        File aFile = APILocator.getFileAPI().find(pfa.getInode(), APILocator.getUserAPI().getSystemUser(), false);
        result.add(aFile);
      }
View Full Code Here


    java.io.File assetFile = null;
    java.io.File previewAsset = null;
    // if the file imported is a FileAsset/Contentlet...
    if(asset instanceof Contentlet){
      Contentlet c = (Contentlet)asset;
      assetFile = APILocator.getContentletAPI().getBinaryFile(c.getInode(), FileAssetAPI.BINARY_FIELD, APILocator.getUserAPI().getSystemUser());
      previewAsset = new java.io.File(importedFilesAssetDir, assetFile.getName());
      if(previewAsset.exists())
        previewAsset.delete();
      result.setContentlet(true);
      result.setInode(c.getInode());
      result.setParent(c.getFolder());
    }else if(asset instanceof File){ // is a File
      File f = (File)asset;
      assetFile =  APILocator.getFileAPI().getAssetIOFile(f);
      previewAsset = new java.io.File(importedFilesAssetDir, assetFile.getName());
      if(previewAsset.exists())
View Full Code Here

    List<String> existingFileNames = new ArrayList<String>();
    for (int k=0;k<fileNamesArray.length;k++) {
      try{
        HibernateUtil.startTransaction();
        Contentlet contentlet = new Contentlet();
        contentlet.setStructureInode(selectedStructureInode);
        contentlet.setHost(hostId);
        contentlet.setFolder(folder.getInode());
        String fileName = fileNamesArray[k];
        String title = getFriendlyName(fileName);

        fileName = checkMACFileName(fileName);

        if(!APILocator.getFolderAPI().matchFilter(folder,fileName))
              {
           customMessage += fileName + ", ";
                 filterError = true;
                 continue;
              }

        if (fileName.length()>0) {

                    //sets filename for this new file
                    contentlet.setStringProperty("title", title);
                    contentlet.setStringProperty("fileName", fileName);

                    java.io.File uploadedFile = uploadReq.getFile(fileName);
                    contentlet.setBinary("fileAsset", uploadedFile);

                    if ( uploadedFile != null ) {

                        //checks if another identifier with the same name exists in the same folder
                        if (APILocator.getFileAssetAPI().fileNameExists(host, folder, fileName, "")) {
                            throw new DuplicateFileException(fileName);
                        }

                        contentlet = APILocator.getContentletAPI().checkin( contentlet, user, false );
                        if ( (subcmd != null) && subcmd.equals( com.dotmarketing.util.Constants.PUBLISH ) ) {
                            if ( isRootHost
                                    && !APILocator.getPermissionAPI().doesUserHaveInheriablePermissions( host, File.class.getCanonicalName(), PermissionAPI.PERMISSION_PUBLISH, user )
                                    && !isAdmin ) {
                                throw new ActionException( WebKeys.USER_PERMISSIONS_EXCEPTION );
                            }

                            APILocator.getVersionableAPI().setLive( contentlet );
                        }

                        HibernateUtil.commitTransaction();
                        APILocator.getContentletAPI().isInodeIndexed(contentlet.getInode());

                    }
        }
      }
      catch (DuplicateFileException e){
View Full Code Here

                if(folder!=null && InodeUtils.isSet(folder.getInode())) {
                    return new FolderResourceImpl(folder,path+folder.getPath());
                }
            }
            else if(ident.getAssetType().equals("contentlet")) {
                Contentlet cont=APILocator.getContentletAPI().findContentletByIdentifier(ident.getId(), false, 1, user, false);
                if(cont!=null && InodeUtils.isSet(cont.getInode())) {
                    return new FileResourceImpl(APILocator.getFileAssetAPI().fromContentlet(cont),path+uri);
                }
            }
        }
        } catch (Exception e) {
View Full Code Here

      Logger.error(this, e.getMessage());
    }
    if(template!=null){
      Identifier imageIdentifier = APILocator.getIdentifierAPI().find(template.getImage());
      if(UtilMethods.isSet(imageIdentifier.getAssetType()) && imageIdentifier.getAssetType().equals("contentlet")) {
        Contentlet imageContentlet = TemplateFactory.getImageContentlet(template);
        if(imageContentlet!=null){
          toReturn.put("inode", imageContentlet.getInode());
          toReturn.put("name", imageContentlet.getTitle());
          toReturn.put("identifier", imageContentlet.getIdentifier());
          toReturn.put("extension", com.dotmarketing.util.UtilMethods.getFileExtension(imageContentlet.getTitle()));
        }
      } else {
        File imgFile = TemplateFactory.getImageFile(template);
        if(imgFile!=null){
          toReturn.put("inode", imgFile.getInode());
View Full Code Here

        HashMap<Integer, String> hashInodes = hashMap.get(key);
        for (int i = 0; i < hashInodes.size(); i++) {
          String inode = (String) hashInodes.get(i);
          Inode asset = (Inode) InodeFactory.getInode(inode,
              Inode.class);
          Contentlet c = null;
          try {
            c = APILocator.getContentletAPI().find(inode, user,
                false);
          } catch (ClassCastException cce) {
            // Continue
          }
          if (asset instanceof Folder) {
            ((Folder) asset).setSortOrder(i);
            ret.add(((Folder) asset));
          }
          if (asset instanceof WebAsset) {
            ((WebAsset) asset).setSortOrder(i);
            ret.add(((WebAsset) asset));
          }
          if (APILocator.getFileAssetAPI().isFileAsset(c)) {
            ret.add(c);
            c.setSortOrder(i);
            APILocator.getContentletAPI().refresh(c);
          }
          HibernateUtil.saveOrUpdate(asset);
        }
      }
View Full Code Here

    Iterator i = itemsList.iterator();
    int x = 0;
    while (i.hasNext()) {

      Inode item = (Inode) i.next();
      Contentlet c = null;
      try {
        c = APILocator.getContentletAPI().find(item.getInode(), user, false);
      } catch(ClassCastException cce) {
      }

      if (item.getInode().equalsIgnoreCase( itemInode)) {
        //this is the item to move
        if (item instanceof Folder) {
          ((Folder)item).setSortOrder(x + increment);
        }
        else if(item instanceof WebAsset) {
          ((WebAsset)item).setSortOrder(x + increment);
        } if (APILocator.getFileAssetAPI().isFileAsset(c))  {
          c.setSortOrder(x + increment);
          APILocator.getContentletAPI().refresh(c);
        }
      }
      else {
        //all other items
        if (item instanceof Folder) {
          ((Folder)item).setSortOrder(x);
        }
        else if(item instanceof WebAsset) {
          ((WebAsset)item).setSortOrder(x);
        if (APILocator.getFileAssetAPI().isFileAsset(c))  {
          c.setSortOrder(x);
          APILocator.getContentletAPI().refresh(c);
        }
      }
      x = x + 2;
    }
View Full Code Here

                inodes.add(liveInode);
              }
            }
           
            for(String inode : inodes) {
                Contentlet con=APILocator.getContentletAPI().find(inode, APILocator.getUserAPI().getSystemUser(), false);
                contentToIndex.add(con);
            }
        }
        return contentToIndex;
  }
View Full Code Here

  }

  @Override
  public Contentlet convertFatContentletToContentlet(com.dotmarketing.portlets.contentlet.business.Contentlet fatty)
      throws DotDataException, DotStateException, DotSecurityException {
      Contentlet con = new Contentlet();


        con.setStructureInode(fatty.getStructureInode());
        Map<String, Object> contentletMap = fatty.getMap();

        try {
            APILocator.getContentletAPI().copyProperties(con, contentletMap);
        } catch (Exception e) {
            Logger.error(this,"Unable to copy contentlet properties",e);
            throw new DotDataException("Unable to copy contentlet properties",e);
        }
        con.setInode(fatty.getInode());
        con.setStructureInode(fatty.getStructureInode());
        con.setIdentifier(fatty.getIdentifier());
        con.setSortOrder(fatty.getSortOrder());
        con.setLanguageId(fatty.getLanguageId());
        con.setNextReview(fatty.getNextReview());
        con.setLastReview(fatty.getLastReview());
        con.setOwner(fatty.getOwner());
        con.setModUser(fatty.getModUser());
        con.setModDate(fatty.getModDate());
        con.setReviewInterval(fatty.getReviewInterval());



       if(UtilMethods.isSet(fatty.getIdentifier())){
          IdentifierAPI identifierAPI = APILocator.getIdentifierAPI();
          Identifier identifier = identifierAPI.find(fatty.getIdentifier());
          Folder folder = null;
          if(identifier.getParentPath().length()>1){
              folder = APILocator.getFolderAPI().findFolderByPath(identifier.getParentPath(), identifier.getHostId(), APILocator.getUserAPI().getSystemUser(),false);
          }else{
              folder = APILocator.getFolderAPI().findSystemFolder();
          }
          con.setHost(identifier.getHostId());
          con.setFolder(folder.getInode());

          // lets check if we have publish/expire fields to set
          Structure st=con.getStructure();
          if(UtilMethods.isSet(st.getPublishDateVar()))
              con.setDateProperty(st.getPublishDateVar(), identifier.getSysPublishDate());
          if(UtilMethods.isSet(st.getExpireDateVar()))
              con.setDateProperty(st.getExpireDateVar(), identifier.getSysExpireDate());
    }
       else{
           con.setHost(APILocator.getHostAPI().findSystemHost().getIdentifier());
           con.setFolder(APILocator.getFolderAPI().findSystemFolder().getInode());
       }
        String wysiwyg = fatty.getDisabledWysiwyg();
        if( UtilMethods.isSet(wysiwyg) ) {
            List<String> wysiwygFields = new ArrayList<String>();
            StringTokenizer st = new StringTokenizer(wysiwyg,",");
            while( st.hasMoreTokens() ) wysiwygFields.add(st.nextToken().trim());
            con.setDisabledWysiwyg(wysiwygFields);
        }
        return con;
  }
View Full Code Here

                for(java.io.File ff2 : ff1.listFiles())
                    if(ff2.isDirectory() && ff2.getName().length()==1 && ff2.getName().matches("^[a-f0-9]$"))
                        for(java.io.File ff3 : ff2.listFiles())
                            try {
                                if(ff3.isDirectory()) {
                                    Contentlet con=find(ff3.getName());
                                    if(con==null || !UtilMethods.isSet(con.getIdentifier()))
                                        if(!FileUtils.deleteQuietly(ff3))
                                            Logger.warn(this, "can't delete "+ff3.getAbsolutePath());
                                }
                            }
                            catch(Exception ex) {
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.contentlet.model.Contentlet$ContentletHashMap

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.