Package org.ametys.cms.workflow.copy
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
public class CopyContentClientInteraction
extends AbstractLogEnabled
implements Component, Serviceable
Component for content copy
-
Field Summary
Modifier and TypeFieldDescriptionprotected CopyContentComponent
Helper for actually edit and copy contents -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription_buildReport
(List<CopyReport> copyReports) Build the copy reportprotected 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)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_getCreatedContentIds
(List<CopyReport> copyReports) Retrieve the identifiers of the created contents through the copy reports_getCreatedContentIds
(CopyReport copyReport) Retrieve the map of identifiers of base copied contents with the linked created contents through the copy report_getEditedContentIds
(List<CopyReport> copyReports) Retrieve the identifiers of the edited contents through the copy reportscreateContentByCopy
(String baseContentId, String newContentTitle, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String viewModeToCopy, int initActionId, int editActionId) 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".createContentByCopy
(String baseContentId, String newContentTitle, String targetContentType, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String viewModeToCopy, int initActionId, int editActionId) 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".editContentByCopy
(String baseContentId, List<String> targetContentIds, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String viewModeToCopy) Edits contents by copied of another one.void
service
(ServiceManager sManager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_copyContentComponent
Helper for actually edit and copy contents
-
-
Constructor Details
-
CopyContentClientInteraction
public CopyContentClientInteraction()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- 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 copynewContentTitle
- The title of content to createjsonMap
- The attributes to copy as a JSON stringviewNameToCopy
- The view name to copy. Can be nullfallbackViewNameToCopy
- The fallback view name to use if 'viewNameToCopy' does not exist. Can be nullviewModeToCopy
- The view mode to copy. Can be nullinitActionId
- The init workflow action id for copyeditActionId
- 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 copynewContentTitle
- The title of content to createjsonMap
- The attributes to copy as a JSON stringviewNameToCopy
- The view name to copy. Can be nullfallbackViewNameToCopy
- The fallback view name to use if 'viewNameToCopy' does not exist. Can be nullviewModeToCopy
- The view mode to copy. Can be nulltargetContentType
- 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 contenteditActionId
- 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 copytargetContentIds
- The ids of content to editjsonMap
- The attributes to copy as a JSON stringviewNameToCopy
- 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
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 copymainContent
- 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 creationfailedContentCopies
- The list that will receive th copy report informations if an error occurred during the copyattributesErrors
- 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 copymainContent
- 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 creationfailedContentCopies
- The list that will receive th copy report informations if an error occurred during the copyattributesErrors
- The list of attributes errors reportedrootLevel
- True indicates the root level of the report.
-
_getCreatedContentIds
Retrieve the map of identifiers of base copied contents with the linked created contents through the copy report- Parameters:
copyReport
- The report of the copy- Returns:
- map of created content ids with their based content ids
-
_getCreatedContentIds
Retrieve the identifiers of the created contents through the copy reports- Parameters:
copyReports
- list of copy reports- Returns:
- list of identifiers
-
_getEditedContentIds
Retrieve the identifiers of the edited contents through the copy reports- Parameters:
copyReports
- list of copy reports- Returns:
- list of identifiers
-