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 CopyContentMetadataComponent
_copyContentComponent
The ametys component that handle content copyprotected JSONUtils
_jsonUtils
JSON helper
-
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 metadataSetNameToCopy, String fallbackMetadataSetNameToCopy, 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 metadataSetNameToCopy, String fallbackMetadataSetNameToCopy, 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 metadataSetNameToCopy, String fallbackMetadataSetNameToCopy, String metadataSetTypeToCopy)
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 Detail
-
_copyContentComponent
protected CopyContentMetadataComponent _copyContentComponent
The ametys component that handle content copy
-
_jsonUtils
protected JSONUtils _jsonUtils
JSON helper
-
-
Constructor Detail
-
CopyContentClientInteraction
public CopyContentClientInteraction()
-
-
Method Detail
-
service
public void service(ServiceManager sManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
createContentByCopy
public Map<String,Object> createContentByCopy(String baseContentId, String newContentTitle, String jsonMap, String metadataSetNameToCopy, String fallbackMetadataSetNameToCopy, 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 stringmetadataSetNameToCopy
- The metadata set name to copy. Can be nullfallbackMetadataSetNameToCopy
- The fallback metadata set name to use if 'metadataSetNameToCopy' 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 metadataSetNameToCopy, String fallbackMetadataSetNameToCopy, 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 stringmetadataSetNameToCopy
- The metadata set name to copy. Can be nullfallbackMetadataSetNameToCopy
- The fallback metadata set name to use if 'metadataSetNameToCopy' 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 metadataSetNameToCopy, String fallbackMetadataSetNameToCopy, 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 stringmetadataSetNameToCopy
- The metadata set name to copy. Can be null.fallbackMetadataSetNameToCopy
- The fallback metadata set name if 'metadataSetName' 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
-
-