Package com.liferay.util.servlet

Examples of com.liferay.util.servlet.UploadPortletRequest


      com.liferay.portlet.RenderRequestImpl reqImpl = (com.liferay.portlet.RenderRequestImpl) req;
        HttpServletRequest httpReq = reqImpl.getHttpServletRequest();
        HttpSession session = httpReq.getSession();

    UploadPortletRequest uploadReq = PortalUtil.getUploadPortletRequest(req);

    String parent = ParamUtil.getString(req, "parent");

    //parent folder
    Folder folder = (Folder) APILocator.getFolderAPI().find(parent, user, false);

    String hostId=folder.getHostId();
    boolean isRootHost=APILocator.getFolderAPI().findSystemFolder().equals(folder);
    if(isRootHost)
        hostId=(String)session.getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);

    Host host=APILocator.getHostAPI().find(hostId, user, false);

    //check permissions
    if(isRootHost) {
        if(!APILocator.getPermissionAPI().doesUserHavePermission(host, PERMISSION_CAN_ADD_CHILDREN, user))
            throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
    }
    else {
        _checkUserPermissions(folder, user, PERMISSION_CAN_ADD_CHILDREN);
    }

    String fileNamesStr = ParamUtil.getString(req, "fileNames");
    if(!UtilMethods.isSet(fileNamesStr))
      throw new ActionException(LanguageUtil.get(user, "message.file_asset.alert.please.upload"));

    String selectedStructureInode = ParamUtil.getString(req, "selectedStructure");
    if(!UtilMethods.isSet(selectedStructureInode))
      selectedStructureInode = StructureCache.getStructureByVelocityVarName(FileAssetAPI.DEFAULT_FILE_ASSET_STRUCTURE_VELOCITY_VAR_NAME).getInode();

    String[] fileNamesArray = fileNamesStr.split(WebKeys.CONTENTLET_FORM_NAME_VALUE_SEPARATOR);
    String customMessage = LanguageUtil.get(user, "message.file_asset.error.filename.filters") + ": ";
    if(fileNamesArray.length > 2)
      SessionMessages.add(req, "custommessage", LanguageUtil.get(user, "message.contentlets.batch.reindexing.background"));
    boolean filterError = false;

    List<String> existingFileNames = new ArrayList<String>();
    for (int k=0;k<fileNamesArray.length;k++) {
      try{
        HibernateUtil.startTransaction();
        Contentlet contentlet = new Contentlet();
        contentlet.setStructureInode(selectedStructureInode);
        contentlet.setHost(hostId);
        contentlet.setFolder(folder.getInode());
        String fileName = fileNamesArray[k];
        String title = getFriendlyName(fileName);

        fileName = checkMACFileName(fileName);

        if(!APILocator.getFolderAPI().matchFilter(folder,fileName))
              {
           customMessage += fileName + ", ";
                 filterError = true;
                 continue;
              }

        if (fileName.length()>0) {

                    //sets filename for this new file
                    contentlet.setStringProperty("title", title);
                    contentlet.setStringProperty("fileName", fileName);

                    java.io.File uploadedFile = uploadReq.getFile(fileName);
                    contentlet.setBinary("fileAsset", uploadedFile);

                    if ( uploadedFile != null ) {

                        //checks if another identifier with the same name exists in the same folder
View Full Code Here


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

        zipTempDirectoryToStream(httpResponse.getOutputStream());

      }else if(cmd.equals("upload")) {

        UploadPortletRequest uploadReq = PortalUtil.getUploadPortletRequest(req);
        ActionResponseImpl responseImpl = (ActionResponseImpl) res;
        HttpServletResponse httpResponse = responseImpl.getHttpServletResponse();

        ActionRequestImpl requestImpl = (ActionRequestImpl) req;
        HttpServletRequest httpRequest = requestImpl.getHttpServletRequest();
View Full Code Here

    DynamicServletRequest dynamicReq =
      (DynamicServletRequest)actionReq.getHttpServletRequest();
    UploadServletRequest uploadReq =
      (UploadServletRequest)dynamicReq.getRequest();

    return new UploadPortletRequest(
      uploadReq, getPortletNamespace(actionReq.getPortletName()));
  }
View Full Code Here

      User systemUser = APILocator.getUserAPI().getSystemUser();

        UserManagerListSearchForm userForm = (UserManagerListSearchForm) form;

        UploadPortletRequest uploadReq = PortalUtil.getUploadPortletRequest(req);
        java.io.File uploadedFile = uploadReq.getFile("newUsersFile");
        StringBuffer returnMessage = new StringBuffer();

        User userLoader = PortalUtil.getUser(req);
        boolean someError = false;
        String companyId = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany().getCompanyId();
View Full Code Here

                        + File.separator
                        + Config
                      .getStringProperty("REPORT_PATH"));
            }

            UploadPortletRequest upr = PortalUtil
                .getUploadPortletRequest(req);
            File importFile = upr.getFile("jrxmlFile");
            if (importFile.exists()) {
              byte[] currentData = new byte[0];
              FileInputStream is = new FileInputStream(importFile);
              int size = is.available();
              currentData = new byte[size];
View Full Code Here

     
      try {
        Logger.debug(this, "Calling Preview Upload Method");

        //Validation
        UploadPortletRequest uploadReq = PortalUtil.getUploadPortletRequest(req);
        byte[] bytes = FileUtil.getBytes(uploadReq.getFile("file"));

        ImportContentletsForm importContentletsForm = (ImportContentletsForm) form;
        if(importContentletsForm.getStructure().isEmpty()){
          SessionMessages.add(req, "error", "structure-type-is-required");
          setForward(req, "portlet.ext.contentlet.import_contentlets");
View Full Code Here

        // Getting the http request
        ActionRequestImpl reqImpl = (ActionRequestImpl) req;
        HttpServletRequest httpReq = reqImpl.getHttpServletRequest();

    UploadPortletRequest uploadReq =
      PortalUtil.getUploadPortletRequest(req);

    byte[] bytes = FileUtil.getBytes(uploadReq.getFile("file_name"));

    if (bytes == null || bytes.length == 0) {
      throw new UploadException();
    }
View Full Code Here

TOP

Related Classes of com.liferay.util.servlet.UploadPortletRequest

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.