Class DocUploadHandler

All Implemented Interfaces:
JcmsConstants, JaliosConstants
Direct Known Subclasses:
FileDocumentActionHandler, ImageEditorActionHandler

public class DocUploadHandler extends EditPublicationHandler
This form handler processes document upload. It use new UploadFilter mechanism and no longer decode MultiPart request.
Since:
jcms-5.7.0
Author:
Jean-Philippe Encausse
See Also:
  • Field Details

    • originalType

      protected Class originalType
    • docFormHandler

      protected EditFileDocumentHandler docFormHandler
    • showOptions

      protected boolean showOptions
    • isTypeAutoSelect

      protected boolean isTypeAutoSelect
    • typeSet

      protected Set<Class> typeSet
    • isModal

      protected boolean isModal
    • document

      protected FileDocument document
    • filename

      protected String[] filename
    • descriptionTFE

      protected TypeFieldEntry descriptionTFE
    • description

      protected String description
    • descriptionML

      protected HashMap<String,String> descriptionML
    • opUpload

      protected boolean opUpload
  • Constructor Details

    • DocUploadHandler

      public DocUploadHandler()
  • Method Details

    • isTypeAutoSelect

      public boolean isTypeAutoSelect()
    • getPublicationClass

      public Class<? extends Publication> getPublicationClass()
      Overrides:
      getPublicationClass in class EditPublicationHandler
    • internalInit

      public void internalInit()
    • getTypeSet

      public Set<Class> getTypeSet()
    • setDocumentFormHandler

      public void setDocumentFormHandler(EditFileDocumentHandler docFormHandler)
    • handleUploadError

      public String handleUploadError(Map<String,String> failedMap)
      Convenient method that returns a list (ul/li) of errors for each files.
      Parameters:
      failedMap - a map of errors returned by handleUpload()
      Returns:
      String error list
    • handleUpload

      public Map<String,String> handleUpload()
      Performs upload of all FileDocuments and create/update FileDocuments. Returns a Map of all FileDocuments with errors
      Returns:
      Map a map of errors
    • handleUpload

      public Map<String,String> handleUpload(DocUploadInfo dui)
      This method allow the use of this formHandler by a programatic call, not in a jsp:usebean tag. Support only one DocUploadInfo.
      Parameters:
      dui - a DocUploadInfo
      Returns:
      failedMap : not empty if some problem occured
    • performUpdate

      protected void performUpdate(DocUploadInfo info, Map<String,String> controllerFailedMap, List<LuceneDataSearchEngine.IndexingLatch> indexingLatchList)
      Performs creation of a FileDocument from a given DocUploadInfo. Store errors in the given controllerFailedMap.
      Parameters:
      info - a DocUploadInfo
      controllerFailedMap - a Map of errors.
      indexingLatchList - if specified, will be filled with IndexingLatch object for each document updated
    • withJsonUpdate

      public void withJsonUpdate(ThrowingConsumer<FileDocument> applyJsonUpdate)
    • performCreate

      protected void performCreate(DocUploadInfo info, Map<String,String> controllerFailedMap, List<LuceneDataSearchEngine.IndexingLatch> indexingLatchList)
      Performs creation of a FileDocument from a given DocUploadInfo. Store errors in the given controllerFailedMap.
      Parameters:
      info - a DocUploadInfo
      controllerFailedMap - a Map of errors.
      indexingLatchList - if specified, will be filled with IndexingLatch object for each document updated
    • getNextUploadStep

      public String getNextUploadStep()
      Returns the JavaScript code to use depending of the upload step. The script may refresh opener, make redrect, fill opener form or close the doc chooser.
      Returns:
      String the JavaScript code to execute
    • getStepCase

      protected com.jalios.jcms.upload.DocUploadHandler.UploadStep getStepCase()
      Returns the upload step depending of multiple paramter steps OpenerForm, OpenerRefresh, Redirect
      Returns:
      int the upload step
    • setModal

      public void setModal(boolean modal)
    • isInModal

      public boolean isInModal()
    • setId

      public void setId(String id)
      Description copied from class: EditPublicationHandler
      Set the value of id.
      Overrides:
      setId in class EditPublicationHandler
      Parameters:
      id - Value to assign to id.
    • getAvailableFileDocument

      public FileDocument getAvailableFileDocument()
    • getAvailableFileDocuments

      public FileDocument[] getAvailableFileDocuments()
    • isUpdate

      public boolean isUpdate()
    • isFieldMissing

      protected boolean isFieldMissing(String field)
      Description copied from class: JcmsFormHandler
      Check if the given parameter is present in the query parameters
      Overrides:
      isFieldMissing in class JcmsFormHandler
      Parameters:
      field - the field to be checked
      Returns:
      true if this field is present in the query parameters
    • setFilename

      public void setFilename(String[] v)
    • getAvailableFilename

      public String getAvailableFilename()
    • setDescription

      public void setDescription(String[] v)
    • getAvailableDescription

      public String getAvailableDescription()
    • getAvailableDescriptionML

      public HashMap<String,String> getAvailableDescriptionML()
    • getAvailableDescription

      public String getAvailableDescription(String lang)
    • getAllAvailableDescriptionML

      public HashMap<String,String> getAllAvailableDescriptionML()
    • getAvailableUseDefaultCategories

      public boolean getAvailableUseDefaultCategories()
      Overrides:
      getAvailableUseDefaultCategories in class EditPublicationHandler
    • setCids

      public void setCids(String[] v)
      Overrides:
      setCids in class EditPublicationHandler
    • getAvailableCategorySet

      public Set<Category> getAvailableCategorySet()
    • setRemoveFile

      public void setRemoveFile(boolean v)
    • getAvailableRemoveFile

      public boolean getAvailableRemoveFile()
    • setUnlock

      public void setUnlock(boolean v)
    • setPstatus

      public void setPstatus(int v)
      Overrides:
      setPstatus in class EditPublicationHandler
    • getAvailablePstatus

      public int getAvailablePstatus()
      Overrides:
      getAvailablePstatus in class EditPublicationHandler
    • setTracked

      public void setTracked(boolean v)
      Overrides:
      setTracked in class EditPublicationHandler
    • getAvailableTracked

      public boolean getAvailableTracked()
      Overrides:
      getAvailableTracked in class EditPublicationHandler
    • setUnzipUploadedFiles

      public void setUnzipUploadedFiles(boolean unzip)
      Set whether uploaded archives should be unziped and a new document created each time
      Parameters:
      unzip - true to unzip, false to leave document intact
    • getUnzipUploadedFiles

      public boolean getUnzipUploadedFiles()
      Check if archives should be unziped and a new document created each time
      Returns:
      true to unzip, false to leave document intact
    • setType

      public void setType(String type)
    • resolveType

      protected void resolveType(DocUploadInfo info)
    • getSelectedDocumentClass

      public Class<? extends FileDocument> getSelectedDocumentClass(DocUploadInfo info)
    • getAvailableType

      public Class<? extends FileDocument> getAvailableType()
    • setOriginalType

      public void setOriginalType(String type)
    • getAvailableOriginalType

      public Class getAvailableOriginalType()
    • setOpenerForm

      public void setOpenerForm(String v)
    • getAvailableOpenerForm

      public String getAvailableOpenerForm()
    • setRefresh

      public void setRefresh(String v)
    • getAvailableOpenerRefresh

      public String getAvailableOpenerRefresh()
    • setNbElt

      public void setNbElt(int v)
    • getAvailableNbElt

      public int getAvailableNbElt()
    • setStartElt

      public void setStartElt(int v)
    • getAvailableStartElt

      public int getAvailableStartElt()
    • setJsFunc

      public void setJsFunc(String v)
    • getAvailableJsFunc

      public String getAvailableJsFunc()
    • isWorkflowTabHidden

      public boolean isWorkflowTabHidden()
      Overrides:
      isWorkflowTabHidden in class EditPublicationHandler
    • setInitPstatus

      public void setInitPstatus(boolean initPstatus)
    • isInitPstatus

      public boolean isInitPstatus()
    • setOpUpload

      public void setOpUpload(String v)
    • isUploading

      public boolean isUploading()
    • setMajorUpdate

      public void setMajorUpdate(boolean v)
    • getAvailableMajorUpdate

      public boolean getAvailableMajorUpdate()
      Overrides:
      getAvailableMajorUpdate in class EditPublicationHandler
    • isUploadEnabled

      public boolean isUploadEnabled()
    • setUploadEnabled

      public void setUploadEnabled(boolean uploadEnabled)
    • setShowOptions

      public void setShowOptions(String v)
    • getAvailableShowOptions

      public boolean getAvailableShowOptions()
    • showModalEditionChange

      public boolean showModalEditionChange()
      Description copied from class: EditPublicationHandler
      Check if the "Advanced edition" or "Simple edition" button should be displayed in modal footer.

      The default implementation of this method is to check for request attribute EditPublicationHandler.SHOW_MODAL_EDITION_CHANGE. If the attribute is not set, the button is displayed only when editing an existing publication (i.e. EditPublicationHandler.getPublication() is not null), and hidden when creating a new one.

      You can set the attribute to a custom value or provide a custom FormHandler to override this behavior.

      See jcore/modalPubFormHandler.jspf for use of this method.

      Overrides:
      showModalEditionChange in class EditPublicationHandler
      Returns:
      true to display the button, false to hide it
    • getFieldStatus

      public FieldStatus getFieldStatus(String fieldName)
      Returns the FieldStatus for the given field.
      Overrides:
      getFieldStatus in class EditPublicationHandler
      Parameters:
      fieldName - the name of the field
      Returns:
      the FieldStatus for the given field (never null).
      Since:
      jcms-6.0.1
    • checkWorkspaceChange

      public void checkWorkspaceChange()
      check if the workspace has been explictly changed and reconfigure the handler to be consistent
    • checkMemberClassWorkspaceCompliance

      public void checkMemberClassWorkspaceCompliance()
    • processIndexingLatch

      public static void processIndexingLatch(List<LuceneDataSearchEngine.IndexingLatch> indexingLatchList, Class<?> docClass)
      Process the IndexingLatch list elements
      Parameters:
      indexingLatchList - the List of LuceneDataSearchEngine.IndexingLatch
      docClass - the class of the document (to manage hibernate transaction)
    • doUploadDocument

      public static FileDocument doUploadDocument(DocUploadInfo info, FileDocument document, Consumer<FileDocument> updateBlock, ThrowingConsumer<FileDocument> applyJsonUpdate, boolean majorUpdate, BiConsumer<FileDocument,FileDocument> workflowBlock, boolean removeFile, boolean unlock, Member mbr, String userLang, HashMap<String,Object> context, Map<String,String> controllerFailedMap, List<LuceneDataSearchEngine.IndexingLatch> indexingLatchList)