Examples of UploadService


Examples of org.exoplatform.upload.UploadService

      String[] uploadIds = req.getParameterValues("uploadId");
     
      res.setHeader("Cache-Control", "no-cache");
     
      ExoContainer container = ExoContainerContext.getCurrentContainer();
      UploadService service = (UploadService)container.getComponentInstanceOfType(UploadService.class);
      if (action == null || action.length() < 1)
         return;

      UploadServiceAction uploadActionService = UploadServiceAction.valueOf(action.toUpperCase());
      if (uploadActionService == UploadServiceAction.PROGRESS)
      {
         Writer writer = res.getWriter();
         if (uploadIds == null)
            return;
         StringBuilder value = new StringBuilder();
         value.append("{\n  upload : {");
         for (int i = 0; i < uploadIds.length; i++)
         {
            UploadResource upResource = service.getUploadResource(uploadIds[i]);
            if (upResource == null)
               continue;
            if (upResource.getStatus() == UploadResource.FAILED_STATUS)
            {
               UploadLimit limit = service.getUploadLimits().get(uploadIds[i]);
               value.append("\n    \"").append(uploadIds[i]).append("\": {");
               value.append("\n      \"status\":").append('\"').append("failed").append("\",");
               value.append("\n      \"size\":").append('\"').append(limit.getLimit()).append("\",");
               value.append("\n      \"unit\":").append('\"').append(limit.getUnit()).append("\"");
               value.append("\n    }");
               continue;
            }
            double percent = 100;
            if (upResource.getStatus() == UploadResource.UPLOADING_STATUS)
            {
               percent = (upResource.getUploadedSize() * 100) / upResource.getEstimatedSize();
            }
            value.append("\n    \"").append(uploadIds[i]).append("\": {");
            value.append("\n      \"percent\":").append('\"').append((int)percent).append("\",");
            String fileName = EntityEncoder.FULL.encode(upResource.getFileName());
            value.append("\n      \"fileName\":").append('\"').append(encodeName(fileName))
               .append("\"");
            value.append("\n    }");
            if (i < uploadIds.length - 1)
               value.append(',');
         }
         value.append("\n  }\n}");
         writer.append(value);
      }
      else if (uploadActionService == UploadServiceAction.UPLOAD)
      {
         service.createUploadResource(req);
      }
      else if (uploadActionService == UploadServiceAction.DELETE)
      {
         service.removeUploadResource(uploadIds[0]);
      }
      else if (uploadActionService == UploadServiceAction.ABORT)
      {
         service.removeUploadResource(uploadIds[0]);
      }
   }
View Full Code Here

Examples of org.exoplatform.upload.UploadService

      uploadId = new String[this.limitFile] ;
      for(int i = 0; i < uploadId.length; i++)
      {
         uploadId[i] = new StringBuffer().append(Math.abs(hashCode())).append('-').append(i).toString();
      }
      UploadService service = getApplicationComponent(UploadService.class);
      for(int i = 0; i < uploadId.length; i++)
      {
         service.addUploadLimit(uploadId[i], null); // Use the limit set by the service. Warning, the service can allow no size limit (value to 0)
      }
      setComponentConfig(UIUploadInput.class, null);
   }
View Full Code Here

Examples of org.exoplatform.upload.UploadService

      uploadId = new String[this.limitFile] ;
      for(int i = 0; i < uploadId.length; i++)
      {
         uploadId[i] = new StringBuffer().append(Math.abs(hashCode())).append('-').append(i).toString();
      }
      UploadService service = getApplicationComponent(UploadService.class);
      for(int i = 0; i < uploadId.length; i++)
      {
         service.addUploadLimit(uploadId[i], Integer.valueOf(limitSize), unit);
      }
      setComponentConfig(UIUploadInput.class, null);
   }
View Full Code Here

Examples of org.exoplatform.upload.UploadService

      return limitFile;
   }
  
   public UploadResource[] getUploadResources() {
      List<UploadResource> holder = new ArrayList<UploadResource>();
      UploadService service = getApplicationComponent(UploadService.class);
      for(int i = 0; i < uploadId.length; i++)
      {
         UploadResource uploadResource = service.getUploadResource(uploadId[i]);
         if(uploadResource == null) continue;
         holder.add(uploadResource) ;
      }
      return holder.toArray(new UploadResource[holder.size()]);
   }
View Full Code Here

Examples of org.exoplatform.upload.UploadService

      }
      return holder.toArray(new UploadResource[holder.size()]);
   }
  
   public UploadResource getUploadResource(String uploadId) {
      UploadService service = getApplicationComponent(UploadService.class);
      return service.getUploadResource(uploadId);
   }
View Full Code Here

Examples of org.exoplatform.upload.UploadService

   }
  
   public InputStream[] getUploadDataAsStreams() throws FileNotFoundException
   {
      List<InputStream> holder = new ArrayList<InputStream>();
      UploadService service = getApplicationComponent(UploadService.class);
      for(int i = 0; i < uploadId.length; i++)
      {
         UploadResource uploadResource = service.getUploadResource(uploadId[i]);
         if(uploadResource == null) continue;
         File file = new File(uploadResource.getStoreLocation());
         holder.add(new FileInputStream(file));
      }
      return holder.toArray(new InputStream[holder.size()]);
View Full Code Here

Examples of org.exoplatform.upload.UploadService

      return holder.toArray(new InputStream[holder.size()]);
   }
  
   public InputStream getUploadDataAsStream(String uploadId) throws FileNotFoundException
   {
      UploadService service = getApplicationComponent(UploadService.class);
      UploadResource uploadResource = service.getUploadResource(uploadId);
      if(uploadResource == null) return null;
      else return new FileInputStream(new File(uploadResource.getStoreLocation()));
   }
View Full Code Here

Examples of org.exoplatform.upload.UploadService

   public UIFormUploadInput(String name, String bindingExpression)
   {
      super(name, bindingExpression, String.class);
      uploadId_ = Integer.toString(Math.abs(hashCode()));
      UploadService service = getApplicationComponent(UploadService.class);
      service.addUploadLimit(uploadId_, null); // Use the limit set by the service. Warning, the service can allow no size limit (value to 0)
      setComponentConfig(UIFormUploadInput.class, null);
   }
View Full Code Here

Examples of org.exoplatform.upload.UploadService

   public UIFormUploadInput(String name, String bindingExpression, int limit)
   {
      super(name, bindingExpression, String.class);
      uploadId_ = Integer.toString(Math.abs(hashCode()));
      UploadService service = getApplicationComponent(UploadService.class);
      service.addUploadLimit(uploadId_, Integer.valueOf(limit)); // Use the limit set by constructor.
      setComponentConfig(UIFormUploadInput.class, null);
   }
View Full Code Here

Examples of org.exoplatform.upload.UploadService

   public UIFormUploadInput(String name, String bindingExpression, boolean isAutoUpload)
   {
      super(name, bindingExpression, String.class);
      uploadId_ = Integer.toString(Math.abs(hashCode()));
      this.isAutoUpload = isAutoUpload;
      UploadService service = getApplicationComponent(UploadService.class);
      service.addUploadLimit(uploadId_, null);
      setComponentConfig(UIFormUploadInput.class, null);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.