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
Fields Modifier and Type Field Description protected CopyContentComponent_copyContentComponentHelper for actually edit and copy contentsprivate JSONUtils_jsonUtils
-
Constructor Summary
Constructors Constructor Description CopyContentClientInteraction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>_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>> metadataErrors)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>> metadataErrors, boolean rootLevel)Helper method used to build the reportprotected List<String>_getCreatedContentIds(List<CopyReport> copyReports)Retrieve the identifiers of the created contents through the copy reportsprotected List<String>_getCreatedContentIds(CopyReport copyReport)Retrieve the identifiers of the created contents through the copy reportprotected List<String>_getEditedContentIds(List<CopyReport> copyReports)Retrieve the identifiers of the edited contents through the copy reportsMap<String,Object>createContentByCopy(String baseContentId, String newContentTitle, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String metadataSetTypeToCopy, 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 metadata of type "content".Map<String,Object>createContentByCopy(String baseContentId, String newContentTitle, String targetContentType, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String metadataSetTypeToCopy, 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 metadata of type "content".Map<String,Object>editContentByCopy(String baseContentId, List<String> targetContentIds, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String metadataSetTypeToCopy)Edits contents by copied of another one.voidservice(ServiceManager sManager)-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_copyContentComponent
protected CopyContentComponent _copyContentComponent
Helper for actually edit and copy contents
-
_jsonUtils
private JSONUtils _jsonUtils
-
-
Constructor Detail
-
CopyContentClientInteraction
public CopyContentClientInteraction()
-
-
Method Detail
-
service
public void service(ServiceManager sManager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
createContentByCopy
public Map<String,Object> createContentByCopy(String baseContentId, String newContentTitle, String jsonMap, String viewNameToCopy, String fallbackViewNameToCopy, String metadataSetTypeToCopy, 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 metadata of type "content".- Parameters:
baseContentId- The id of content to copynewContentTitle- The title of content to createjsonMap- The metadata 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 nullmetadataSetTypeToCopy- The metadata set type 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 metadataSetTypeToCopy, 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 metadata of type "content".- Parameters:
baseContentId- The id of content to copynewContentTitle- The title of content to createjsonMap- The metadata 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 nullmetadataSetTypeToCopy- The metadata set type 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 metadataSetTypeToCopy) throws Exception
Edits contents by copied of another one.- Parameters:
baseContentId- The id of content to copytargetContentIds- The ids of content to editjsonMap- The metadata 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.metadataSetTypeToCopy- The metadata set type 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>> metadataErrors)
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 copymetadataErrors- The list of metadata 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>> metadataErrors, 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 copymetadataErrors- The list of metadata errors reportedrootLevel- 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
-
-