Package com.dotmarketing.portlets.contentlet.model

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


        dc.addParam(folder.getHostId());
        dc.loadResult();
        for(HashMap<String, String> ident:contentInodes){
             String inode = ident.get("inode");
             cc.remove(inode);
             Contentlet content = find(inode);
             new ESContentletIndexAPI().addContentToIndex(content);
        }
  }
View Full Code Here


      return false;
    }
    ica = new InternalContextAdapterImpl(ctx);
    String fieldResourceName = ica.getCurrentTemplateName();
    String conInode = fieldResourceName.substring(fieldResourceName.indexOf("/") + 1, fieldResourceName.indexOf("_"));
    Contentlet con = APILocator.getContentletAPI().find(conInode, APILocator.getUserAPI().getSystemUser(), true);
    User mu = userAPI.loadUserById(con.getModUser(), APILocator.getUserAPI().getSystemUser(), true);
    Role scripting =APILocator.getRoleAPI().loadRoleByKey("Scripting Developer");
    return APILocator.getRoleAPI().doesUserHaveRole(mu, scripting);
  }
View Full Code Here

    String fieldResourceName = ica.getCurrentTemplateName();
    String inode = null;
    String userId = null;
    if (fieldResourceName.indexOf("field") > -1) {
      inode = fieldResourceName.substring(fieldResourceName.lastIndexOf("/") + 1, fieldResourceName.indexOf("_"));
      Contentlet con = APILocator.getContentletAPI().find(inode, APILocator.getUserAPI().getSystemUser(), true);
      userId = con.getModUser();
    } else if (fieldResourceName.indexOf("template") > -1) {
      inode = fieldResourceName.substring(fieldResourceName.lastIndexOf("/") + 1, fieldResourceName.indexOf("."));
      Template t = APILocator.getTemplateAPI().findWorkingTemplate(inode,
          APILocator.getUserAPI().getSystemUser(), true);
      userId = t.getModUser();
View Full Code Here

            }
            //GetPrevious version if exists
            IFileAsset currentFile = null;
            Identifier currentId = APILocator.getIdentifierAPI().find(host, pluginFolderPath+"/"+filePathAndName);
            if(currentId!=null && InodeUtils.isSet(currentId.getId()) && currentId.getAssetType().equals("contentlet")){
              Contentlet cont = APILocator.getContentletAPI().findContentletByIdentifier(currentId.getId(), true, APILocator.getLanguageAPI().getDefaultLanguage().getId(), APILocator.getUserAPI().getSystemUser(),false);
              if(cont!=null && InodeUtils.isSet(cont.getInode())){
                currentFile = APILocator.getFileAssetAPI().fromContentlet(cont);
                cont.setStringProperty(FileAssetAPI.TITLE_FIELD, UtilMethods.getFileName(fileName));
                cont.setFolder(folder.getInode());
                cont.setHost(host.getIdentifier());
                cont.setBinary(FileAssetAPI.BINARY_FIELD, temporaryFile);
                APILocator.getContentletAPI().checkin(cont, APILocator.getUserAPI().getSystemUser(),false);
                APILocator.getVersionableAPI().setWorking(cont);
                APILocator.getVersionableAPI().setLive(cont);
                if (cont.isLive()){
                  LiveCache.removeAssetFromCache(cont);
                  LiveCache.addToLiveAssetToCache(cont);
                }else{
                  LiveCache.removeAssetFromCache(cont);
                  LiveCache.addToLiveAssetToCache(cont);
                }
                WorkingCache.removeAssetFromCache(cont);
                WorkingCache.addToWorkingAssetToCache(cont);
              }
            }else if(currentId!=null && InodeUtils.isSet(currentId.getId())){
              currentFile = APILocator.getFileAPI().getFileByURI(pluginFolderPath+"/"+filePathAndName, host, true, APILocator.getUserAPI().getSystemUser(),false);
              com.dotmarketing.portlets.files.model.File file = new com.dotmarketing.portlets.files.model.File();
              file.setFileName(fileName);
              file.setFriendlyName(UtilMethods.getFileName(fileName));
              file.setTitle(UtilMethods.getFileName(fileName));
              file.setMimeType(APILocator.getFileAPI().getMimeType(fileName));
              file.setOwner(systemUser.getUserId());
              file.setModUser(systemUser.getUserId());
              file.setModDate(new Date());
              file.setParent(folder.getIdentifier());
              file.setSize((int)temporaryFile.length());
             
              HibernateUtil.saveOrUpdate(file);
              APILocator.getFileAPI().invalidateCache(file);
              // get the file Identifier
              Identifier ident = null;
              if (InodeUtils.isSet(currentFile.getInode())){
                ident = APILocator.getIdentifierAPI().find((com.dotmarketing.portlets.files.model.File)currentFile);
                APILocator.getFileAPI().invalidateCache((com.dotmarketing.portlets.files.model.File)currentFile);
              }else{
                ident = new Identifier();
              }
              //Saving the file, this creates the new version and save the new data
              com.dotmarketing.portlets.files.model.File workingFile = null;
              workingFile = APILocator.getFileAPI().saveFile(file, temporaryFile, folder, systemUser, false);
             
              APILocator.getVersionableAPI().setWorking(workingFile);
              APILocator.getVersionableAPI().setLive(workingFile);

              APILocator.getFileAPI().invalidateCache(workingFile);
              ident = APILocator.getIdentifierAPI().find(workingFile);

              //updating caches
              if (workingFile.isLive()){
                LiveCache.removeAssetFromCache(workingFile);
                LiveCache.addToLiveAssetToCache(workingFile);
              }else{
                LiveCache.removeAssetFromCache(file);
                LiveCache.addToLiveAssetToCache(file);
              }
              WorkingCache.removeAssetFromCache(workingFile);
              WorkingCache.addToWorkingAssetToCache(workingFile);
             
              //Publish the File
              PublishFactory.publishAsset(workingFile, systemUser, false);

            }else{
              Contentlet cont = new Contentlet();
              cont.setStructureInode(folder.getDefaultFileType());
              cont.setStringProperty(FileAssetAPI.TITLE_FIELD, UtilMethods.getFileName(fileName));
              cont.setFolder(folder.getInode());
              cont.setHost(host.getIdentifier());
              cont.setBinary(FileAssetAPI.BINARY_FIELD, temporaryFile);
              APILocator.getContentletAPI().checkin(cont, APILocator.getUserAPI().getSystemUser(),false);
              APILocator.getVersionableAPI().setWorking(cont);
              APILocator.getVersionableAPI().setLive(cont);
              if (cont.isLive()){
                LiveCache.removeAssetFromCache(cont);
                LiveCache.addToLiveAssetToCache(cont);
              }else{
                LiveCache.removeAssetFromCache(cont);
                LiveCache.addToLiveAssetToCache(cont);
View Full Code Here

        for (Rating rating : list) {
           
            try {
                row = new ArrayList<String>();
                Identifier id = APILocator.getIdentifierAPI().find(rating.getIdentifier());
                Contentlet content = conAPI.findContentletByIdentifier(id.getInode(), false, langAPI.getDefaultLanguage().getId(), APILocator.getUserAPI().getSystemUser(), true);
                String conTitle = conAPI.getName(content, APILocator.getUserAPI().getSystemUser(), true);
                row.add("" + structure.getInode());
                row.add(UtilMethods.isSet(structure.getName()) ? structure.getName() : "");
                row.add("" + content.getInode());
                row.add(UtilMethods.isSet(conTitle) ? conTitle : "");
                row.add("" + rating.getRating());
                row.add(UtilMethods.isSet(rating.getRatingDate()) ? UtilMethods.dateToHTMLDate(rating.getRatingDate()) : "");
                row.add(UtilMethods.isSet(rating.getUserId()) ? rating.getUserId() : "");
                row.add(UtilMethods.isSet(rating.getSessionId()) ? rating.getSessionId() : "");
View Full Code Here

                                    "on contentlet id '"+task.getWebasset()+"' "+
                                "timeout on step '"+step.getName()+"' " +
                                "excecuting escalation action '"+action.getName()+"'");
                           
                            // find contentlet for default language
                            Contentlet def=APILocator.getContentletAPI().findContentletByIdentifier(task.getWebasset(), false,
                                    APILocator.getLanguageAPI().getDefaultLanguage().getId(),
                                    APILocator.getUserAPI().getSystemUser(), false);
                            String inode=def.getInode();
                           
                            Contentlet c;

                            // if the worflow requires a checkin
                            if(action.requiresCheckout()){
                                c = APILocator.getContentletAPI().checkout(inode, APILocator.getUserAPI().getSystemUser(), false);
                                c.setStringProperty("wfActionId", action.getId());
                                c.setStringProperty("wfActionComments", wfActionComments);
                                c.setStringProperty("wfActionAssign", wfActionAssign);
                               
                                c = APILocator.getContentletAPI().checkin(c, APILocator.getUserAPI().getSystemUser(), false);
                            }
                           
                            // if the worflow requires a checkin
                            else{
                                c = APILocator.getContentletAPI().find(inode, APILocator.getUserAPI().getSystemUser(), false);
                                c.setStringProperty("wfActionId", action.getId());
                                c.setStringProperty("wfActionComments", wfActionComments);
                                c.setStringProperty("wfActionAssign", wfActionAssign);
                                wapi.fireWorkflowNoCheckin(c, APILocator.getUserAPI().getSystemUser());
                            }
                        }
                        HibernateUtil.commitTransaction();
                    }
View Full Code Here

                    + "</lastmod><changefreq>daily</changefreq></url>\n";
                writeFile(stringbuf);
                addRegistryProcessed();
              }
            } else if (itemChild instanceof Contentlet) {
              Contentlet fileContent = (Contentlet)itemChild;
              if (fileContent.isLive() && !fileContent.isArchived()) {
                Identifier identifier = APILocator.getIdentifierAPI().find(fileContent);
                stringbuf = "<url><loc>"
                    + XMLUtils.xmlEscape("http://"
                        + host.getHostname()
                        + UtilMethods.encodeURIComponent(identifier.getParentPath()+fileContent.getStringProperty(FileAssetAPI.FILE_NAME_FIELD)))
                    + "</loc><lastmod>"
                    + modifiedDateStringValue
                    + "</lastmod><changefreq>daily</changefreq></url>\n";
                writeFile(stringbuf);
                addRegistryProcessed();
View Full Code Here

                + "</lastmod><changefreq>daily</changefreq></url>\n";
            writeFile(stringbuf);
            addRegistryProcessed();
          }
        } else if (childChild2 instanceof Contentlet) {
          Contentlet fileContent = (Contentlet)childChild2;
          if (fileContent.isLive() && !fileContent.isArchived()) {
            Identifier identifier = APILocator.getIdentifierAPI().find(fileContent);
            stringbuf = "<url><loc>"
                + XMLUtils.xmlEscape("http://"
                    + host.getHostname()
                    + UtilMethods.encodeURIComponent(identifier.getParentPath()+fileContent.getStringProperty(FileAssetAPI.FILE_NAME_FIELD)))
                + "</loc><lastmod>"
                + modifiedDateStringValue
                + "</lastmod><changefreq>daily</changefreq></url>\n";
            writeFile(stringbuf);
            addRegistryProcessed();
View Full Code Here

            currentHost, systemUser, true);
      }

      java.io.File uploadedFile = new java.io.File(sitemapName);
      // Create the new file
      Contentlet file = new Contentlet();
      file.setStructureInode(folder.getDefaultFileType());
      file.setStringProperty(FileAssetAPI.TITLE_FIELD, UtilMethods.getFileName(sitemapName));
      file.setFolder(folder.getInode());
      file.setHost(currentHost.getIdentifier());
      file.setBinary(FileAssetAPI.BINARY_FIELD, uploadedFile);
      if(StructureCache.getStructureByInode(file.getStructureInode()).getStructureType() == Structure.STRUCTURE_TYPE_FILEASSET)
        file.setStringProperty("fileName", sitemapName);
      file = APILocator.getContentletAPI().checkin(file, systemUser,false);
      if(APILocator.getPermissionAPI().doesUserHavePermission(file, PermissionAPI.PERMISSION_PUBLISH, systemUser))
        APILocator.getVersionableAPI().setLive(file);
      APILocator.getVersionableAPI().setWorking(file);
View Full Code Here

      tmp.delete();
      tmp.mkdirs();
      tmp = new java.io.File(tmp,filename);
      FileUtils.writeStringToFile(tmp, "this is a test text");
     
      Contentlet file = new Contentlet();
      file.setStringProperty(FileAssetAPI.FILE_NAME_FIELD, filename);
      file.setStringProperty(FileAssetAPI.TITLE_FIELD, filename);
      file.setStringProperty(FileAssetAPI.HOST_FOLDER_FIELD,hostid);
      file.setBinary(FileAssetAPI.BINARY_FIELD, tmp);
      file.setStructureInode(StructureCache.getStructureByVelocityVarName("fileAsset").getInode());
      file.setLanguageId(1);
      file.setHost(hostid);
      file.setFolder("SYSTEM_FOLDER");
      file = APILocator.getContentletAPI().checkin(file, user, false);
      APILocator.getContentletAPI().isInodeIndexed(file.getInode());
     
     
      final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Host hh=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
       
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.