Package webwork.multipart

Examples of webwork.multipart.MultiPartRequestWrapper


      logger.error("Bad filesize in principal properties: " + fileUploadMaximumSize);
    }
     
        try
        {
            MultiPartRequestWrapper mpr = ActionContext.getMultiPartRequest();
            if(mpr == null)
            {
                this.reasonKey = "tool.contenttool.fileUpload.fileUploadFailedOnSizeText";
               
                //------------------------------------------------------------------
                // If we fail because the file is bigger than the system maximum
                // we might still want to print the local maximum file size because
                // it makes more sense to the user.
                //------------------------------------------------------------------
               
                if (uploadMaxSize > myFileUploadSizeLimit && myFileUploadSizeLimit > -1)
                {
                  this.uploadMaxSize = getLocalizedString(getLocale(), "tool.contenttool.myFileUploadLimit", formatter.formatFileSize(myFileUploadSizeLimit));
                }
                else if (digitalAssetKey == null)
                {
                  this.uploadMaxSize = getLocalizedString(getLocale(), "tool.contenttool.systemWideFileUploadLimit", formatter.formatFileSize(uploadMaxSize));                 
                }
                else if(this.contentTypeDefinitionId != null && digitalAssetKey != null)
        {
          this.contentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(this.contentTypeDefinitionId);
          AssetKeyDefinition assetKeyDefinition = ContentTypeDefinitionController.getController().getDefinedAssetKey(contentTypeDefinitionVO, true, digitalAssetKey);
         
          if(assetKeyDefinition != null)
          {
            this.uploadMaxSize = getLocalizedString(getLocale(), "tool.contenttool.myFileUploadLimit", formatter.formatFileSize(assetKeyDefinition.getMaximumSize()));
          }
                }
               
                return "uploadFailed";
            }
           
          if(this.contentVersionId != null)
          {
          this.contentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(this.contentVersionId);
            this.contentTypeDefinitionVO = ContentController.getContentController().getContentTypeDefinition(contentVersionVO.getContentId());
          }
          else
          {
              if(this.entity.equalsIgnoreCase(UserProperties.class.getName()))
              {
                  UserPropertiesVO userPropertiesVO = UserPropertiesController.getController().getUserPropertiesVOWithId(this.entityId);
                  this.contentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(userPropertiesVO.getContentTypeDefinitionId());           
              }
              else if(this.entity.equalsIgnoreCase(RoleProperties.class.getName()))
              {
                  RolePropertiesVO rolePropertiesVO = RolePropertiesController.getController().getRolePropertiesVOWithId(this.entityId);
                  this.contentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(rolePropertiesVO.getContentTypeDefinitionId());           
              }
              else if(this.entity.equalsIgnoreCase(GroupProperties.class.getName()))
              {
                  GroupPropertiesVO groupPropertiesVO = GroupPropertiesController.getController().getGroupPropertiesVOWithId(this.entityId);
                  this.contentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(groupPropertiesVO.getContentTypeDefinitionId());           
              }
          }
         
 
        InputStream is = null;
      //File renamedFile = null;
      File file = null;
     
        try
        {
          if(mpr != null)
          {
            Enumeration names = mpr.getFileNames();
               while (names.hasMoreElements())
               {
                  String name       = (String)names.nextElement();
            String contentType    = mpr.getContentType(name);
            String fileSystemName = mpr.getFilesystemName(name);

            String fromEncoding = CmsPropertyHandler.getUploadFromEncoding();
            if(fromEncoding == null)
              fromEncoding = "iso-8859-1";
           
            String toEncoding = CmsPropertyHandler.getUploadToEncoding();
            if(toEncoding == null)
              toEncoding = "utf-8";
           
                  digitalAssetKey = new String(digitalAssetKey.getBytes(fromEncoding), toEncoding);
                  fileSystemName = new String(fileSystemName.getBytes(fromEncoding), toEncoding);
                                   
                  logger.info("digitalAssetKey:" + digitalAssetKey);
                  logger.info("name:" + name);
                  logger.info("contentType:" + contentType);
                  logger.info("fileSystemName:" + fileSystemName);
                  if(digitalAssetKey == null || digitalAssetKey.equals(""))
                  {
                    if(fileSystemName.lastIndexOf(".") > -1)
                      digitalAssetKey = fileSystemName.substring(0, fileSystemName.lastIndexOf("."));
                   
                    digitalAssetKey = formatter.replaceNiceURINonAsciiWithSpecifiedChars(digitalAssetKey, CmsPropertyHandler.getNiceURIDefaultReplacementCharacter());
                    //digitalAssetKey = formatter.replaceNonAscii(digitalAssetKey, '_');
                  }
                  logger.info("digitalAssetKey:" + digitalAssetKey);
                 
                  if(useFileNameAsContentTypeBase)
                  {
                    if(fileSystemName.lastIndexOf(".") > -1)
                    {
                      String extension = fileSystemName.substring(fileSystemName.lastIndexOf(".") + 1);
                      logger.info("extension:" + extension)

                      if(extension.equalsIgnoreCase("gif"))
                        contentType = "image/gif";
                      else if(extension.equalsIgnoreCase("jpg"))
                        contentType = "image/jpg";
                      else if(extension.equalsIgnoreCase("png"))
                        contentType = "image/png";
                     
                      else if(extension.equalsIgnoreCase("pdf"))
                        contentType = "application/pdf";
                      else if(extension.equalsIgnoreCase("doc"))
                        contentType = "application/msword";
                      else if(extension.equalsIgnoreCase("xls"))
                        contentType = "application/vnd.ms-excel";
                      else if(extension.equalsIgnoreCase("ppt"))
                        contentType = "application/vnd.ms-powerpoint";
                      else if(extension.equalsIgnoreCase("zip"))
                        contentType = "application/zip";
                      else if(extension.equalsIgnoreCase("xml"))
                        contentType = "text/xml";                   
                    }
                  }
                  logger.info("contentType:" + contentType);
                 
                  file = mpr.getFile(name);
                  logger.info("file:" + file.getPath());
                  logger.info("file.exists:" + file.exists());
                  logger.info("file.length:" + file.length());
                 
            String fileName = fileSystemName;
View Full Code Here


    public String doExecute() //throws Exception
    {
        try
    {
      MultiPartRequestWrapper mpr = ActionContext.getMultiPartRequest();
      if (mpr == null)
      {
        return "input";
      }

      log.debug("Handling upload...");
      Enumeration names = mpr.getFileNames();
      if (names.hasMoreElements())
      {
        String name = (String) names.nextElement();
        log.debug("name:" + name);
        File uploadedFile = mpr.getFile(name);
        if (uploadedFile == null || uploadedFile.length() == 0)
        {
          log.error("No file found in multipart request");
          return "input";
        }

        String contentType = mpr.getContentType(name);
        String fileName = mpr.getFilesystemName(name);
        String filePath = CmsPropertyHandler.getDigitalAssetPath();
        log.debug("fileName:" + fileName);
       
        // Pluto prepare portlet-war
        String appName = fileName;
View Full Code Here

      logger.error("Bad filesize in principal properties: " + fileUploadMaximumSize);
    }
       
    try
        {
            MultiPartRequestWrapper mpr = ActionContext.getMultiPartRequest();
            if(mpr == null)
            {
                this.reasonKey = "tool.contenttool.fileUpload.fileUploadFailedOnSizeText";
               
                //------------------------------------------------------------------
                // If we fail because the file is bigger than the system maximum
                // we might still want to print the local maximum file size because
                // it makes more sense to the user.
                //------------------------------------------------------------------
               
                if (uploadMaxSize > myFileUploadSizeLimit && myFileUploadSizeLimit > -1)
                {
                  this.uploadMaxSize = getLocalizedString(getLocale(), "tool.contenttool.myFileUploadLimit", formatter.formatFileSize(myFileUploadSizeLimit));
                }
                else if (digitalAssetKey == null)
                {
                  this.uploadMaxSize = getLocalizedString(getLocale(), "tool.contenttool.systemWideFileUploadLimit", formatter.formatFileSize(uploadMaxSize));                 
                }
                else if(this.contentTypeDefinitionId != null && digitalAssetKey != null)
        {
          this.contentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(this.contentTypeDefinitionId);
          AssetKeyDefinition assetKeyDefinition = ContentTypeDefinitionController.getController().getDefinedAssetKey(contentTypeDefinitionVO, true, digitalAssetKey);
         
          if(assetKeyDefinition != null)
          {
            this.uploadMaxSize = getLocalizedString(getLocale(), "tool.contenttool.myFileUploadLimit", formatter.formatFileSize(assetKeyDefinition.getMaximumSize()));
          }
                }
               
                return "uploadFailed";
            }
           
      String fromEncoding = CmsPropertyHandler.getUploadFromEncoding();
      if(fromEncoding == null)
        fromEncoding = "iso-8859-1";
     
      String toEncoding = CmsPropertyHandler.getUploadToEncoding();
      if(toEncoding == null)
        toEncoding = "utf-8";
     
      this.digitalAssetKey = new String(this.digitalAssetKey.getBytes(fromEncoding), toEncoding);

      List<Integer> newContentVersionIdList = new ArrayList<Integer>();

      DigitalAssetVO digitalAssetVO = ContentVersionController.getContentVersionController().checkStateAndChangeIfNeeded(contentVersionId, digitalAssetId, getInfoGluePrincipal(), newContentVersionIdList);
     
      if(newContentVersionIdList.size() > 0)
        {
          Integer newContentVersionId = newContentVersionIdList.get(0);
          if(this.contentVersionId != newContentVersionId)
            refreshAll = true;
          setContentVersionId(newContentVersionId);
        }
     
      digitalAssetVO.setAssetKey(this.digitalAssetKey);

        if(mpr != null)
        {
          Enumeration names = mpr.getFileNames();
             while (names.hasMoreElements())
             {
                String name = (String)names.nextElement();
                         
                file = mpr.getFile(name);
                if(file != null)
                {
                  String contentType    = mpr.getContentType(name);
            String fileSystemName = mpr.getFilesystemName(name);
         
            String fileName = fileSystemName;
                  fileName = formatter.replaceNiceURINonAsciiWithSpecifiedChars(fileName, CmsPropertyHandler.getNiceURIDefaultReplacementCharacter());
            //fileName = new VisualFormatter().replaceNonAscii(fileName, '_');
View Full Code Here

    File renamedFile = null;
    DigitalAssetVO digitalAssetVO = null;
   
    try
    {
      MultiPartRequestWrapper mpr = ActionContext.getContext().getMultiPartRequest();
      if(mpr != null)
      {
        String fromEncoding = CmsPropertyHandler.getUploadFromEncoding();
        if(fromEncoding == null)
          fromEncoding = "iso-8859-1";
       
        String toEncoding = CmsPropertyHandler.getUploadToEncoding();
        if(toEncoding == null)
          toEncoding = "utf-8";
       
        this.digitalAssetKey = new String(this.digitalAssetKey.getBytes(fromEncoding), toEncoding);

        Enumeration names = mpr.getFileNames();
        while (names.hasMoreElements())
        {
          String name       = (String)names.nextElement();
          String contentType    = mpr.getContentType(name);
          String fileSystemName = mpr.getFilesystemName(name);
         
          File file = mpr.getFile(name);
          String fileName = fileSystemName;
          //String fileName = digitalAssetKey + "_" + System.currentTimeMillis() + "_" + fileSystemName;
          //String tempFileName = "tmp_" + fileName;
          //tempFileName = new VisualFormatter().replaceNonAscii(fileName, '_');
         
View Full Code Here

      if(this.principal == null)
        this.principal = getInfoGluePrincipal();

        try
        {
            MultiPartRequestWrapper mpr = ActionContext.getMultiPartRequest();
            if(mpr == null)
            {
                this.reasonKey = "tool.contenttool.fileUpload.fileUploadFailedOnSizeText";
                this.uploadMaxSize = getLocalizedString(getLocale(), "tool.contenttool.systemWideFileUploadLimit", formatter.formatFileSize(getUploadMaxSize()));
                return "uploadFailed";
            }
           
      File file = null;
     
        try
        {
          if(mpr != null)
          {
            Enumeration names = mpr.getFileNames();
               while (names.hasMoreElements())
               {
                  String name       = (String)names.nextElement();
            String contentType    = mpr.getContentType(name);
            String fileSystemName = mpr.getFilesystemName(name);
           
            logger.info("contentType:" + contentType);
            logger.info("fileSystemName:" + fileSystemName);
            if(fileSystemName.endsWith(".zip"))
            {
              file = mpr.getFile(name);
             
              String folder = CmsPropertyHandler.getDigitalAssetUploadPath() + File.separator + "zip" + System.currentTimeMillis();
              List<File> unzippedFiles = FileHelper.unzipFile(file, folder);
              for(File unzippedFile : unzippedFiles)
              {
                handleFile(null, name, null, unzippedFile.getName(), unzippedFile);
              }
            }
            else
            {
              String fromEncoding = CmsPropertyHandler.getUploadFromEncoding();
              if(fromEncoding == null)
                fromEncoding = "iso-8859-1";
             
              String toEncoding = CmsPropertyHandler.getUploadToEncoding();
              if(toEncoding == null)
                toEncoding = "utf-8";
             
                    digitalAssetKey = new String(digitalAssetKey.getBytes(fromEncoding), toEncoding);
                   
                    file = mpr.getFile(name);
                 
                    return handleFile(digitalAssetKey, name, contentType, fileSystemName, file);
            }
               }
          }
View Full Code Here

      InputStream is = null;
    File file = null;
   
      try
      {
        MultiPartRequestWrapper mpr = ActionContext.getContext().getMultiPartRequest();
        logger.info("mpr:" + mpr);
        if(mpr != null)
        {
          Enumeration names = mpr.getFileNames();
             while (names.hasMoreElements())
             {
                String name       = (String)names.nextElement();
          String contentType    = mpr.getContentType(name);
          String fileSystemName = mpr.getFilesystemName(name);
         
          logger.info("name:" + name);
          logger.info("contentType:" + contentType);
          logger.info("fileSystemName:" + fileSystemName);
               
                file = mpr.getFile(name);
                if(file != null)
                {
            String fileName = fileSystemName;
            //fileName = new VisualFormatter().replaceNonAscii(fileName, '_');
                  fileName = new VisualFormatter().replaceNiceURINonAsciiWithSpecifiedChars(fileName, CmsPropertyHandler.getNiceURIDefaultReplacementCharacter());
View Full Code Here

TOP

Related Classes of webwork.multipart.MultiPartRequestWrapper

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.