Class JcmsUploadFormHandler

    • Field Detail

      • FAKE_ID_ADDITION

        public static final java.lang.String FAKE_ID_ADDITION
        Adding to define a fake ID
        See Also:
        Constant Field Values
    • Constructor Detail

      • JcmsUploadFormHandler

        public JcmsUploadFormHandler()
    • Method Detail

      • setFormUniqueId

        public void setFormUniqueId​(java.lang.String formUniqueId)
      • getFormUniqueId

        public java.lang.String getFormUniqueId()
      • getFileDocumentClass

        @Deprecated
        protected java.lang.Class<? extends FileDocument> getFileDocumentClass​(java.lang.Class<? extends FileDocument> clazz,
                                                                               Member member,
                                                                               Workspace workspace)
        Deprecated.
        The getFileDocumentClass(Class, Member, Workspace, String) method is used directly by the setFileDocuments(String, String, List) method. It is no longer necessary to call this method. It is preferable to use the methods setFileDocuments(...) and setFileDocumentsML(...) that don't take the Class as an argument.
        Returns the FileDocument Class authorized for publication by the specified member and workspace.

        Here's how to find the file class

        • If the favorite class is null, try to auto detect the FileDocument Class that the member can publish
        • If the favorite class is specified, check if this class is authorized for publication by the member
        • Try to retrieve the first subtype of the favorite Class used in the Workspace and that the member can publish
        • Try to auto detect the FileDocument Class that the member can publish according to the contentType
        • Check if the member can publish with the default FileDocument Class defined by the property 'file-document.upload.class.default'
        • If there is no class compatible with this workspace, use FileDocument.class
        Parameters:
        clazz - Favorite class to use for creating the FileDocument
        member - Member who publishes FileDocuments
        workspace - Workspace where FileDocuments are created
        Returns:
        The FileDocument Class authorized for publication by the specified member and workspace
      • getFileDocumentClass

        protected java.lang.Class<? extends FileDocument> getFileDocumentClass​(java.lang.Class<? extends FileDocument> clazz,
                                                                               Member member,
                                                                               Workspace workspace,
                                                                               java.lang.String contentType)
        Returns the FileDocument Class authorized for publication by the specified member and workspace, and the most relevant regarding specified contentType.

        Here's how to find the file class

        • If the favorite class is null, try to auto detect the FileDocument Class that the member can publish according to the contentType
        • If the favorite class is specified, check if this class is authorized for publication by the member
        • Try to retrieve the first subtype of the favorite Class used in the Workspace and that the member can publish
        • Try to auto detect the FileDocument Class that the member can publish according to the contentType
        • Check if the member can publish with the default FileDocument Class defined by the property 'file-document.upload.class.default'
        • If there is no class compatible with this workspace, use FileDocument.class
        Parameters:
        clazz - Favorite class to use for creating the FileDocument
        member - Member who publishes FileDocuments
        workspace - Workspace where FileDocuments are created
        contentType - contentType of the document to create
        Returns:
        The FileDocument Class authorized for publication by the specified member and workspace
      • removeFileDocuments

        protected void removeFileDocuments​(java.lang.String fieldName)
        Removes file documents from the field name.
        Parameters:
        fieldName - field name
      • getFileDocuments

        protected java.util.List<? extends FileDocument> getFileDocuments​(java.lang.String fieldName)
        Returns the file documents from the field name.
        Parameters:
        fieldName - field name
        Returns:
        List of FileDocument
      • getFileDocuments

        protected java.util.List<? extends FileDocument> getFileDocuments​(java.lang.String fieldName,
                                                                          java.lang.String lang)
        Returns the file documents from the field name and the specified language.
        Parameters:
        fieldName - field name
        lang - language
        Returns:
        List of FileDocument
      • getFileDocumentsML

        protected java.util.Map<java.lang.String,​java.util.List<? extends FileDocument>> getFileDocumentsML​(java.lang.String fieldName)
        Returns the file documents from the field name for all the defined languages to the site.
        Parameters:
        fieldName - field name
        Returns:
        Map of List of FileDocument by language
      • setFileDocuments

        @Deprecated
        protected void setFileDocuments​(java.lang.String fieldName,
                                        java.lang.String userLang,
                                        java.lang.String[] documents,
                                        java.lang.Class<? extends FileDocument> clazz)
        Sets the file documents from the field name and the specified language.
        If the 'documents' array contains MultipartRequest.MULTIPART_UPLOAD as value then a new FileDocument is instantiated but NOT persisted.
        Parameters:
        fieldName - field name
        userLang - language
        documents - array of documents ids
        clazz - Class used to instantiate the FileDocuments. If null, try to auto detect the Class that the member can publish
      • setFileDocuments

        protected void setFileDocuments​(java.lang.String fieldName,
                                        java.lang.String userLang,
                                        java.lang.String[] documents,
                                        FileUploadOptions options)
        Sets the file documents for the specified field in the specified language.
        Parameters:
        fieldName - the field name
        userLang - an ISO-639 language code of the language
        documents - field values, which may contains either ids of existing FileDocument, or the string value MultipartRequest.MULTIPART_UPLOAD to request that a new FileDocument gets instantiated and assigned to this field but NOT persisted.
        Since:
        jcms-10.0.6 / JCMS-8317
      • setFileDocuments

        protected void setFileDocuments​(java.lang.String fieldName,
                                        java.lang.String userLang,
                                        java.lang.String[] documents)
        Sets the file documents from the field name and the specified language.
        If the 'documents' array contains MultipartRequest.MULTIPART_UPLOAD as value then a new FileDocument is instantiated but NOT persisted.
        The FileDocument Class is selected automatically from the file content-type.
        Parameters:
        fieldName - the field name
        userLang - language
        documents - field values, which may contains either ids of existing FileDocument, or the string value MultipartRequest.MULTIPART_UPLOAD to request that a new FileDocument gets instantiated and assigned to this field but NOT persisted.
      • setFileDocuments

        protected void setFileDocuments​(java.lang.String fieldName,
                                        java.lang.String[] documents,
                                        FileUploadOptions options)
        Sets the file documents from the field name and the default language.

        The If the 'documents' array contains MultipartRequest.MULTIPART_UPLOAD as value then a new FileDocument is instantiated but NOT persisted.

        Parameters:
        fieldName - the field name
        documents - field values, which may contains either ids of existing FileDocument, or the string value MultipartRequest.MULTIPART_UPLOAD to request that a new FileDocument gets instantiated and assigned to this field but NOT persisted.
        options - upload options
        Since:
        jcms-10.0.6 / JCMS-8317
      • setFileDocuments

        @Deprecated
        protected void setFileDocuments​(java.lang.String fieldName,
                                        java.lang.String[] documents,
                                        java.lang.Class<? extends FileDocument> clazz)
        Sets the file documents from the field name and the default language.
        If the 'documents' array contains MultipartRequest.MULTIPART_UPLOAD as value then a new FileDocument is instantiated but NOT persisted.
        Parameters:
        fieldName - the field name
        documents - array of documents ids
        clazz - Class used to instantiate the FileDocuments. If null, try to auto detect the Class that the member can publish
      • setFileDocuments

        protected void setFileDocuments​(java.lang.String fieldName,
                                        java.lang.String[] documents)
        Sets the file documents from the field name and the default language. If the 'documents' array contains MultipartRequest.MULTIPART_UPLOAD as value then a new FileDocument is instantiated but NOT persisted.
        The FileDocument Class is selected automatically from the file content-type.
        Parameters:
        fieldName - the field name
        documents - array of documents ids
      • setFileDocumentsML

        protected void setFileDocumentsML​(java.lang.String fieldName,
                                          java.lang.String[] documents,
                                          FileUploadOptions options)
        Sets the file documents from the field name for all the defined languages to the site.
        Parameters:
        fieldName - the field name
        documents - field values, which may contains either ids of existing FileDocument, or the string value MultipartRequest.MULTIPART_UPLOAD to request that a new FileDocument gets instantiated and assigned to this field but NOT persisted.
        options - upload options
        Since:
        jcms-10.0.6 / JCMS-8317
      • setFileDocumentsML

        @Deprecated
        protected void setFileDocumentsML​(java.lang.String fieldName,
                                          java.lang.String[] documents,
                                          java.lang.Class<? extends FileDocument> clazz)
        Sets the file documents from the field name for all the defined languages to the site.
        If the 'documents' array contains MultipartRequest.MULTIPART_UPLOAD as value then a new FileDocument is instantiated but NOT persisted.
        Parameters:
        fieldName - field name
        documents - array of documents ids
        clazz - Class used to instantiate the FileDocuments. If null, try to auto detect the Class that the member can publish
      • setFileDocumentsML

        protected void setFileDocumentsML​(java.lang.String fieldName,
                                          java.lang.String[] documents)
        Sets the file documents from the field name for all the defined languages to the site.
        If the 'documents' array contains MultipartRequest.MULTIPART_UPLOAD as value then a new FileDocument is instantiated but NOT persisted.
        The FileDocument Class is selected automatically from the file content-type.
        Parameters:
        fieldName - field name
        documents - array of documents ids
      • doPrepareFileDocuments

        protected void doPrepareFileDocuments​(FileDocument fd,
                                              java.lang.String fieldName,
                                              java.lang.String language)
        Prepares the new uploaded file document.
        Parameters:
        fd - file document
        fieldName - field name related to document file
        language - file document language
      • validateUploadedFileDocument

        protected boolean validateUploadedFileDocument​(java.util.List<? extends FileDocument> fileDocuments,
                                                       Member author)
        Validates the specified fileDocuments to upload.
        Parameters:
        fileDocuments - a list of FileDocuments to work with
        author - the author of the fileDocuments. If not defined try to retrieve the authors defined on the FileDocuments
        Returns:
        true if ControllerStatus is ok
      • validateUploadedFileDocument

        protected boolean validateUploadedFileDocument​(java.util.Map<java.lang.String,​java.util.List<FileDocument>> fileDocumentsML,
                                                       Member author)
        Validates the specified fileDocuments to upload.
        Parameters:
        fileDocumentsML - a map of list of FileDocuments to work with
        author - the author of the fileDocuments
        Returns:
        true if ControllerStatus is ok
      • createUploadedFileDocument

        protected boolean createUploadedFileDocument​(java.util.List<? extends FileDocument> fileDocuments,
                                                     Member author)
        Performs create on given array of data if it is a FileDocument that have just been uploaded.
        Parameters:
        fileDocuments - a list of FileDocuments to work with
        author - the author of the fileDocuments. If not defined try to retrieve the authors defined on the FileDocuments
        Returns:
        true if ControllerStatus is ok
      • createUploadedFileDocument

        protected boolean createUploadedFileDocument​(java.util.List<? extends FileDocument> fileDocuments,
                                                     Member author,
                                                     java.util.Map<?,​?> context)
        Performs create on given array of data if it is a FileDocument that have just been uploaded.
        Parameters:
        fileDocuments - a list of FileDocuments to work with
        author - the author of the fileDocuments. If not defined try to retrieve the authors defined on the FileDocuments
        context - a map which contains context parameters
        Returns:
        true if ControllerStatus is ok
      • createUploadedFileDocument

        protected boolean createUploadedFileDocument​(java.util.Map<java.lang.String,​java.util.List<FileDocument>> fileDocumentsML,
                                                     Member author)
        Performs create on given array of data if it is a FileDocument that have just been uploaded.
        Parameters:
        fileDocumentsML - a map of list of FileDocuments to work with
        author - the author of the fileDocuments
        Returns:
        true if ControllerStatus is ok
      • createUploadedFileDocument

        protected boolean createUploadedFileDocument​(java.util.Map<java.lang.String,​java.util.List<FileDocument>> fileDocumentsML,
                                                     Member author,
                                                     java.util.Map<?,​?> context)
        Performs create on given array of data if it is a FileDocument that have just been uploaded.
        Parameters:
        fileDocumentsML - a map of list of FileDocuments to work with
        author - the author of the fileDocuments
        context - a map which contains context parameters
        Returns:
        true if ControllerStatus is ok
      • getTemporaryDir

        public static java.io.File getTemporaryDir()
        Returns:
        the JCMS temporary directory.
      • getFileDocument

        public FileDocument getFileDocument​(java.lang.String id,
                                            Member member)
        Returns the file document from its ID.
        Parameters:
        id - file document id
        member -
        Returns:
        FileDocument
      • getFakeUniqueId

        public static java.lang.String getFakeUniqueId​(java.lang.Class<? extends Data> clazz)
      • isFakeUniqueId

        public static boolean isFakeUniqueId​(java.lang.String id)
      • getFormHiddenFields

        public java.lang.String getFormHiddenFields()
        Method used to add hidden fields in the form.
        Returns:
        String representing the input[hidden] to add in the form