Package com.dotmarketing.portlets.structure.model

Examples of com.dotmarketing.portlets.structure.model.Structure


    }
    Collections.reverse(al);


    // get the structure and field
    @SuppressWarnings("deprecation")
    Structure structure = StructureCache.getStructureByName(structureName);
        if(structure ==null){
            Logger.error(this.getClass(), "getContentletByUrl unable to find structure " +structureName + "." +fieldName );
            return null;
        }


    List<Field> fields = FieldsCache.getFieldsByStructureInode(structure.getInode());
    Field field = null;
    for (Field f : fields) {
      try {
        if (f.getFieldName().equals(fieldName)) {
          field = f;
          break;
        }
      } catch (Exception e) {
      }
    }
        if(field ==null){
            Logger.error(this.getClass(), "getContentletByUrl unable to find field " +structureName + "." +fieldName );
            return null;
        }


    StringBuffer luceneQuery = new StringBuffer();
    luceneQuery.append(" +structureName:");
    luceneQuery.append(structure.getVelocityVarName());
    luceneQuery.append(" +(");
    int i = 0;
    for (String s : al) {
      luceneQuery.append("");
      luceneQuery.append(structure.getVelocityVarName()+"."+field.getVelocityVarName());
      luceneQuery.append(":");
      luceneQuery.append(s);

      if(++i < al.size()){
        luceneQuery.append(" ");
View Full Code Here


   */
  public List<String> findFieldValues(String structureName, String fieldName, User user) throws DotDataException {
    List<String> result = new ArrayList<String>();

    try {
      @SuppressWarnings("deprecation")
      Structure structure = StructureCache.getStructureByName(structureName);
      if ((structure == null) || !InodeUtils.isSet(structure.getInode()))
        return result;

      Field field = FieldFactory.getFieldByName(structure.getInode(), fieldName);
      if ((field == null) || !InodeUtils.isSet(field.getInode()))
        return result;

      result = conAPI.findFieldValues(structure.getInode(), field, user, true);
    } catch (Exception e) {
      Logger.debug(this, e.toString());
      HibernateUtil.closeSession();
    }

View Full Code Here

          query.setBuilderType(BuilderType.MENU_LINK)
        }
        else if(tableName.equalsIgnoreCase(BuilderType.FOLDER.toString())){
          query.setBuilderType(BuilderType.FOLDER);
        }else {
          Structure s = StructureCache.getStructureByVelocityVarName(tableName);
          if(!UtilMethods.isSet(s)){
            Logger.error(this, "table name doesn't exist");
            throw new ValidationException("table name doesn't exist");
          }
          query.setBuilderType(BuilderType.CONTENTLET);
View Full Code Here

      InputStream is = content;
      byte[] currentData = IOUtils.toByteArray(is);

      if(destinationFile==null){
        Contentlet fileAsset = new Contentlet();
        Structure faStructure = StructureCache.getStructureByInode(folder.getDefaultFileType());
        Field fieldVar = faStructure.getFieldVar(FileAssetAPI.BINARY_FIELD);
        fileAsset.setStructureInode(folder.getDefaultFileType());
        fileAsset.setFolder(folder.getInode());
        if (currentData != null) {
          java.io.File tempUserFolder = new java.io.File(APILocator.getFileAPI().getRealAssetPathTmpBinary() + java.io.File.separator + user.getUserId() +
              java.io.File.separator + fieldVar.getFieldContentlet());
          if (!tempUserFolder.exists())
            tempUserFolder.mkdirs();

          java.io.File fileData = new java.io.File(tempUserFolder.getAbsolutePath() + java.io.File.separator + fileName);
          if(fileData.exists())
            fileData.delete();
          // Saving the new working data
          FileChannel writeCurrentChannel = new FileOutputStream(fileData).getChannel();
          writeCurrentChannel.truncate(0);
          ByteBuffer buffer = ByteBuffer.allocate(currentData.length);
          buffer.put(currentData);
          buffer.position(0);
          writeCurrentChannel.write(buffer);
          writeCurrentChannel.force(false);
          writeCurrentChannel.close();
          fileAsset.setStringProperty(FileAssetAPI.TITLE_FIELD, fileName);
          fileAsset.setStringProperty(FileAssetAPI.FILE_NAME_FIELD, fileName);
          fileAsset.setBinary(FileAssetAPI.BINARY_FIELD, fileData);
          fileAsset.setHost(host.getIdentifier());
          fileAsset=APILocator.getContentletAPI().checkin(fileAsset, user, false);

          //Validate if the user have the right permission before
          if(isAutoPub && !perAPI.doesUserHavePermission(fileAsset, PermissionAPI.PERMISSION_PUBLISH, user) ){
            APILocator.getContentletAPI().archive(fileAsset, APILocator.getUserAPI().getSystemUser(), false);
            APILocator.getContentletAPI().delete(fileAsset, APILocator.getUserAPI().getSystemUser(), false);
            throw new DotSecurityException("User does not have permission to publish contentlets");
              }else if(!isAutoPub && !perAPI.doesUserHavePermission(fileAsset, PermissionAPI.PERMISSION_EDIT, user)){
                APILocator.getContentletAPI().archive(fileAsset, APILocator.getUserAPI().getSystemUser(), false);
            APILocator.getContentletAPI().delete(fileAsset, APILocator.getUserAPI().getSystemUser(), false);
            throw new DotSecurityException("User does not have permission to edit contentlets");
              }
          if(isAutoPub && perAPI.doesUserHavePermission(fileAsset, PermissionAPI.PERMISSION_PUBLISH, user)) {
              APILocator.getContentletAPI().publish(fileAsset, user, false);

              Date currentDate = new Date();
              fileResourceCache.add(resourceUri + "|" + user.getUserId(), currentDate.getTime());

          }
        }
      }else{

        if(destinationFile instanceof File){
          // Save the file size
          File file = fileAPI.getFileByURI(path, host, false, user, false);
          file.setSize(currentData.length);
          file.setModDate(modifiedDate);
          file.setModUser(user.getUserId());
          try {
            HibernateUtil.saveOrUpdate(file);
          } catch (DotHibernateException e1) {
            Logger.error(this,e1.getMessage(), e1);
          }
        }

        if (currentData != null) {
          // Saving the new working data
            java.io.File fileData;
            if(destinationFile instanceof File) {
                fileData=workingFile;
            }
            else {
              Structure faStructure = StructureCache.getStructureByInode(folder.getDefaultFileType());
              Field fieldVar = faStructure.getFieldVar(FileAssetAPI.BINARY_FIELD);
              java.io.File tempUserFolder = new java.io.File(APILocator.getFileAPI().getRealAssetPathTmpBinary() + java.io.File.separator + user.getUserId() +
                  java.io.File.separator + fieldVar.getFieldContentlet());
              if (!tempUserFolder.exists())
                tempUserFolder.mkdirs();
View Full Code Here

        if ( liveContentlet == null || !UtilMethods.isSet( liveContentlet.getIdentifier() ) ) {
            throw new DotStateException( "No live version Contentlet. Call setLive first" );
        }

        //Get the structure for this contentlet
        Structure structure = StructureCache.getStructureByInode( liveContentlet.getStructureInode() );

        if(contentlet.getMap().get(Contentlet.DONT_VALIDATE_ME) == null){
          if ( UtilMethods.isSet( structure.getExpireDateVar() ) ) {//Verify if the structure have a Expire Date Field set
                if ( UtilMethods.isSet( ident.getSysExpireDate() ) && ident.getSysExpireDate().after( new Date() ) ) {
                    throw new PublishStateException( "message.contentlet.unpublish.expired" );
                }
            }
        }
View Full Code Here

            if ( info == null || !UtilMethods.isSet( info.getIdentifier() ) ) {
                throw new DotStateException( "No version info. Call setWorking first" );
            }

            //Get the structure for this contentlet
            Structure structure = StructureCache.getStructureByInode( cont.getStructureInode() );

            if ( UtilMethods.isSet( structure.getPublishDateVar() ) ) {//Verify if the structure have a Publish Date Field set
                if ( UtilMethods.isSet( ident.getSysPublishDate() ) && ident.getSysPublishDate().after( new Date() ) ) {
                    throw new PublishStateException( "message.contentlet.publish.future.date" );
                }
            }
            if ( UtilMethods.isSet( structure.getExpireDateVar() ) ) {//Verify if the structure have a Expire Date Field set
                if ( UtilMethods.isSet( ident.getSysExpireDate() ) && ident.getSysExpireDate().before( new Date() ) ) {
                    throw new PublishStateException( "message.contentlet.expired" );
                }
            }
View Full Code Here

     */
  private static final long serialVersionUID = 1L;

  public Host() {
    map.put(SYSTEM_HOST_KEY, false);
    Structure st = StructureCache.getStructureByVelocityVarName("Host");
    this.map.put(STRUCTURE_INODE_KEY, st.getInode());
    setDefault(false);
    setSystemHost(false);
  }
View Full Code Here

  public void setDefault(boolean isDefault) {
    map.put(IS_DEFAULT_KEY, isDefault);
  }

  public String getStructureInode() {
    Structure st = StructureCache.getStructureByVelocityVarName("Host");
    return (String) st.getInode();
  }
View Full Code Here

    String message = "";
    String errorMessage = "";
    CmsMaintenanceForm ccf = (CmsMaintenanceForm) form;
    String cmd = req.getParameter("cmd");
    String defaultStructure = req.getParameter("defaultStructure")
    Structure structure = new Structure();

    //Manage all the cache Task
    if(cmd.equals("cache")){

      String cacheName = ccf.getCacheName();
      if (cacheName.equals(com.dotmarketing.util.WebKeys.Cache.CACHE_CONTENTS_INDEX))
      {
        Logger.info(this, "Running Contents Index Cache");
        if(defaultStructure.equals("Rebuild Whole Index")){
          structure = StructureCache.getStructureByVelocityVarName(defaultStructure);
        }else
          structure = StructureCache.getStructureByVelocityVarName(ccf.getStructure());
        if(!InodeUtils.isSet(structure.getInode()))
        {
          try{
            int shards = Config.getIntProperty("es.index.number_of_shards", 2);
            try{
              shards = Integer.parseInt(req.getParameter("shards"));
            }catch(Exception e){
             
            }
            System.setProperty("es.index.number_of_shards", String.valueOf(shards));
            Logger.info(this, "Running Contentlet Reindex");
            HibernateUtil.startTransaction();
            conAPI.reindex();
            HibernateUtil.commitTransaction();
            message = "message.cmsmaintenance.cache.indexrebuilt";
            AdminLogger.log(ViewCMSMaintenanceAction.class, "processAction", "Running Contentlet Reindex");
          }catch(DotReindexStateException dre){
            Logger.warn(this, "Content Reindexation Failed caused by: "+ dre.getMessage());
            errorMessage = "message.cmsmaintenance.cache.failedtorebuild";
            HibernateUtil.rollbackTransaction();
          }
        }
        else
        {
          try{
            Logger.info(this, "Running Contentlet Reindex on Structure: " + structure.getName());
            conAPI.reindex(structure);
            message = "message.cmsmaintenance.cache.indexrebuilt";
            AdminLogger.log(ViewCMSMaintenanceAction.class, "processAction", "Running Contentlet Reindex on structure : "+structure.getName());
          }catch(DotReindexStateException dre){
            Logger.warn(this, "Content Reindexation Failed caused by: "+ dre.getMessage());
            errorMessage = "message.cmsmaintenance.cache.failedtorebuild";
          }
        }
View Full Code Here

      String defaultFileType = req.getParameter("defaultFileType");
      if(!InodeUtils.isSet(defaultFileType)){
        SessionMessages.add(req, "message", "message.folder.defaultfiletype.required");
        return false;
      }
      Structure defaultStr = StructureCache.getStructureByInode(defaultFileType);
      if(defaultStr==null || !InodeUtils.isSet(defaultStr.getInode())){
        SessionMessages.add(req, "message", "message.folder.defaultfiletype.required");
        return false;
      }
      f.setDefaultFileType(defaultFileType);
     
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.structure.model.Structure

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.