Examples of ContentletAPI


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

    Contentlet newCont = new Contentlet();

    Structure fileAssetStr = StructureCache.getStructureByVelocityVarName(FileAssetAPI.DEFAULT_FILE_ASSET_STRUCTURE_VELOCITY_VAR_NAME);

    ContentletAPI conAPI = APILocator.getContentletAPI();

    newCont.setStructureInode(fileAssetStr.getInode());

    try {

      newCont.setLanguageId(APILocator.getLanguageAPI().getDefaultLanguage().getId());

      for(Field field : FieldsCache.getFieldsByStructureVariableName(fileAssetStr.getInode())){
        if(field.getVelocityVarName().equals(FileAssetAPI.TITLE_FIELD))
          conAPI.setContentletProperty(newCont, field, fileName);

        if(field.getVelocityVarName().equals(FileAssetAPI.HOST_FOLDER_FIELD))
          conAPI.setContentletProperty(newCont, field, APILocator.getHostAPI().findSystemHost().getInode());

        if(field.getVelocityVarName().equals(FileAssetAPI.BINARY_FIELD)){

          File binaryFile = null;
          if(UtilMethods.isSet(fileName)){
            fileName = ContentletUtil.sanitizeFileName(fileName);
            binaryFile = new File(APILocator.getFileAPI().getRealAssetPathTmpBinary()
                + File.separator + user.getUserId() + File.separator + FieldsCache.getField(fieldInode).getFieldContentlet()
                + File.separator + fileName.trim());
            }

          conAPI.setContentletProperty(newCont, field, binaryFile);
        }
      }

      newCont = conAPI.checkin(newCont, sysUser, false);

    } catch (Exception e) {
      Logger.error(this,"Contentlet failed while creating new binary content",e);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.