Class UploadManager

java.lang.Object
com.jalios.jcms.upload.UploadManager
All Implemented Interfaces:
JPropertiesListener

public class UploadManager extends Object implements JPropertiesListener
  • Field Details

  • Method Details

    • getInstance

      public static UploadManager getInstance()
    • propertiesChange

      public void propertiesChange(JProperties properties)
      Description copied from interface: JPropertiesListener
      Invoked after properties have been modified in JCMS and save on disk.

      You cannot alter the value received in parameters.

      Note that properties parameter may be null, a limited set of site properties, or all site properties.

      To check that a property has been modified, reload the "current" property instead using channel.getProperties or channel.getProperty.

      Specified by:
      propertiesChange in interface JPropertiesListener
      Parameters:
      properties - the properties which have been submitted to change
    • initMaxUploadSizePermissionsMap

      public void initMaxUploadSizePermissionsMap()
    • initExtensionIconsMap

      public void initExtensionIconsMap()
    • addUploadComponentScripts

      public void addUploadComponentScripts(JcmsJspContext ctxt)
      Add all required CSS and JS files needed for an upload component to the current JSP context
      Parameters:
      ctxt - the current JcmsJspContext, must not be nuill
    • getUploadComponent

      public String getUploadComponent(JcmsJspContext ctxt, String pfield)
      Returns a String HTML component for upload. Declare required css/js code.
      Parameters:
      ctxt - the JcmsJspContext
      pfield - the field name
      Returns:
      an HTML component as a String
    • getUploadComponent

      public String getUploadComponent(JcmsJspContext ctxt, String pfield, String pdrop, String pbrowse, boolean showFiles, boolean showLogs)
      Returns a String HTML component for upload. Declare required css/js code.
      Parameters:
      ctxt - the JcmsJspContext
      pfield - the field name
      pdrop - (optional) label of the drop box (set null to bypass)
      pbrowse - (optional) label of the browse button (set null to bypass)
      showFiles - boolean true to generate list of files
      showLogs - boolean true to generate logs
      Returns:
      an HTML component as a String
    • getUploadedFiles

      public List<DocUploadInfo> getUploadedFiles(JcmsContext ctxt, String field, FileUploadOptions options)
      Performs upload for file received for the specified field.
      Parameters:
      ctxt - JcmsContext
      field - the submited field
      options - upload options
      Returns:
      a List of uploaded files (DocUploadInfo), never return null
      Since:
      jcms-10.0.6 / JCMS-8317
    • getUploadedFile

      @Deprecated public Object getUploadedFile(JcmsContext ctxt, String field, boolean isFileDocument, boolean override)
      Deprecated.
      Performs upload for the given field to JCMS upload directory. Calling method must handle job around file like creating or updating associated FileDocument.
      Parameters:
      ctxt - JcmsContext
      field - the submited field
      isFileDocument - upload to a FileDocument path upload/docs/...
      override - If file already exists, override or rename with current timemillis
      Returns:
      Object a List of uploaded files (DocUploadInfo) or a DocUploadInfo
      Since:
      jcms-5.7.0
    • getUploadedFileList

      @Deprecated public List<DocUploadInfo> getUploadedFileList(JcmsContext ctxt, String field, boolean isFileDocument, boolean override)
      Performs upload for the given field to JCMS upload directory. Calling method must handle job around file like creating or updating associated FileDocument.
      Parameters:
      ctxt - JcmsContext
      field - the submited field
      isFileDocument - upload to a FileDocument upload/docs/...
      override - If file already exists, override or rename with current timemillis
      Returns:
      List a List of uploaded files
      Since:
      jcms-5.7.0
    • retrieveUploadedFile

      @Deprecated public DocUploadInfo retrieveUploadedFile(org.apache.commons.fileupload.FileItem item, boolean isFileDocument, boolean override)
      Deprecated.
      Performs upload of a given FileItem to JCMS upload directory. Calling method must handle job around file like creating or updating associated FileDocument.
      Parameters:
      item - the FileItem handling uploaded file information
      isFileDocument - upload to a Filedocument path upload/docs/...
      override - If file already exists, override or rename with current timemillis
      Returns:
      DocUploadInfo the uploaded DocUploadInfo
      Since:
      jcms-5.7.0
    • storeFileItem

      public void storeFileItem(JcmsJspContext ctxt, String token, String field, org.apache.commons.fileupload.FileItem fileItem)
      Store the given FileItem in session to be retrieved later by DocUpload mechanism.
      Parameters:
      ctxt - the JcmsJspContext
      token - String the token used to store the object in session. It identify the page request
      field - String the field name
      fileItem - the FileItem to store
      Since:
      jcms-7.0.0
    • removeFileItem

      public org.apache.commons.fileupload.FileItem removeFileItem(JcmsJspContext ctxt, String token, String field, String filename)
      Remove from session the first FileItem with the given name
      Parameters:
      ctxt - the JcmsJspContext
      token - String the token used to store the object in session. It identify the page request
      field - String the field name
      filename - String the name of the FileItem to remove
      Returns:
      FileItem the removed fileitem or null
      Since:
      jcms-7.0.0
    • removeAllFileItem

      public void removeAllFileItem(JcmsJspContext ctxt, String token, String field)
    • retrieveFileItem

      public Object retrieveFileItem(JcmsContext ctxt, String token, String field)
      Retrieve from session FileItem or List stored in session
      Parameters:
      ctxt - the JcmsJspContext
      token - String the token used to store the object in session. It identify the page request
      field - String the field name
      Returns:
      Object FileItem, List or null
      Since:
      jcms-7.0.0
    • getExtensionIconsMap

      public Map<String,String> getExtensionIconsMap()
      All file-document.icon.* from jcms.prop as json prop (key,value) :
      Returns:
      map value of extension icons: {key: audio/mpeg, images/jalios/icons/media/audio16.png}, ...
    • getMaxUploadSizePermissionsMap

      public Map<String,Long> getMaxUploadSizePermissionsMap()
      Returns:
      the map of max file size depending on mime type of files
      Since:
      jcms-11.0.0
    • getMaxUploadSizePermissionsByMimeType

      public Long getMaxUploadSizePermissionsByMimeType(String mimeType)
      Returns the maximum upload size allowed for a given MIME type.
      Parameters:
      mimeType - the MIME type of the file
      Returns:
      the maximum allowed file size for the specified MIME type