Class CopyContentClientInteraction

java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.cms.workflow.copy.CopyContentClientInteraction
All Implemented Interfaces:
Component, LogEnabled, Serviceable
Direct Known Subclasses:
CopyContentClientInteraction

Component for content copy
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager sManager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • createContentByCopy

      public Map<String,Object> createContentByCopy(String baseContentId, String newContentTitle, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String viewModeToCopy, int initActionId, int editActionId) throws Exception
      Creates a content by copy of another one.
      Also handle the possible inner duplication depending on the duplication mode for each attribute of type "content".
      Parameters:
      baseContentId - The id of content to copy
      newContentTitle - The title of content to create
      jsonMap - The attributes to copy as a JSON string
      viewNameToCopy - The view name to copy. Can be null
      fallbackViewNameToCopy - The fallback view name to use if 'viewNameToCopy' does not exist. Can be null
      viewModeToCopy - The view mode to copy. Can be null
      initActionId - The init workflow action id for copy
      editActionId - The workflow action for editing content
      Returns:
      the copy result
      Throws:
      Exception - if an error occurred during copy
    • createContentByCopy

      public Map<String,Object> createContentByCopy(String baseContentId, String newContentTitle, String targetContentType, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String viewModeToCopy, int initActionId, int editActionId) throws Exception
      Creates a content by copy of another one.
      Also handle the possible inner duplication depending on the duplication mode for each attribute of type "content".
      Parameters:
      baseContentId - The id of content to copy
      newContentTitle - The title of content to create
      jsonMap - The attributes to copy as a JSON string
      viewNameToCopy - The view name to copy. Can be null
      fallbackViewNameToCopy - The fallback view name to use if 'viewNameToCopy' does not exist. Can be null
      viewModeToCopy - The view mode to copy. Can be null
      targetContentType - The type of content to create. If null the type(s) of created content will be those of base content.
      initActionId - The workflow action id for copy to init the new content
      editActionId - The workflow action id for copy to edit the newly created content
      Returns:
      the copy result
      Throws:
      Exception - if an error occurred during copy
    • editContentByCopy

      public Map<String,Object> editContentByCopy(String baseContentId, List<String> targetContentIds, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String viewModeToCopy) throws Exception
      Edits contents by copied of another one.
      Parameters:
      baseContentId - The id of content to copy
      targetContentIds - The ids of content to edit
      jsonMap - The attributes to copy as a JSON string
      viewNameToCopy - The view name to copy. Can be null.
      fallbackViewNameToCopy - The fallback view name if 'viewName' is not found. Can be null.
      viewModeToCopy - The view mode to copy. Can be null
      Returns:
      the copy result
      Throws:
      Exception - if an error occurred during copy
    • _buildReport

      protected Map<String,Object> _buildReport(List<CopyReport> copyReports)
      Build the copy report
      Parameters:
      copyReports - List of copy report
      Returns:
      The builded report
    • _buildReport

      protected void _buildReport(CopyReport copyReport, Map<String,Object> mainContent, List<Map<String,Object>> createdContents, List<Map<String,Object>> editedContents, List<Map<String,Object>> failedContentCopies, List<Map<String,Object>> attributesErrors)
      Helper method used to build the report (rootLevel is false)
      Parameters:
      copyReport - The report of the copy
      mainContent - The map that will receive the copy report informations during a creation at rootLevel.
      createdContents - The list that will receive the copy report informations during a creation at another level.
      editedContents - The list that will receive the copy report informations during something else than a creation
      failedContentCopies - The list that will receive th copy report informations if an error occurred during the copy
      attributesErrors - The list of attributes errors reported
    • _buildReport

      protected void _buildReport(CopyReport copyReport, Map<String,Object> mainContent, List<Map<String,Object>> createdContents, List<Map<String,Object>> editedContents, List<Map<String,Object>> failedContentCopies, List<Map<String,Object>> attributesErrors, boolean rootLevel)
      Helper method used to build the report
      Parameters:
      copyReport - The report of the copy
      mainContent - The map that will receive the copy report informations during a creation at rootLevel.
      createdContents - The list that will receive the copy report informations during a creation at another level.
      editedContents - The list that will receive the copy report informations during something else than a creation
      failedContentCopies - The list that will receive th copy report informations if an error occurred during the copy
      attributesErrors - The list of attributes errors reported
      rootLevel - True indicates the root level of the report.
    • _getCreatedContentIds

      protected List<String> _getCreatedContentIds(CopyReport copyReport)
      Retrieve the identifiers of the created contents through the copy report
      Parameters:
      copyReport - The report of the copy
      Returns:
      list of identifiers
    • _getCreatedContentIds

      protected List<String> _getCreatedContentIds(List<CopyReport> copyReports)
      Retrieve the identifiers of the created contents through the copy reports
      Parameters:
      copyReports - list of copy reports
      Returns:
      list of identifiers
    • _getEditedContentIds

      protected List<String> _getEditedContentIds(List<CopyReport> copyReports)
      Retrieve the identifiers of the edited contents through the copy reports
      Parameters:
      copyReports - list of copy reports
      Returns:
      list of identifiers