Class UploadManager


  • public class UploadManager
    extends java.lang.Object
    • Method Detail

      • getInstance

        public static UploadManager getInstance()
        Returns a UploadManager. Singleton method initalized by Channel (not synchronized)
        Returns:
        PluginManager the UploadManager
      • 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 java.lang.String getUploadComponent​(JcmsJspContext ctxt,
                                                   java.lang.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 java.lang.String getUploadComponent​(JcmsJspContext ctxt,
                                                   java.lang.String pfield,
                                                   java.lang.String pdrop,
                                                   java.lang.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 java.util.List<DocUploadInfo> getUploadedFiles​(JcmsContext ctxt,
                                                              java.lang.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 java.lang.Object getUploadedFile​(JcmsContext ctxt,
                                                java.lang.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 java.util.List<DocUploadInfo> getUploadedFileList​(JcmsContext ctxt,
                                                                 java.lang.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,
                                  java.lang.String token,
                                  java.lang.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,
                                                                     java.lang.String token,
                                                                     java.lang.String field,
                                                                     java.lang.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,
                                      java.lang.String token,
                                      java.lang.String field)
      • retrieveFileItem

        public java.lang.Object retrieveFileItem​(JcmsContext ctxt,
                                                 java.lang.String token,
                                                 java.lang.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