Package com.dotmarketing.portlets.structure.model

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


   * @param value The field value
   * @throws DotDataException
   */
  private static void setField(Structure structure, Contentlet contentlet, String fieldName, String[] values) throws DotDataException{

    Field field = structure.getFieldVar(fieldName);
    String value="";
    if(UtilMethods.isSet(field) && APILocator.getFieldAPI().valueSettable(field)){
      try{
        if(field.getFieldType().equals(Field.FieldType.MULTI_SELECT.toString()) || field.getFieldType().equals(Field.FieldType.CHECKBOX.toString())){
          for(String temp : values){
            value = temp+","+value;
          }
        }else {
          value = VelocityUtil.cleanVelocity(values[0]);
View Full Code Here


     */

    if(fileParameters.size() > 0){

      for(Map<String,Object> value : fileParameters){
        Field field = (Field)value.get("field");
        java.io.File uploadedFile = (java.io.File)value.get("file");
        String title = (String)value.get("title");
        Host host = (Host)value.get("host");
        contentlet = addFileToContentlet(contentlet, field,host, uploadedFile, user, title);
      }
View Full Code Here

    List<Field> fields = FieldsCache.getFieldsByStructureInode(st.getInode());
    for (Field f : fields) {
      if (f.getFieldName().equals(fieldName))
        return f;
    }
    return new Field();
  }
View Full Code Here

    List<Field> fields = FieldsCache.getFieldsByStructureInode(st.getInode());
    for (Field f : fields) {
      if (f.getFieldContentlet().equals(fieldName))
        return f;
    }
    return new Field();
  }
View Full Code Here

   * @return
   * @deprecated Try using the #getContentDetail or #getContentDetailByIdentifier macros to retrieve the fields of a content.
   */
  public Object getFieldValue(String fieldName, Contentlet content) {
    Structure structure = StructureCache.getStructureByInode(content.getStructureInode());
    Field theField = null;
    List<Field> fields = FieldsCache.getFieldsByStructureInode(structure.getInode());
    for (Field field : fields) {
      if (field.getFieldName().equals(fieldName)) {
        theField = field;
        break;
      }
    }
    if (theField == null)
      return null;
    try {
      return PropertyUtils.getProperty(content, theField.getFieldContentlet());
    } catch (Exception e) {
      Logger.error(this, e.getMessage(), e);
      return null;
    }
  }
View Full Code Here

   * @throws DotDataException
   * @deprecated This method was deprecated because it uses the presentation name of the field
   *              we encourage the use of the logical name of the field instead @see getFieldByLogicalName
   */
  public List<Contentlet> getContentsByStructureAndFieldValue(Structure structure, String fieldName, String fieldValue) throws DotDataException, DotSecurityException {
    Field field = structure.getField(fieldName);
    StringBuffer buffy = new StringBuffer();
    buffy.append("+live:true +deleted:false +structureInode:" + structure.getInode() + " +" + field.getFieldName() + ":" + fieldValue);
    return conAPI.search(buffy.toString(), 0, -1, "mod_date", user, true);
  }
View Full Code Here

          continue;
        if(orderBySeg.toLowerCase().equals("moddate")) {
          orderBy = orderBy.replaceAll("(?i)moddate", "mod_date");
          continue;
        }
        Field field = FieldFactory.getFieldByVariableName(contentlet.getStructureInode(), orderBySeg);
        if (field != null && InodeUtils.isSet(field.getInode()))
          orderBy = orderBy.replaceAll(orderBySeg, field.getFieldContentlet());
      }
    }
    return RelationshipFactory.getRelatedContentlets(relationship, contentlet, orderBy, null, true, limit);

  }
View Full Code Here

            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

      @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());
View Full Code Here

      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();

              fileData = new java.io.File(tempUserFolder.getAbsolutePath() + java.io.File.separator + fileName);
              if(fileData.exists())
View Full Code Here

TOP

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

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.