Package org.ametys.cms.content
Class CopyContentMetadataComponent
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.cms.content.CopyContentMetadataComponent
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
- Direct Known Subclasses:
CopyContentMetadataComponent
,CopyContentMetadataComponent
public class CopyContentMetadataComponent extends AbstractLogEnabled implements Serviceable, Component
This component is used to copy a content (either totally or partially).
In this whole file a Map named copyMap is regularly used. This map provide the name of the metadata to copy as well as some optional parameters. It has the following form (JSON) :
{ "$param1": value, "metadataA": null, "metadataB": { "subMetadataB1": null, "subMetadataB2": { "$param1": value, "$param2": value, "subSubMetadataB21": {...} }, ... } }
Each metadata that should be copied must be present as a key in the map. Composite metadata can contains child metadata but as seen on the example the map must be well structured, it is not a flat map. Parameters in the map must always start with the reserved character '$', in order to be differentiated from metadata name.
There are two main entry points for this helper component:
- copyContent and editContent are methods that run a dedicated workflow function (createByCopy or editByCopy) that will later call the copyMetadataMap function (see below).
- copyMetadataMap is the method that is responsible for the recursive copy of the metadata (by following the copyMap structure). During this process, underlying content creation can be requested in which case the copyContent method will be called.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
CopyContentMetadataComponent.CopyAttachmentsHandler
A copy attachments content handler.
-
Field Summary
Fields Modifier and Type Field Description protected ContentHelper
_contentHelper
The content helperprotected ContentTypeExtensionPoint
_contentTypeExtensionPoint
Content type extension point.protected ContentTypesHelper
_contentTypesHelper
Helper for content typesprotected ServiceManager
_manager
Avalon service managerprotected OutgoingReferencesExtractor
_outgoingReferencesExtractor
The outgoing references extractorprotected AmetysObjectResolver
_resolver
Ametys object resolver available to subclasses.protected WorkflowProvider
_workflowProvider
Workflow provider.static String
ROLE
Avalon ROLE.
-
Constructor Summary
Constructors Constructor Description CopyContentMetadataComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>
_buildCopyMap(AbstractMetadataSetElement metadataSetElement, Map<String,Object> copyMap)
Recursive auxiliary function used to build the copy map.protected Map<String,Object>
_buildCopyMap(Content baseContent, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String targetContentType, Map<String,Object> baseCopyMap)
Build the copy map from a metadata set.protected Map<String,Object>
_buildCopyMap(Content baseContent, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, Map<String,Object> baseCopyMap)
Build the copy map from a metadata set.protected void
_copyFile(File baseFile, ModifiableFolder targetFolder)
File copy during the copy of a folder.protected void
_copyFolder(Folder baseFolder, ModifiableFolder targetFolder)
Folder copy during the copy of a rich text metadata.protected void
_copyMetadataMap(Content baseContent, CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metaPrefix, MetadataDefinition parentMetadataDefinition, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Copy the specified set of metadata from a base composite metadata to a target composite metadata by iterating over the copyMap.protected String[]
_copyReferencedContents(String[] baseContentIds, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Duplicate base contents by creating new contents.protected void
_copyRepeater(Content baseContent, CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataPath, MetadataDefinition metadataDefinition, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Copy a repeaterprotected void
_extractOutgoingReferences(ModifiableContent content)
Analyse the content to find outgoing references and store themprotected Map<String,Object>
_getInputsForContentReferencesEdition(Content baseContent, WorkflowAwareContent targetContent, Map<String,Object> editionValues, CopyReport copyReport)
Retrieve the inputs for the content references edition workflow function.protected Map<String,Object>
_getInputsForCopy(Content baseContent, String title, Map<String,Object> copyMap, String targetContentType, String parentContentId, String parentMetadataPath, CopyReport copyReport)
Retrieve the inputs for the copy workflow function.protected Map<String,Object>
_getInputsForEdition(Content baseContent, WorkflowAwareContent targetContent, Map<String,Object> copyMap, CopyReport copyReport)
Retrieve the inputs for the edition workflow function.protected MetadataDefinition
_getMetadataDefinition(Content content, MetadataDefinition metadataDefinition, String metadataName)
Retrieves aMetadataDefinition
through its parent definition or theContentType
of the current content if at the root level of the metadataset.protected String
_getWorklowName(Content content, Map<String,Object> inputs)
Retrieve the workflow name of a content.protected Map<String,Object>
_handleInnerCopyMap(Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs)
Handle the creation of the inner copy map given the current context.protected void
_reportMetadataException(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, MetadataDefinition metadataDefinition, CopyReport copyReport, Exception e)
Add a metadata exception to the report.protected WorkflowAwareContent
_retrieveTargetContent(String targetContentId)
Retrieve the target content from its id.protected void
_runContentReferencesEdition(Content baseContent, WorkflowProvider.AmetysObjectWorkflow targetContentWorkflow, int editActionId, boolean forceEdition, CopyReport copyReport)
Run the edition of the content references that has been stored during the copy of the metadata.protected void
_setBooleanMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type boolean from a base composite metadata to a target composite metadata.protected void
_setDateMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type date/datetime from a base composite metadata to a target composite metadata.protected void
_setDoubleMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type double from a base composite metadata to a target composite metadata.protected void
_setLongMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type long from a base composite metadata to a target composite metadata.protected void
_setStringMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type string from a base composite metadata to a target composite metadata.protected void
_updateRichTextMetadata(Content baseContent, ModifiableContent targetContent, CopyReport copyReport)
This method analyzes content rich texts and update their content to ensure consistency.Map<String,Object>
buildCopyMap(Content baseContent, String metadataSetName, String fallbackMetadataSetName, String metadataSetType)
Build the copy map from given content and metadata set.void
copyBasicMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDef, String metadataName)
Copy a 'basic' metadata.void
copyBinaryMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName)
Duplicate a metadata of typeMetadataType.BINARY
.void
copyCompositeMetadata(Content baseContent, CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataPath, MetadataDefinition metadataDefinition, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Copy composite metadataCopyReport
copyContent(String baseContentId, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int initActionId, int editActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.CopyReport
copyContent(String baseContentId, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String targetContentType, int initActionId, int editActionId)
Create a new content by copy of another.CopyReport
copyContent(String baseContentId, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int initActionId, int editActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.CopyReport
copyContent(Content baseContent, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int initActionId, int editRefActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.CopyReport
copyContent(Content baseContent, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String targetContentType, int initActionId, int editRefActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.CopyReport
copyContent(Content baseContent, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String parentContentId, String parentMetadataPath, int initActionId, int editActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.CopyReport
copyContent(Content baseContent, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String targetContentType, String parentContentId, String parentMetadataPath, int initActionId, int editRefActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.CopyReport
copyContent(Content baseContent, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.CopyReport
copyContent(Content baseContent, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int initActionId, int editRefActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.void
copyContentReferenceMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDefinition, String metadataPath, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Duplicate a metadata of typeMetadataType.CONTENT
.void
copyFileMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDef, String metadataName)
Copy a file metadatavoid
copyGeocodeMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName)
Duplicate a metadata of typeMetadataType.GEOCODE
.void
copyMetadata(Content baseContent, CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDefinition, String metaPrefix, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Copy the specified metadata from a base composite metadata to a target composite metadata.void
copyMetadataMap(Content baseContent, ModifiableContent targetContent, Map<String,Object> copyMap, CopyReport copyReport)
Copy the specified set of metadata from a base content to a target content by iterating over the copyMap.void
copyMultilingualStringMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName)
Duplicate a metadata of typeMetadataType.MULTILINGUAL_STRING
.void
copyReferenceMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDefinition, String metadataName)
Duplicate a metadata of typeMetadataType.REFERENCE
.protected void
copyRichTextMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDef, String metadataName, CopyReport copyReport)
Copy a rich-text metadatavoid
copySubContentMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, String metadataPath, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Duplicate a metadata of typeMetadataType.SUB_CONTENT
.void
copyUserMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName)
Duplicate a metadata of typeMetadataType.USER
.CopyReport
editContent(String baseContentId, String targetContentId, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType)
Edit a content by copying the value of the metadata of a source content into a target content.CopyReport
editContent(String baseContentId, String targetContentId, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int actionId, int editRefActionId)
Edit a content by copying the value of the metadata of a source content into a target content.int
getActionIdForCopy2()
Retrieve the action id to execute for the content copy.int
getDefaultActionIdForContentEdition()
Get the default workflow action id for editing content by copyint
getDefaultActionIdForEditingContentReferences()
Get the default workflow action id for editing content metadata of main contentint
getDefaultInitActionId()
Get the default workflow action id for initialization of main contentvoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_workflowProvider
protected WorkflowProvider _workflowProvider
Workflow provider.
-
_resolver
protected AmetysObjectResolver _resolver
Ametys object resolver available to subclasses.
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
Content type extension point.
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
Helper for content types
-
_outgoingReferencesExtractor
protected OutgoingReferencesExtractor _outgoingReferencesExtractor
The outgoing references extractor
-
_contentHelper
protected ContentHelper _contentHelper
The content helper
-
_manager
protected ServiceManager _manager
Avalon service manager
-
-
Constructor Detail
-
CopyContentMetadataComponent
public CopyContentMetadataComponent()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
copyContent
public CopyReport copyContent(String baseContentId, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int initActionId, int editActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one. The title of the new content will the one from the base content.- Parameters:
baseContentId
- The identifier of the base contentcopyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback of metadata set to copy. Use for legacy purpose if 'metadataSetName' does not exist.metadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.initActionId
- The workflow action id to use to create the new contenteditActionId
- The workflow action id to use to edit the newly created content- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
copyContent
public CopyReport copyContent(String baseContentId, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int initActionId, int editActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.- Parameters:
baseContentId
- The identifier of the base contenttitle
- Desired title for the new content.copyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback of metadata set to copy. Use for legacy purpose if 'metadataSetName' does not exist.metadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.initActionId
- The init workflow action id for main content onlyeditActionId
- The workflow action for editing main content only- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
copyContent
public CopyReport copyContent(String baseContentId, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String targetContentType, int initActionId, int editActionId)
Create a new content by copy of another. The type of created content can be different of the source content. The source and target contents must have a common content type ancestor.- Parameters:
baseContentId
- The id of content to copytitle
- The title of the new created contentcopyMap
- The map of metadata to copy. Can be null to copy the whole metadata set.metadataSetName
- The name of metadata set to copyfallbackMetadataSetName
- The fallback of metadata set to copy. Use for legacy purpose if 'metadataSetName' does not exist.metadataSetType
- The type of metadata set to copytargetContentType
- The type of content to create. If null the type(s) of created content will be those of base content.initActionId
- The init workflow action id for main content onlyeditActionId
- The workflow action for editing main content only- Returns:
- The copy report
-
copyContent
public CopyReport copyContent(Content baseContent, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.- Parameters:
baseContent
- The base content.copyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback of metadata set to copy. Use for legacy purpose if 'metadataSetName' does not exist.metadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
copyContent
public CopyReport copyContent(Content baseContent, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int initActionId, int editRefActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.- Parameters:
baseContent
- The base content.copyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback of metadata set to copy. Use for legacy purpose if 'metadataSetName' does not exist.metadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.initActionId
- The init workflow action id for main content onlyeditRefActionId
- The workflow action for editing references- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
copyContent
public CopyReport copyContent(Content baseContent, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int initActionId, int editRefActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.- Parameters:
baseContent
- The base content.title
- Desired title for the new content.copyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback of metadata set to copy. Use for legacy purpose if 'metadataSetName' does not exist.metadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.initActionId
- The init workflow action id for main content onlyeditRefActionId
- The workflow action for editing references- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
copyContent
public CopyReport copyContent(Content baseContent, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String targetContentType, int initActionId, int editRefActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.- Parameters:
baseContent
- The base content.title
- Desired title for the new content.copyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback of metadata set to copy. Use for legacy purpose if 'metadataSetName' does not exist.metadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.targetContentType
- The type of content to create. If null the type(s) of created content will be those of base content.initActionId
- The init workflow action id for main content onlyeditRefActionId
- The workflow action for editing references- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
copyContent
public CopyReport copyContent(Content baseContent, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String parentContentId, String parentMetadataPath, int initActionId, int editActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.- Parameters:
baseContent
- The base content.title
- Desired title for the new content.copyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback of metadata set to copy. Use for legacy purpose if 'metadataSetName' does not exist.metadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.parentContentId
- The target content ID.parentMetadataPath
- the parent metadata path, if a sub-content is being created.initActionId
- The init workflow action id for main content onlyeditActionId
- The workflow action for editing main content only- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
copyContent
public CopyReport copyContent(Content baseContent, String title, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String targetContentType, String parentContentId, String parentMetadataPath, int initActionId, int editRefActionId)
Copy a content by creating a new content and copying the value of the metadata of a source content into the new one.- Parameters:
baseContent
- The base content.title
- Desired title for the new content.copyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback of metadata set to copy. Use for legacy purpose if 'metadataSetName' does not exist.metadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.targetContentType
- The type of content to create. If null the type(s) of created content will be those of base content.parentContentId
- The target content ID.parentMetadataPath
- the parent metadata path, if a sub-content is being created.initActionId
- The init workflow action id for main content onlyeditRefActionId
- The workflow action for editing references- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
_getInputsForCopy
protected Map<String,Object> _getInputsForCopy(Content baseContent, String title, Map<String,Object> copyMap, String targetContentType, String parentContentId, String parentMetadataPath, CopyReport copyReport)
Retrieve the inputs for the copy workflow function.- Parameters:
baseContent
- The content to copytitle
- The title to setcopyMap
- The map with properties to copytargetContentType
- The type of content to create. If null the type(s) of created content will be those of base content.parentContentId
- The parent content ID, when copying a sub-content.parentMetadataPath
- The parent metadata path, when copying a sub-content.copyReport
- The report of the copy- Returns:
- The map of inputs.
-
_getWorklowName
protected String _getWorklowName(Content content, Map<String,Object> inputs) throws IllegalArgumentException
Retrieve the workflow name of a content.- Parameters:
content
- The content to considerinputs
- The inputs that will be provided to the workflow function- Returns:
- The name of the workflow.
- Throws:
IllegalArgumentException
- if the content is not workflow aware.
-
buildCopyMap
public Map<String,Object> buildCopyMap(Content baseContent, String metadataSetName, String fallbackMetadataSetName, String metadataSetType)
Build the copy map from given content and metadata set.- Parameters:
baseContent
- the content to copymetadataSetName
- Name of the metadata set.fallbackMetadataSetName
- The fallback metadata set name if 'metadataSetName' is not foundmetadataSetType
- Type of the metadata set.- Returns:
- A map with properties to copy.
-
_buildCopyMap
protected Map<String,Object> _buildCopyMap(Content baseContent, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, Map<String,Object> baseCopyMap)
Build the copy map from a metadata set.- Parameters:
baseContent
- the content to copymetadataSetName
- Name of the metadata set.fallbackMetadataSetName
- The fallback metadata set name if 'metadataSetName' is not foundmetadataSetType
- Type of the metadata set.baseCopyMap
- The copy map being constructed- Returns:
- The copy map.
-
_buildCopyMap
protected Map<String,Object> _buildCopyMap(Content baseContent, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, String targetContentType, Map<String,Object> baseCopyMap)
Build the copy map from a metadata set.- Parameters:
baseContent
- The content to be copiedmetadataSetName
- Name of the metadata set to be copied.fallbackMetadataSetName
- The fallback metadata set name if 'metadataSetName' is not foundmetadataSetType
- Type of the metadata set to be copied (view or edition).targetContentType
- The content type of content to create. Can be null.baseCopyMap
- The copy map being constructed- Returns:
- The copy map.
-
_buildCopyMap
protected Map<String,Object> _buildCopyMap(AbstractMetadataSetElement metadataSetElement, Map<String,Object> copyMap)
Recursive auxiliary function used to build the copy map.- Parameters:
metadataSetElement
- The current metadata set elementcopyMap
- The copy map being constructed or null- Returns:
- The copy map corresponding to this metadata set element.
-
editContent
public CopyReport editContent(String baseContentId, String targetContentId, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType)
Edit a content by copying the value of the metadata of a source content into a target content.- Parameters:
baseContentId
- The identifier of the base contenttargetContentId
- The identifier of the target contentcopyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback metadata set name if 'metadataSetName' is not foundmetadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
editContent
public CopyReport editContent(String baseContentId, String targetContentId, Map<String,Object> copyMap, String metadataSetName, String fallbackMetadataSetName, String metadataSetType, int actionId, int editRefActionId)
Edit a content by copying the value of the metadata of a source content into a target content.- Parameters:
baseContentId
- The identifier of the base contenttargetContentId
- The identifier of the target contentcopyMap
- The map of properties as described inCopyContentMetadataComponent
. Can be null in which case the map will be constructed from a metadataSet.metadataSetName
- The name of the metadata set to be used to construct to copyMap if not provided. This will also be the default name for possible inner copies (if not provided as a copyMap parameter).fallbackMetadataSetName
- The fallback metadata set name if 'metadataSetName' is not foundmetadataSetType
- The type of the metadata set to be used to construct to copyMap if not provided. This will also be the default type for possible inner copies.actionId
- the edit workflow action ideditRefActionId
- the workflow action id for editing references- Returns:
- The copy report containing valuable information about the copy and the possible encountered errors.
-
_retrieveTargetContent
protected WorkflowAwareContent _retrieveTargetContent(String targetContentId) throws IllegalArgumentException
Retrieve the target content from its id. Also ensure that it is a workflow aware content.- Parameters:
targetContentId
- The target content identifer.- Returns:
- the retrieved workflow aware content
- Throws:
IllegalArgumentException
- if the content is not workflow aware.
-
_getInputsForEdition
protected Map<String,Object> _getInputsForEdition(Content baseContent, WorkflowAwareContent targetContent, Map<String,Object> copyMap, CopyReport copyReport)
Retrieve the inputs for the edition workflow function.- Parameters:
baseContent
- The content to copytargetContent
- The target of the copycopyMap
- The properties to copycopyReport
- The report of the copy- Returns:
- The map of inputs.
-
copyMetadataMap
public void copyMetadataMap(Content baseContent, ModifiableContent targetContent, Map<String,Object> copyMap, CopyReport copyReport)
Copy the specified set of metadata from a base content to a target content by iterating over the copyMap.- Parameters:
baseContent
- The original contenttargetContent
- The copy contentcopyMap
- The properties to copycopyReport
- The copy report being populated during the copy.
-
_copyMetadataMap
protected void _copyMetadataMap(Content baseContent, CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metaPrefix, MetadataDefinition parentMetadataDefinition, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Copy the specified set of metadata from a base composite metadata to a target composite metadata by iterating over the copyMap.- Parameters:
baseContent
- The original contentbaseMetaHolder
- The metadata holder of the baseContenttargetMetaHolder
- The metadata holder of the target contentmetaPrefix
- The metadata prefix.parentMetadataDefinition
- The parent metadata definition. Can be nullcopyMap
- The properties to copyinnerCopyMapInputs
- The properties to copy for sub objectscopyReport
- The copy report being populated during the copy.
-
_getMetadataDefinition
protected MetadataDefinition _getMetadataDefinition(Content content, MetadataDefinition metadataDefinition, String metadataName)
Retrieves aMetadataDefinition
through its parent definition or theContentType
of the current content if at the root level of the metadataset.- Parameters:
content
- The contentmetadataDefinition
- The parent metadata definition. Can be null.metadataName
- The metadata name- Returns:
- The retrieved metadata defintion or null if not found
-
_reportMetadataException
protected void _reportMetadataException(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, MetadataDefinition metadataDefinition, CopyReport copyReport, Exception e)
Add a metadata exception to the report.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to copymetadataDefinition
- The associated definitioncopyReport
- The report of the copye
- The raised exception.
-
copyMetadata
public void copyMetadata(Content baseContent, CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDefinition, String metaPrefix, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Copy the specified metadata from a base composite metadata to a target composite metadata.- Parameters:
baseContent
- The original contentbaseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataDefinition
- The associated definitionmetaPrefix
- The metadata prefix.copyMap
- The properties to copyinnerCopyMapInputs
- The properties to copy for sub objectscopyReport
- The report of the copy
-
copyBasicMetadata
public void copyBasicMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDef, String metadataName)
Copy a 'basic' metadata. This is used to copy metadata of type :MetadataType.STRING
,MetadataType.DATE
,MetadataType.DATETIME
,MetadataType.DOUBLE
,MetadataType.LONG
,MetadataType.BOOLEAN
,MetadataType.USER
- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataDef
- The metadata definitionmetadataName
- The metadata name
-
_setStringMetadata
protected void _setStringMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type string from a base composite metadata to a target composite metadata.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to considerisMultiple
- Is the metadata multiple
-
_setDateMetadata
protected void _setDateMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type date/datetime from a base composite metadata to a target composite metadata.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to considerisMultiple
- Is the metadata multiple
-
_setDoubleMetadata
protected void _setDoubleMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type double from a base composite metadata to a target composite metadata.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to considerisMultiple
- Is the metadata multiple
-
_setLongMetadata
protected void _setLongMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type long from a base composite metadata to a target composite metadata.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to considerisMultiple
- Is the metadata multiple
-
_setBooleanMetadata
protected void _setBooleanMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, Boolean isMultiple)
Set a metadata of type boolean from a base composite metadata to a target composite metadata.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to considerisMultiple
- Is the metadata multiple
-
copyGeocodeMetadata
public void copyGeocodeMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName)
Duplicate a metadata of typeMetadataType.GEOCODE
.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to consider
-
copyMultilingualStringMetadata
public void copyMultilingualStringMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName)
Duplicate a metadata of typeMetadataType.MULTILINGUAL_STRING
.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to consider
-
copyUserMetadata
public void copyUserMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName)
Duplicate a metadata of typeMetadataType.USER
.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to consider
-
copyReferenceMetadata
public void copyReferenceMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDefinition, String metadataName)
Duplicate a metadata of typeMetadataType.REFERENCE
.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to considermetadataDefinition
- The associated definition
-
copyBinaryMetadata
public void copyBinaryMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName)
Duplicate a metadata of typeMetadataType.BINARY
.- Parameters:
baseMetaHolder
- The metadata holder to copytargetMetaHolder
- The metadata holder where to copymetadataName
- The metadata to consider
-
copyFileMetadata
public void copyFileMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDef, String metadataName)
Copy a file metadata- Parameters:
baseMetaHolder
- The copied composite metadatatargetMetaHolder
- The target composite metadatametadataDef
- The metadata definitionmetadataName
- The metadata name
-
copyRichTextMetadata
protected void copyRichTextMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDef, String metadataName, CopyReport copyReport)
Copy a rich-text metadata- Parameters:
baseMetaHolder
- The copied composite metadatatargetMetaHolder
- The target composite metadatametadataName
- The metadata namemetadataDef
- The metadata definitioncopyReport
- The copy report
-
_copyFolder
protected void _copyFolder(Folder baseFolder, ModifiableFolder targetFolder)
Folder copy during the copy of a rich text metadata.- Parameters:
baseFolder
- The folder to copytargetFolder
- The folder where to copy
-
_copyFile
protected void _copyFile(File baseFile, ModifiableFolder targetFolder)
File copy during the copy of a folder.- Parameters:
baseFile
- The file to copytargetFolder
- The folder where to copy
-
copyContentReferenceMetadata
public void copyContentReferenceMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, MetadataDefinition metadataDefinition, String metadataPath, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Duplicate a metadata of typeMetadataType.CONTENT
. If the copy map has a '$mode' parameter set to 'create', a new content will be created for each referenced content in the base metadata. The referenced contents are created if needed but content references are not set here. It should be done manually as done in_runContentReferencesEdition(org.ametys.cms.repository.Content, org.ametys.plugins.workflow.support.WorkflowProvider.AmetysObjectWorkflow, int, boolean, org.ametys.cms.content.CopyReport)
- Parameters:
baseMetaHolder
- The metadata holder of the content to copytargetMetaHolder
- The metadata holder of the target contentmetadataDefinition
- The definition of the metadatametadataPath
- The content metadata path.copyMap
- The properties to copyinnerCopyMapInputs
- The properties of sub objectscopyReport
- The report of the copy
-
_copyReferencedContents
protected String[] _copyReferencedContents(String[] baseContentIds, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Duplicate base contents by creating new contents. If a specific metadata set must be used, a '$metadataSetName' parameter must be specified. If the copyMap for each inner duplication is already present in the current copyMap, a '$loaded' parameter must be set to true, if not the copyMap will be constructed from the requested metadata set.- Parameters:
baseContentIds
- The ids of contents to copycopyMap
- The properties to copyinnerCopyMapInputs
- The properties of sub objectscopyReport
- The report of the copy- Returns:
- The array of identifiers of the new contents.
-
_handleInnerCopyMap
protected Map<String,Object> _handleInnerCopyMap(Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs)
Handle the creation of the inner copy map given the current context. The inner copy map will act as the copy map for underlying content copies.- Parameters:
copyMap
- The properties to copyinnerCopyMapInputs
- The properties of sub objects- Returns:
- The inner copy map
-
copySubContentMetadata
public void copySubContentMetadata(CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataName, String metadataPath, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Duplicate a metadata of typeMetadataType.SUB_CONTENT
. If the copy map has a '$mode' parameter set to 'create', a new content will be created for each referenced content in the base metadata.- Parameters:
baseMetaHolder
- The metadata holder of the content to copytargetMetaHolder
- The metadata holder of the target contentmetadataName
- The name of the metadatametadataPath
- The content metadata path.copyMap
- The properties to copyinnerCopyMapInputs
- The properties of sub objectscopyReport
- The report of the copy
-
copyCompositeMetadata
public void copyCompositeMetadata(Content baseContent, CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataPath, MetadataDefinition metadataDefinition, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Copy composite metadata- Parameters:
baseContent
- The copied contentbaseMetaHolder
- The original composite metadatatargetMetaHolder
- The target composite metadatametadataPath
- The metadata pathmetadataDefinition
- The metadata definitioncopyMap
- The map for copyinnerCopyMapInputs
- The properties of sub objectscopyReport
- The copy report
-
_copyRepeater
protected void _copyRepeater(Content baseContent, CompositeMetadata baseMetaHolder, ModifiableCompositeMetadata targetMetaHolder, String metadataPath, MetadataDefinition metadataDefinition, Map<String,Object> copyMap, Map<String,Object> innerCopyMapInputs, CopyReport copyReport)
Copy a repeater- Parameters:
baseContent
- The copied contentbaseMetaHolder
- The original composite metadatatargetMetaHolder
- The target composite metadatametadataPath
- The metadata pathmetadataDefinition
- The metadata definitioncopyMap
- The map for copyinnerCopyMapInputs
- The properties of sub objectscopyReport
- The copy report
-
_extractOutgoingReferences
protected void _extractOutgoingReferences(ModifiableContent content)
Analyse the content to find outgoing references and store them- Parameters:
content
- The content to analyze
-
_updateRichTextMetadata
protected void _updateRichTextMetadata(Content baseContent, ModifiableContent targetContent, CopyReport copyReport)
This method analyzes content rich texts and update their content to ensure consistency. (link to image, attachments...)- Parameters:
baseContent
- The copied contenttargetContent
- The target contentcopyReport
- The copy report
-
_runContentReferencesEdition
protected void _runContentReferencesEdition(Content baseContent, WorkflowProvider.AmetysObjectWorkflow targetContentWorkflow, int editActionId, boolean forceEdition, CopyReport copyReport) throws Exception
Run the edition of the content references that has been stored during the copy of the metadata. It is done via the EditContentFunction at the end of the process for technical purposes.- Parameters:
baseContent
- The base content to copytargetContentWorkflow
- the target content local workfloweditActionId
- The edit action id to edit referencesforceEdition
- true to force edition regardless user's rightscopyReport
- the copy report- Throws:
Exception
- If an error occured
-
_getInputsForContentReferencesEdition
protected Map<String,Object> _getInputsForContentReferencesEdition(Content baseContent, WorkflowAwareContent targetContent, Map<String,Object> editionValues, CopyReport copyReport)
Retrieve the inputs for the content references edition workflow function.- Parameters:
baseContent
- The content to copytargetContent
- The content where to copyeditionValues
- The values representing the content references to be edited (also contains special repeater size values)copyReport
- The report of the copy- Returns:
- The map of inputs.
-
getDefaultInitActionId
public int getDefaultInitActionId()
Get the default workflow action id for initialization of main content- Returns:
- the default action id
-
getDefaultActionIdForEditingContentReferences
public int getDefaultActionIdForEditingContentReferences()
Get the default workflow action id for editing content metadata of main content- Returns:
- the default action id
-
getDefaultActionIdForContentEdition
public int getDefaultActionIdForContentEdition()
Get the default workflow action id for editing content by copy- Returns:
- the default action id
-
getActionIdForCopy2
public int getActionIdForCopy2()
Retrieve the action id to execute for the content copy.- Returns:
- The action id
-
-