Class BaseSynchroComponent
java.lang.Object
org.ametys.plugins.contentio.synchronize.BaseSynchroComponent
- All Implemented Interfaces:
Component
,Serviceable
Class for basics operations on SCC.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CurrentUserProvider
The current user providerprotected ObservationManager
The observation managerprotected AmetysObjectResolver
The ametys object resolverprotected ContentWorkflowHelper
The content workflow helperstatic final String
Avalon Role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
_setBinaryMetadata
(ModifiableCompositeMetadata metadataHolder, String metadataName, Object valueToSet, boolean synchronize, String title, Logger logger) Set the binary metadataapplyChanges
(ModifiableDefaultContent content, Integer actionId, String event, boolean ignoreRights, Logger logger) Does workflow actionapplyChanges
(ModifiableDefaultContent content, Integer actionId, String event, Logger logger) Does workflow actioncreateContentAction
(String contentType, String workflowName, int initialActionId, String lang, String contentTitle, String contentPrefix, Logger logger) Creates content action with result from requestgetMetadataHolder
(ModifiableCompositeMetadata parentMetadata, String metadataPath) Get the metadata holder for the requested metadata path.boolean
removeMetadataIfExists
(ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize) Remove the metadata if existsvoid
service
(ServiceManager manager) synchronizeMetadata
(ModifiableDefaultContent content, ContentType contentType, String logicalMetadataPath, String completeMetadataPath, List<Object> remoteValue, boolean synchronize, boolean create, Logger logger) Fill the metadata with remove value.synchronizeMetadata
(ModifiableDefaultContent content, ContentType contentType, String logicalMetadataPath, ModifiableCompositeMetadata metadataHolder, String metadataName, List<Object> remoteValue, boolean synchronize, boolean create, Logger logger) Fill the metadata with remote value.boolean
updateRelation
(ModifiableCompositeMetadata metadataToEdit, String metadataName, String contentId, boolean remove) Update the invert relation by adding/removing the content to/from the old values.boolean
updateRelation
(ModifiableCompositeMetadata metadataToEdit, String metadataName, Content content, boolean remove) Update the invert relation by adding/removing the content to/from the old values.void
updateSCCProperty
(DefaultContent content, String collectionId) Add the current synchronizable collection as propertyvoid
validateContent
(WorkflowAwareContent content, int validationActionId, boolean ignoreRights, Logger logger) Validates a content after importvoid
validateContent
(WorkflowAwareContent content, int validationActionId, Logger logger) Validates a content after import
-
Field Details
-
ROLE
Avalon Role -
_workflowHelper
The content workflow helper -
_observationManager
The observation manager -
_currentUserProvider
The current user provider -
_resolver
The ametys object resolver
-
-
Constructor Details
-
BaseSynchroComponent
public BaseSynchroComponent()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
removeMetadataIfExists
public boolean removeMetadataIfExists(ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize) Remove the metadata if exists- Parameters:
metadataHolder
- The metadata holdermetadataName
- The name of the metadatasynchronize
-true
if the data is synchronize- Returns:
true
if the metadata have been removed
-
validateContent
Validates a content after import- Parameters:
content
- The content to validatevalidationActionId
- Validation action ID to use for this contentlogger
- The logger
-
validateContent
public void validateContent(WorkflowAwareContent content, int validationActionId, boolean ignoreRights, Logger logger) Validates a content after import- Parameters:
content
- The content to validatevalidationActionId
- Validation action ID to use for this contentignoreRights
- true if checking rights needs to be ignoredlogger
- The logger
-
applyChanges
public Map<String,Boolean> applyChanges(ModifiableDefaultContent content, Integer actionId, String event, Logger logger) throws RepositoryException Does workflow action- Parameters:
content
- The synchronized contentactionId
- Workflow actionevent
- Type of eventlogger
- The logger- Returns:
- A
Map
with one or twoBoolean
, "success" tells if the operation have been done successfully, "error" tells if an error occurs during the content saving. The save can be successful but an error can occurs during the workflow update. - Throws:
RepositoryException
- if an error occurs when trying to rollback pending changes in the repository.
-
applyChanges
public Map<String,Boolean> applyChanges(ModifiableDefaultContent content, Integer actionId, String event, boolean ignoreRights, Logger logger) throws RepositoryException Does workflow action- Parameters:
content
- The synchronized contentactionId
- Workflow actionevent
- Type of eventignoreRights
- true if checking rights needs to be ignoredlogger
- The logger- Returns:
- A
Map
with one or twoBoolean
, "success" tells if the operation have been done successfully, "error" tells if an error occurs during the content saving. The save can be successful but an error can occurs during the workflow update. - Throws:
RepositoryException
- if an error occurs when trying to rollback pending changes in the repository.
-
updateRelation
public boolean updateRelation(ModifiableCompositeMetadata metadataToEdit, String metadataName, Content content, boolean remove) Update the invert relation by adding/removing the content to/from the old values.- Parameters:
metadataToEdit
- Metadata holder to editmetadataName
- Metadata name to setcontent
- The content to add or removeremove
-true
if we wan't to remove the content from the relation- Returns:
true
if there are changes
-
updateRelation
public boolean updateRelation(ModifiableCompositeMetadata metadataToEdit, String metadataName, String contentId, boolean remove) Update the invert relation by adding/removing the content to/from the old values.- Parameters:
metadataToEdit
- Metadata holder to editmetadataName
- Metadata name to setcontentId
- The content to add or removeremove
-true
if we wan't to remove the content from the relation- Returns:
true
if there are changes
-
updateSCCProperty
public void updateSCCProperty(DefaultContent content, String collectionId) throws RepositoryException Add the current synchronizable collection as property- Parameters:
content
- The synchronized contentcollectionId
- The ID of the collection- Throws:
RepositoryException
- if an error occurred
-
createContentAction
public Map<String,Object> createContentAction(String contentType, String workflowName, int initialActionId, String lang, String contentTitle, String contentPrefix, Logger logger) Creates content action with result from request- Parameters:
contentType
- Type of the content to createworkflowName
- Workflow to use for this contentinitialActionId
- Action ID for initializationlang
- The languagecontentTitle
- The content titlecontentPrefix
- The content prefix for the node creationlogger
- The logger- Returns:
- A
Map
with the created content in "content", and aBoolean
in "error" if an error occurs.
-
synchronizeMetadata
public Map<String,Boolean> synchronizeMetadata(ModifiableDefaultContent content, ContentType contentType, String logicalMetadataPath, String completeMetadataPath, List<Object> remoteValue, boolean synchronize, boolean create, Logger logger) Fill the metadata with remove value.- Parameters:
content
- The content to synchronizecontentType
- The content typelogicalMetadataPath
- The logical metadata path without the entriescompleteMetadataPath
- The complete metadata path from the root of the contentremoteValue
- The remote valuesynchronize
-true
if synchronizablecreate
-true
if content is creating, false if it is updatedlogger
- The logger- Returns:
- A
Map
with aBoolean
in "hasChanges" value if changes has been made, and aBoolean
in "error" value if an error occurs.
-
synchronizeMetadata
public Map<String,Boolean> synchronizeMetadata(ModifiableDefaultContent content, ContentType contentType, String logicalMetadataPath, ModifiableCompositeMetadata metadataHolder, String metadataName, List<Object> remoteValue, boolean synchronize, boolean create, Logger logger) Fill the metadata with remote value.- Parameters:
content
- The content to synchronizecontentType
- The content typelogicalMetadataPath
- The logical metadata path without the entriesmetadataHolder
- the metadata holder of the content to synchronizemetadataName
- the name of the metadataremoteValue
- The remote valuesynchronize
-true
if synchronizablecreate
-true
if content is creating, false if it is updatedlogger
- The logger- Returns:
- A
Map
with aBoolean
in "hasChanges" value if changes has been made, and aBoolean
in "error" value if an error occurs.
-
_setBinaryMetadata
protected boolean _setBinaryMetadata(ModifiableCompositeMetadata metadataHolder, String metadataName, Object valueToSet, boolean synchronize, String title, Logger logger) Set the binary metadata- Parameters:
metadataHolder
- the metadata holdermetadataName
- the metadata namevalueToSet
- the value to setsynchronize
- true if the metadata is synchronizetitle
- the content titlelogger
- the logger- Returns:
true
if changes were made
-
getMetadataHolder
public ModifiableCompositeMetadata getMetadataHolder(ModifiableCompositeMetadata parentMetadata, String metadataPath) Get the metadata holder for the requested metadata path.- Parameters:
parentMetadata
- Initial metadatametadataPath
- Metadata path from the parent- Returns:
- A metadata holder
-