Class EditDataHandler

All Implemented Interfaces:
JcmsConstants, JaliosConstants
Direct Known Subclasses:
AbstractEditWorkspaceHandler, AttachPublicationHandler, AttachWorkspaceHandler, EditAccessTokenHandler, EditAclHandler, EditCatHandler, EditDataIdHandler, EditExtraDataHandler, EditGroupHandler, EditMemberHandler, EditNotificationCriteriaHandler, EditNotificationHandler, EditPublicationHandler, EditPublicLinkHandler, EditThemeHandler, EditWorkflowInstanceHandler, EditWSTypeEntryHandler, ImportCategoriesHandler, ImportThemeModalHandler, MemberCsvImportHandler

public abstract class EditDataHandler extends JcmsFormHandler
This class is the super class of all FormHandler which manage stored data.
See Also:
  • Field Details

    • opCreate

      protected boolean opCreate
    • resultOpCreate

      protected boolean resultOpCreate
    • opUpdate

      protected boolean opUpdate
    • resultOpUpdate

      protected boolean resultOpUpdate
    • opDelete

      protected boolean opDelete
    • resultOpDelete

      protected boolean resultOpDelete
    • opCancel

      protected boolean opCancel
    • opRefresh

      protected boolean opRefresh
    • id

      protected String id
    • isDeleteForced

      protected boolean isDeleteForced
  • Constructor Details

    • EditDataHandler

      public EditDataHandler()
  • Method Details

    • sendRedirect

      protected void sendRedirect() throws IOException
      Throws:
      IOException
    • afterValidation

      protected boolean afterValidation(boolean result) throws IOException
      Overrides:
      afterValidation in class JcmsFormHandler
      Throws:
      IOException
    • processAction

      public boolean processAction() throws IOException
      Description copied from class: JcmsFormHandler
      Method to be implemented to check/validate action to be performed and process them.

      Default implementation is to return false. No need to call super method.

      This method may NOT be invoked at all if security validation are not met.

      You must ensure your handler and JSP can work properly without any code invoked in this method.

      Overrides:
      processAction in class JcmsFormHandler
      Returns:
      false if no redirection is needed, true otherwise
      Throws:
      IOException - IO Exception
    • getControllerContext

      protected HashMap<String,Object> getControllerContext()
      Description copied from class: JcmsFormHandler
      Build a controller context. I.E. add request, response and loggedMember.
      Overrides:
      getControllerContext in class JcmsFormHandler
      Returns:
      the HashMap which contains the context
    • setFields

      public void setFields(Data data)
      Set the common (Data) fields. This method is also a hook for sub-classed to fill some field (or do anything else) before a create or an update.
      Parameters:
      data - the publication to set the fields
      Since:
      jcms-5.7.1
    • getDataClass

      public abstract Class<? extends Data> getDataClass()
    • getAvailableField

      public Object getAvailableField(String field)
      Get value of the given field calling getAvailable{field}(). Called by widgets and meta templates See also getEnumValues(String) and getEnumLabels(String, String)
      Parameters:
      field - the field name
      Returns:
      Object return by getAvailable
      Since:
      jcms-9.0.0
    • getTabGroupMaxCount

      public int getTabGroupMaxCount(String tabGroupName)
      Returns the max value of the given tab group from the fields defining this tab group.
      Parameters:
      tabGroupName - Tab group defined in the type
      Returns:
      tab group count
    • getEnumValues

      public Object getEnumValues(String field)
      Get enum values of the given field calling clazz.get{field}Values(). Called by widgets and meta templates
      Parameters:
      field - the field name
      Returns:
      Object return by getAvailable
      Since:
      jcms-9.0.0
    • getEnumLabels

      public Object getEnumLabels(String field, String userLang)
      Get enum values of the given field calling clazz.get{field}Labels(). Called by widgets and meta templates
      Parameters:
      field - the field name
      userLang - the userLang
      Returns:
      Object return by getAvailable
      Since:
      jcms-9.0.0
    • validateCancel

      public boolean validateCancel()
    • performCancel

      public boolean performCancel() throws IOException
      Throws:
      IOException
    • validateRefresh

      public boolean validateRefresh()
    • performRefresh

      public boolean performRefresh() throws IOException
      Throws:
      IOException
    • setOpCreate

      public void setOpCreate(String v)
    • setOpUpdate

      public void setOpUpdate(String v)
    • setOpDelete

      public void setOpDelete(String v)
    • setOpCancel

      public void setOpCancel(String v)
    • setOpRefresh

      public void setOpRefresh(String v)
    • getId

      public String getId()
    • setId

      public void setId(String id)
    • setForceDelete

      public void setForceDelete(String v)
    • setExtraKeys

      public void setExtraKeys(String[] extraKeys)
      Convenient methods to update ExtraDataMap from bean
      Parameters:
      extraKeys - the extraKey
      Since:
      jcms-5.7.1
    • setExtraValues

      public void setExtraValues(String[] extraValues)
      Convenient methods to update ExtraDataMap from bean
      Parameters:
      extraValues - the extraValues
      Since:
      jcms-5.7.1
    • getAvailableExtraDataMap

      public Map<String,String> getAvailableExtraDataMap()
      Returns a Map of available extra data. A mix between:
      1. Default extra data
      2. Previous extra data
      3. Submited extra data
      Returns:
      Map of extra data
    • isExtraDataHidden

      public boolean isExtraDataHidden(String prop)
      Determines whether the specified extra data field must be rendered as hidden in the current form context.

      The hiding mechanism is context-aware and is enabled only if the current request defines the attribute "extraData.ui-prefix". This prefix identifies the active UI context (JSP, handler, or form) and is used to resolve the corresponding configuration property.

      The extra data is considered hidden when the following property evaluates to true:

       <ui-prefix>.<extraDataProperty>.hidden
       

      Example:

      • The member front-office edit form sets the request attribute "extraData.ui-prefix" to "fo-member-edit".
      • A plugin defining the extra data "extradb.Member.jcmsplugin.sampleplugin.matricule" can hide it in this context by declaring:
         fo-member-edit.extradb.Member.jcmsplugin.sampleplugin.matricule.hidden: true
               
      Parameters:
      prop - the extra data property name (e.g. "extradb.Member.jcmsplugin.sampleplugin.matricule")
      Returns:
      true if the extra data must be included in the form as a hidden field, false if it should be displayed to the user
      Since:
      11.0.0 (JCMS-11693)
    • setExtraDBKeys

      public void setExtraDBKeys(String[] extraDBKeys)
      Convenient methods to update ExtraDBDataMap from bean
      Parameters:
      extraDBKeys - the extraDBKey
      Since:
      jcms-6.0
    • setExtraDBValues

      public void setExtraDBValues(String[] extraDBValues)
      Convenient methods to update ExtraDBDataMap from bean
      Parameters:
      extraDBValues - the extraDBValues
      Since:
      jcms-6.0
    • getAvailableExtraDBDataMap

      public Map<String,String> getAvailableExtraDBDataMap()
      Returns a Map of available extra db data. A mix between:
      1. Default extra db data
      2. Previous extra db data
      3. Submited extra db data
      Returns:
      Map of extra db data
      Since:
      jcms-6.0
    • processDataIds

      protected <T extends Data> List<T> processDataIds(String fieldName, String[] ids, Class<T> clazz)
      Computes link array to retrieve Data of the given Class. Trim end of the returned List. If link array contains value MultipartRequest.MULTIPART_UPLOAD then instanciate a new FileDocument but do NOT perform create. Handler.validate() should perform Create or Update. Underlaying files are never overrided.
      Type Parameters:
      T - The data type
      Parameters:
      fieldName - the field name
      ids - arrays of ids
      clazz - the class of links
      Returns:
      List a list of Data
      Since:
      jcms-5.7.0
    • processDataIds

      protected <T extends Data> List<T> processDataIds(String fieldName, String[] ids, Class<T> clazz, boolean trim)
      Computes link array to retrieve Data of the given Class. optionaly, trims the end of the returned List. If link array contains value MultipartRequest.MULTIPART_UPLOAD then instanciate a new FileDocument but do NOT perform create. Handler.validate() should perform Create or Update. Underlaying files are never overrided.
      Type Parameters:
      T - The data type
      Parameters:
      fieldName - the field name
      ids - arrays of ids
      clazz - the class of links
      trim - if true, trim the end of the returned list.
      Returns:
      List a list of Data
      Since:
      jcms-6.0.0
    • processDataId

      protected Data processDataId(String fieldName, String dataId, Class<? extends Data> clazz)
      Computes given dataid, trim and retrieve associated data. If link contains value MultipartRequest.MULTIPART_UPLOAD then instanciate a new FileDocument but do NOT perform create. Handler.validate() should perform Create or Update. Underlaying files are never overrided. Check the data match the given class.
      Parameters:
      fieldName - The field name
      dataId - the id of the data
      clazz - the class of the data
      Returns:
      Data the updated data
      Since:
      jcms-5.7.0
    • validateUploadedFileDocument

      protected boolean validateUploadedFileDocument(Data data, Member author, Workspace ws)
      Performs create on given data if it is a FileDocument that have just been uploaded. This method should be called by EditPublicationHandler#validateBeforeOp()
      Parameters:
      data - the data to work with
      author - the author of the data
      ws - the workspace of the data
      Returns:
      true if ControllerStatus is ok
      Since:
      jcms-5.7.0
      See Also:
    • validateUploadedFileDocument

      protected boolean validateUploadedFileDocument(Data data, Map dataML, Member author, Workspace ws)
      Performs create on given data if it is a FileDocument that have just been uploaded. This method should be called by EditPublicationHandler#validateBeforeOp()
      Parameters:
      data - the data to work with
      dataML - the other languages
      author - the author of the data
      ws - the workspace of the data
      Returns:
      true if ControllerStatus is ok
      Since:
      jcms-6.1.3
      See Also:
    • validateUploadedFileDocument

      protected boolean validateUploadedFileDocument(Data[] datas, Member author, Workspace ws)
      Performs validate on given array of data if it is a FileDocument that have just been uploaded. This method should be called by EditPublicationHandler#validateBeforeOp()
      Parameters:
      datas - an array of data to work with
      author - the author of the data
      ws - the workspace of the data
      Returns:
      true if ControllerStatus is ok
      Since:
      jcms-5.7.0
      See Also:
    • validateUploadedFileDocument

      protected boolean validateUploadedFileDocument(Data[] datas, Map dataML, Member author, Workspace ws)
      Performs create on given data if it is a FileDocument that have just been uploaded. This method should be called by EditPublicationHandler#validateBeforeOp()
      Parameters:
      datas - an array of data to work with
      dataML - the other languages
      author - the author of the data
      ws - the workspace of the data
      Returns:
      true if ControllerStatus is ok
      Since:
      jcms-6.1.3
      See Also:
    • createUploadedFileDocument

      protected boolean createUploadedFileDocument(Data data, Member author, Workspace ws)
      Performs create on given data if it is a FileDocument that have just been uploaded. This method should be called by EditPublicationHandler#validateBeforeOp()
      Parameters:
      data - the data to work with
      author - the author of the data
      ws - the workspace of the data
      Returns:
      true if ControllerStatus is ok
      Since:
      jcms-5.7.0
      See Also:
    • createUploadedFileDocument

      protected boolean createUploadedFileDocument(Data data, Map dataML, Member author, Workspace ws)
      Performs create on given array of data if it is a FileDocument that have just been uploaded. This method should be called by EditPublicationHandler#validateBeforeOp()
      Parameters:
      data - the data to work with (main language
      dataML - the other languages
      author - the author of the data
      ws - the workspace of the data
      Returns:
      true if ControllerStatus is ok
      Since:
      jcms-6.1.3
      See Also:
    • createUploadedFileDocument

      protected boolean createUploadedFileDocument(Data[] datas, Member author, Workspace ws)
      Performs create on given array of data if it is a FileDocument that have just been uploaded. This method should be called by EditPublicationHandler#validateBeforeOp()
      Parameters:
      datas - an array of data to work with
      author - the author of the data
      ws - the workspace of the data
      Returns:
      true if ControllerStatus is ok
      Since:
      jcms-6.1.2
      See Also:
    • createUploadedFileDocument

      protected boolean createUploadedFileDocument(Data[] datas, Map dataML, Member author, Workspace ws)
      Performs create on given array of data if it is a FileDocument that have just been uploaded. This method should be called by EditPublicationHandler#validateBeforeOp()
      Parameters:
      datas - an array of data to work with
      dataML - the other languages
      author - the author of the data
      ws - the workspace of the data
      Returns:
      true if ControllerStatus is ok
      Since:
      jcms-6.1.3
      See Also:
    • processMLData

      public Data processMLData(String fieldName, Class clazz, String[] values, Map mlMap)
      Process the given ML values (data ids)
      Parameters:
      fieldName - the field name
      clazz - the class
      values - the ids
      mlMap - the mlMap
      Returns:
      the data in the main language
      Since:
      jcms-5.7.0
    • processMLDataArray

      public <T extends Data> Data[] processMLDataArray(String fieldName, Class<T> clazz, String[] values, Map mlMap)
      Process the given ML values (data ids)
      Type Parameters:
      T - The data type
      Parameters:
      fieldName - the field name
      clazz - the class
      values - the ids
      mlMap - the mlMap
      Returns:
      the data array in the main language
      Since:
      jcms-5.7.0
    • getAvailableData

      public Data getAvailableData(Data data, Data dataField, Data field, Map mlMap, String lang)
      Generic method to get available ML field for a given data in a given language.
      Parameters:
      data - the object (eg a Publication)
      dataField - the current value of the field (may be null)
      field - the proposed value for this field
      mlMap - the ML map
      lang - the langugage value
      Returns:
      the value for the field of the object in the given language
      Since:
      jcms-5.7.0
    • getAvailableDataArray

      public Data[] getAvailableDataArray(Data data, Data[] dataField, Data[] field, Map mlMap, String lang)
      Generic method to get available ML field for a given array of data in a given language.
      Parameters:
      data - the object (eg a Publication)
      dataField - the current value of the field (may be null)
      field - the proposed value for this field
      mlMap - the ML map
      lang - the langugage value
      Returns:
      the value for the field of the object in the given language
      Since:
      jcms-5.7.0
    • isFirstAccess

      public boolean isFirstAccess()
      Returns true if this is the first access to this form (no previous submission).
      Returns:
      true if this is the first access to this form (no previous submission).
      Since:
      jcms-5.7.0
    • handleRestResponse

      protected void handleRestResponse() throws IOException
      Throws:
      IOException
    • restValidation

      protected boolean restValidation(boolean result) throws IOException
      Throws:
      IOException
    • getModalRedirect

      public String getModalRedirect()
      Description copied from class: JcmsFormHandler
      Get the redirect value to be used in the modals with modalRedirect.jspf and the request attribute 'modal.redirect'.
      Overrides:
      getModalRedirect in class JcmsFormHandler
      Returns:
      redirect value
    • getDeleteRedirect

      public static String getDeleteRedirect(Data data, Locale userLocale)
      Get the redirect value to be used by default in the ctx menus for delete action.

      Returns publication workspace home url if data is a Publication, else returns null.

      Parameters:
      data - the data to be deleted
      userLocale - the user context
      Returns:
      redirect value
      Since:
      jcms-10.0.6