Class JcmsUploadFormHandler

All Implemented Interfaces:
JcmsConstants, JaliosConstants
Direct Known Subclasses:
EditDataFormHandler, ImageUploadHandler, JcmsJsonActionUploadHandler, JPortalFrontFilesHandler, MemberStatusDetailsHandler, PubChooserActionHandler

public abstract class JcmsUploadFormHandler extends JcmsFormHandler
  • Field Details

  • Constructor Details

    • JcmsUploadFormHandler

      public JcmsUploadFormHandler()
  • Method Details

    • setFormUniqueId

      public void setFormUniqueId(String formUniqueId)
    • getFormUniqueId

      public String getFormUniqueId()
    • getFileDocumentClass

      @Deprecated protected Class<? extends FileDocument> getFileDocumentClass(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 Class<? extends FileDocument> getFileDocumentClass(Class<? extends FileDocument> clazz, Member member, Workspace workspace, 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(String fieldName)
      Removes file documents from the field name.
      Parameters:
      fieldName - field name
    • getFileDocuments

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

      protected List<? extends FileDocument> getFileDocuments(String fieldName, 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 Map<String,List<? extends FileDocument>> getFileDocumentsML(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(String fieldName, String userLang, String[] documents, 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(String fieldName, String userLang, 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(String fieldName, String userLang, 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(String fieldName, 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(String fieldName, String[] documents, 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(String fieldName, 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(String fieldName, 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(String fieldName, String[] documents, 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(String fieldName, 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, String fieldName, 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(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(Map<String,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(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(List<? extends FileDocument> fileDocuments, Member author, 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(Map<String,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(Map<String,List<FileDocument>> fileDocumentsML, Member author, 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 File getTemporaryDir()
      Returns:
      the JCMS temporary directory.
    • getFileDocument

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

      public static String getFakeUniqueId(Class<? extends Data> clazz)
    • isFakeUniqueId

      public static boolean isFakeUniqueId(String id)
    • getFormStepHiddenFields

      public String getFormStepHiddenFields()
      Overrides:
      getFormStepHiddenFields in class JcmsFormHandler
    • getFormHiddenFields

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