Package com.dotmarketing.portlets.files.struts

Examples of com.dotmarketing.portlets.files.struts.FileForm


      parentFolder = fileAPI.getFileFolder(file,WebAPILocator.getHostWebAPI().getCurrentHost(req), user, false);
    }

    // setting parent folder path and inode on the form bean
    if(parentFolder != null) {
      FileForm cf = (FileForm) form;
      cf.setSelectedparent(parentFolder.getName());
      cf.setParent(parentFolder.getInode());
      cf.setSelectedparentPath(APILocator.getIdentifierAPI().find(parentFolder).getPath());
      file.setParent(parentFolder.getInode());
    }


View Full Code Here


  public void processAction(ActionMapping mapping, ActionForm form, PortletConfig config, ActionRequest req,
      ActionResponse res) throws Exception {
   
    String cmd = req.getParameter(Constants.CMD);
    String referer = req.getParameter("referer");
    FileForm fileForm = (FileForm) form;
   
    // wraps request to get session object
    ActionRequestImpl reqImpl = (ActionRequestImpl) req;
    HttpServletRequest httpReq = reqImpl.getHttpServletRequest();
   
View Full Code Here

      parentFolder = fileAPI.getFileFolder(file,fileHost, user, false);
    }

    // setting parent folder path and inode on the form bean
    if(parentFolder != null) {
      FileForm cf = (FileForm) form;
      cf.setSelectedparent(parentFolder.getName());
      cf.setParent(parentFolder.getInode());
      cf.setSelectedparentPath(APILocator.getIdentifierAPI().find(parentFolder).getPath());
      file.setParent(parentFolder.getInode());
    }
    if(InodeUtils.isSet(file.getIdentifier())){
       APILocator.getFileAPI().invalidateCache(file);
    }
View Full Code Here

    try {
     
      // wraps request to get session object
      ActionRequestImpl reqImpl = (ActionRequestImpl) req;
      HttpServletRequest httpReq = reqImpl.getHttpServletRequest();
      FileForm fileForm = (FileForm) form;
      UploadPortletRequest uploadReq = PortalUtil.getUploadPortletRequest(req);
     
     
      // gets the new information for the container from the request
      // object
      File file = new File();
      file.setTitle(fileForm.getTitle());
      BeanUtils.copyProperties(file,fileForm);
      req.setAttribute(WebKeys.FILE_FORM_EDIT,file);
           
      // gets the current container being edited from the request object
      File currentFile = (File) req.getAttribute(WebKeys.FILE_EDIT);
     
      // parent folder
      String parent = ParamUtil.getString(req, "parent");
      Folder folder = APILocator.getFolderAPI().find(parent, user, false);
      //http://jira.dotmarketing.net/browse/DOTCMS-5899
      if(InodeUtils.isSet(currentFile.getIdentifier())){
        Identifier id = APILocator.getIdentifierAPI().find(currentFile);
        if(id!=null && InodeUtils.isSet(id.getInode())){
          String URI = id.getURI();
          String uriPath = URI.substring(0,URI.lastIndexOf("/")+1);
          String folderPath = APILocator.getIdentifierAPI().find(folder).getPath();
          if(!uriPath.equals(folderPath)){
            id.setURI(folderPath+currentFile.getFileName());
            APILocator.getIdentifierAPI().save(id);
          }
        }
      }

      req.setAttribute(WebKeys.PARENT_FOLDER, folder)// Since the above query is expensive, save it into request object
     
      if(currentFile!=null)
        file.setIdentifier(currentFile.getIdentifier());
     
      _checkPermissions(file, folder, user, httpReq);
     
      // gets user id from request for modified user
      String userId = user.getUserId();
     
      boolean previousShowMenu = file.isShowOnMenu();
     
      long uploadFileMaxSize = Long.parseLong(Config.getStringProperty("UPLOAD_FILE_MAX_SIZE"));

      //Checking the max file size
      java.io.File uploadedFile = uploadReq.getFile("uploadedFile");
     
      if(currentFile!=null && UtilMethods.isSet(currentFile.getInode())){
        java.io.File editedFile = new java.io.File(APILocator.getFileAPI().getAssetIOFile(currentFile).getPath()+"_text");
        if(editedFile.exists()){
          FileChannel ic = new FileInputStream(editedFile).getChannel();
          FileChannel oc = new FileOutputStream(APILocator.getFileAPI().getAssetIOFile(currentFile)).getChannel();
          ic.transferTo(0, ic.size(), oc);
          ic.close();
          oc.close();
        }
      }

     
      //Do we have an uploaded file or not?
      boolean haveUpload = (uploadedFile.exists() && uploadedFile.length()>0);
      boolean tmpFile = true;
     
      if(!haveUpload){

        // look for a edited file in the users session, if it is there, use that
        if(UtilMethods.isSet(fileForm.get_imageToolSaveFile())){
          String x =fileForm.get_imageToolSaveFile().trim();
          if( x != null){
            x = PublicEncryptionFactory.decryptString(x);
            uploadedFile = new java.io.File( x.trim());
            haveUpload = (uploadedFile.exists() && uploadedFile.length()>0);
          }
          else{
            x=null;
          }
          reqImpl.getHttpServletRequest().getSession().removeAttribute(WebKeys.IMAGE_TOOL_SAVE_FILES);
        }
      }
     
     
     
      if(haveUpload) {
        if ((uploadFileMaxSize > 0) && (uploadedFile.length() > uploadFileMaxSize)) {
          // when there is an error saving should unlock working asset
          WebAssetFactory.unLockAsset(currentFile);
          throw new ActionException();
        }
      }
     
     
      // CHECK THE FOLDER PATTERN
      if (UtilMethods.isSet(file.getFileName()) && !APILocator.getFolderAPI().matchFilter(folder, file.getFileName())) {
        SessionMessages.add(req, "error", "message.file_asset.error.filename.filters");
        // when there is an error saving should unlock working asset
        WebAssetFactory.unLockAsset(currentFile);
        throw new ActionException("message.file_asset.error.filename.filters");
      }
     
     
      // Checking permissions
      _checkPermissions(currentFile, folder, user, httpReq);
     
     
      //Setting some flags
      boolean editing = (InodeUtils.isSet(currentFile.getInode()));

     

      if(!haveUpload){
        uploadedFile = APILocator.getFileAPI().getAssetIOFile(currentFile);
        tmpFile = false;
      }
     
     
      // if we don't have a file anywhere, die
      if(!(uploadedFile.exists() && uploadedFile.length()>0)){
        SessionMessages.add(req, "error", "message.file_asset.error.nofile");
        // when there is an error saving should unlock working asset
        WebAssetFactory.unLockAsset(currentFile);
        throw new ActionException("message.file_asset.error.nofile")
      }

      String fileName = (editing) ? currentFile.getFileName() : fileForm.getFileName();
     
      //getting mime type
      String mimeType = APILocator.getFileAPI().getMimeType(fileName);

      file.setMimeType(mimeType);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.files.struts.FileForm

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.