public class BaseSynchroComponent extends Object implements Serviceable, Component
Modifier and Type | Field and Description |
---|---|
protected CurrentUserProvider |
_currentUserProvider
The current user provider
|
protected ObservationManager |
_observationManager
The observation manager
|
protected AmetysObjectResolver |
_resolver
The ametys object resolver
|
protected ContentWorkflowHelper |
_workflowHelper
The content workflow helper
|
static String |
ROLE
Avalon Role
|
static int |
SYNCHRONIZE_WORKFLOW_ACTION_ID
Id of workflow action for synchronization
|
Constructor and Description |
---|
BaseSynchroComponent() |
Modifier and Type | Method and Description |
---|---|
private byte[] |
_getBytesFromValue(Object valueToSet)
Get the bytes array from the value to set
|
private String |
_getContentName(String title,
String lang,
String prefix)
Gets the content name
|
private String[] |
_getLinesFromValue(Object valueToSet)
Get the lines array from valueToSet for the richText
|
protected boolean |
_setBinaryMetadata(ModifiableCompositeMetadata metadataHolder,
String metadataName,
Object valueToSet,
boolean synchronize,
String title,
Logger logger)
Set the binary metadata
|
private Map<String,Boolean> |
_setMetadata(ModifiableCompositeMetadata metadataHolder,
String metadataName,
Object valueToSet,
boolean synchronize,
boolean forceExternalStatus,
String contentTitle,
String contentType,
Logger logger) |
private boolean |
_setRichTextMetadata(ModifiableCompositeMetadata metadataHolder,
String metadataName,
Object valueToSet,
boolean synchronize,
String title,
Logger logger)
Set the richtext metadata
|
private static <T> T[] |
_toTypedArray(Class<?> classToCastTo,
List<Object> list)
This method have been build to go through the CONTENTIO-95 problem.
|
Map<String,Boolean> |
applyChanges(ModifiableDefaultContent content,
Integer actionId,
String event,
Logger logger)
Does workflow action
|
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
|
ModifiableCompositeMetadata |
getMetadataHolder(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 exists
|
void |
service(ServiceManager manager) |
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.
|
boolean |
updateRelation(ModifiableCompositeMetadata metadataToEdit,
String metadataName,
Content content,
boolean remove)
Update the invert relation by adding/removing the content to/from the old values.
|
boolean |
updateRelation(ModifiableCompositeMetadata metadataToEdit,
String metadataName,
String contentId,
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 property
|
void |
validateContent(WorkflowAwareContent content,
int validationActionId,
Logger logger)
Validates a content after import
|
public static final int SYNCHRONIZE_WORKFLOW_ACTION_ID
protected ContentWorkflowHelper _workflowHelper
protected ObservationManager _observationManager
protected CurrentUserProvider _currentUserProvider
protected AmetysObjectResolver _resolver
public BaseSynchroComponent()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public boolean removeMetadataIfExists(ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize)
metadataHolder
- The metadata holdermetadataName
- The name of the metadatasynchronize
- true
if the data is synchronizetrue
if the metadata have been removedpublic void validateContent(WorkflowAwareContent content, int validationActionId, Logger logger)
content
- The content to validatevalidationActionId
- Validation action ID to use for this contentlogger
- The loggerpublic Map<String,Boolean> applyChanges(ModifiableDefaultContent content, Integer actionId, String event, Logger logger) throws RepositoryException
content
- The synchronized contentactionId
- Workflow actionevent
- Type of eventlogger
- The loggerMap
with one or two Boolean
, "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.RepositoryException
- if an error occurs when trying to rollback pending changes in the repository.public boolean updateRelation(ModifiableCompositeMetadata metadataToEdit, String metadataName, Content content, boolean remove)
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 relationtrue
if there are changespublic boolean updateRelation(ModifiableCompositeMetadata metadataToEdit, String metadataName, String contentId, boolean remove)
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 relationtrue
if there are changespublic void updateSCCProperty(DefaultContent content, String collectionId) throws RepositoryException
content
- The synchronized contentcollectionId
- The ID of the collectionRepositoryException
- if an error occurredpublic Map<String,Object> createContentAction(String contentType, String workflowName, int initialActionId, String lang, String contentTitle, String contentPrefix, Logger logger)
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 loggerMap
with the created content in "content", and a Boolean
in "error" if an error occurs.private String _getContentName(String title, String lang, String prefix)
title
- The namelang
- The lang of the contentpublic Map<String,Boolean> synchronizeMetadata(ModifiableDefaultContent content, ContentType contentType, String logicalMetadataPath, String completeMetadataPath, List<Object> remoteValue, boolean synchronize, boolean create, Logger logger)
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 loggerMap
with a Boolean
in "hasChanges" value if changes has been made, and a Boolean
in "error" value if an error occurs.private boolean _setRichTextMetadata(ModifiableCompositeMetadata metadataHolder, String metadataName, Object valueToSet, boolean synchronize, String title, Logger logger)
metadataHolder
- the metadata holdermetadataName
- the metadata namevalueToSet
- the value to setsynchronize
- true if the metadata is synchronizetitle
- the content titlelogger
- the loggertrue
if changes were madeprotected boolean _setBinaryMetadata(ModifiableCompositeMetadata metadataHolder, String metadataName, Object valueToSet, boolean synchronize, String title, Logger logger)
metadataHolder
- the metadata holdermetadataName
- the metadata namevalueToSet
- the value to setsynchronize
- true if the metadata is synchronizetitle
- the content titlelogger
- the loggertrue
if changes were madeprivate byte[] _getBytesFromValue(Object valueToSet) throws IOException
valueToSet
- the value to setIOException
- if an error occurredprivate String[] _getLinesFromValue(Object valueToSet) throws IOException
valueToSet
- the value to setIOException
- if an error occurredprivate Map<String,Boolean> _setMetadata(ModifiableCompositeMetadata metadataHolder, String metadataName, Object valueToSet, boolean synchronize, boolean forceExternalStatus, String contentTitle, String contentType, Logger logger)
public ModifiableCompositeMetadata getMetadataHolder(ModifiableCompositeMetadata parentMetadata, String metadataPath)
parentMetadata
- Initial metadatametadataPath
- Metadata path from the parentprivate static <T> T[] _toTypedArray(Class<?> classToCastTo, List<Object> list)
ExternalizableMetadataHelper
methods.T
- The type of the arrayclassToCastTo
- The class to cast tolist
- The list to transform to an array