Class AbstractSynchronizableContentsCollection
- java.lang.Object
-
- org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
-
- org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
-
- All Implemented Interfaces:
SynchronizableContentsCollection
,Configurable
,Serviceable
- Direct Known Subclasses:
AbstractCDMFrSynchronizableContentsCollection
,AbstractSimpleSynchronizableContentsCollection
public abstract class AbstractSynchronizableContentsCollection extends AbstractStaticSynchronizableContentsCollection
Abstract implementation ofSynchronizableContentsCollection
.
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentTypeExtensionPoint
_contentTypeEP
The content type extension pointprotected CurrentUserProvider
_currentUserProvider
The current user providerprotected boolean
_hasGlobalError
True if there is a global error during synchronizationprotected I18nUtils
_i18nUtils
The i18n utilsprotected int
_nbCreatedContents
Number of created contentsprotected int
_nbDeletedContents
Number of deleted contentsprotected int
_nbError
Number of errors encounteredprotected int
_nbNotChangedContents
Number of unchanged contentsprotected int
_nbSynchronizedContents
Number of synchronized contentsprotected ObservationManager
_observationManager
The observation managerprotected BaseSynchroComponent
_synchroComponent
The base SCC componentprotected static String
SCC_UNIQUE_ID
SCC unique ID field-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_contentDAO, _contentPrefix, _contentType, _id, _initialActionId, _label, _languages, _modelId, _modelParamValues, _removalSync, _reportMails, _resolver, _restrictedField, _sccHelper, _searchModelConfiguration, _synchronizeActionId, _synchronizeExistingContentsOnly, _synchronizingContentOperator, _validateActionId, _validateAfterImport, _workflowName
-
Fields inherited from interface org.ametys.plugins.contentio.synchronize.SynchronizableContentsCollection
COLLECTION_ID_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description AbstractSynchronizableContentsCollection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected int
_deleteContents(List<Content> contentsToRemove, org.slf4j.Logger logger)
Delete contents.protected String
_getContentPathQuery(String lang, String idValue, String contentType)
Construct the query to retrieve the content.protected abstract List<Content>
_getContentsToRemove(AmetysObjectIterable<ModifiableDefaultContent> contents)
Filter the contents to remove.protected List<Expression>
_getExpressionsList(String lang, String idValue, String contentType)
Construct the query to retrieve the content.protected ModifiableCompositeMetadata
_getMetadataHolder(ModifiableCompositeMetadata parentMetadata, String metadataPath)
Get the metadata holder for the requested metadata path.protected abstract List<ModifiableDefaultContent>
_internalPopulate(org.slf4j.Logger logger)
Internal implementation ofpopulate(Logger)
protected boolean
_isParamNotEmpty(Object parameterValue)
Check if the parameter value is emptyprotected Map<String,Object>
_removeEmptyParameters(Map<String,Object> parameters)
Remove empty parameters to the mapprotected boolean
_removeMetadataIfExists(ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize)
Remove the metadata if existsprotected boolean
_synchronizeMetadata(ModifiableDefaultContent content, ContentType contentType, String logicalMetadataPath, String completeMetadataPath, List<Object> remoteValue, boolean synchronize, boolean create, org.slf4j.Logger logger)
Fill the metadata with remove value.protected boolean
_updateRelation(ModifiableCompositeMetadata metadataToEdit, String metadataName, Content content)
Update the invert relation by adding the new value (Content) to the old values.protected boolean
_updateRelation(ModifiableCompositeMetadata metadataToEdit, String metadataName, Content content, boolean remove)
Update the invert relation by adding/removing the content to/from the old values.protected boolean
applyChanges(ModifiableDefaultContent content, Integer actionId, String event, org.slf4j.Logger logger)
Does workflow actionprotected boolean
applyChanges(ModifiableDefaultContent content, org.slf4j.Logger logger)
Does workflow actionprotected ModifiableDefaultContent
createContentAction(String contentType, String workflowName, int initialActionId, String lang, String contentTitle, org.slf4j.Logger logger)
Creates content action with result from requestprotected void
deleteUnexistingContents(org.slf4j.Logger logger)
Delete contents created by a previous synchronization which does not exist anymore in remote sourcevoid
empty(org.slf4j.Logger logger)
Empty the collection of its synchronized contentsList<ModifiableDefaultContent>
populate(org.slf4j.Logger logger)
Populates contentsprotected void
sendErrorMail(int nbError)
Sends the report mailsvoid
service(ServiceManager manager)
protected void
updateSCCProperty(DefaultContent content)
Add the current synchronizable collection as propertyprotected void
validateContent(WorkflowAwareContent content, int validationActionId, org.slf4j.Logger logger)
Validates a content after import-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_parseLanguages, _parseParameters, configure, configureDataSource, configureSearchModel, configureStaticParams, getContentPrefix, getContentType, getId, getInitialActionId, getLabel, getLanguages, getParameterValues, getReportMails, getRestrictedField, getSearchModelConfiguration, getSynchronizeActionId, getSynchronizeCollectionModelId, getSynchronizingContentOperator, getValidateActionId, getWorkflowName, removalSync, synchronizeExistingContentsOnly, validateAfterImport
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.contentio.synchronize.SynchronizableContentsCollection
getContent, getExternalOnlyFields, getIdField, getLocalAndExternalFields, getTotalCount, handleRightAssignmentContext, importContent, search, synchronizeContent, updateSyncInformations
-
-
-
-
Field Detail
-
SCC_UNIQUE_ID
protected static final String SCC_UNIQUE_ID
SCC unique ID field- See Also:
- Constant Field Values
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
_contentTypeEP
protected ContentTypeExtensionPoint _contentTypeEP
The content type extension point
-
_synchroComponent
protected BaseSynchroComponent _synchroComponent
The base SCC component
-
_nbError
protected int _nbError
Number of errors encountered
-
_hasGlobalError
protected boolean _hasGlobalError
True if there is a global error during synchronization
-
_nbCreatedContents
protected int _nbCreatedContents
Number of created contents
-
_nbSynchronizedContents
protected int _nbSynchronizedContents
Number of synchronized contents
-
_nbNotChangedContents
protected int _nbNotChangedContents
Number of unchanged contents
-
_nbDeletedContents
protected int _nbDeletedContents
Number of deleted contents
-
-
Constructor Detail
-
AbstractSynchronizableContentsCollection
public AbstractSynchronizableContentsCollection()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractStaticSynchronizableContentsCollection
- Throws:
ServiceException
-
populate
public List<ModifiableDefaultContent> populate(org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollection
Populates contents- Parameters:
logger
- The logger- Returns:
- Return the populated contents (imported or synchronized)
-
_internalPopulate
protected abstract List<ModifiableDefaultContent> _internalPopulate(org.slf4j.Logger logger)
Internal implementation ofpopulate(Logger)
- Parameters:
logger
- The logger- Returns:
- The list of created/synchronized contents
-
empty
public void empty(org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollection
Empty the collection of its synchronized contents- Parameters:
logger
- The logger
-
deleteUnexistingContents
protected void deleteUnexistingContents(org.slf4j.Logger logger)
Delete contents created by a previous synchronization which does not exist anymore in remote source- Parameters:
logger
- The logger
-
_getContentsToRemove
protected abstract List<Content> _getContentsToRemove(AmetysObjectIterable<ModifiableDefaultContent> contents)
Filter the contents to remove.
-
_deleteContents
protected int _deleteContents(List<Content> contentsToRemove, org.slf4j.Logger logger)
Delete contents.- Parameters:
contentsToRemove
- List of contents to removelogger
- The logger- Returns:
- the number of deleted contents
-
sendErrorMail
protected void sendErrorMail(int nbError) throws javax.mail.MessagingException
Sends the report mails- Parameters:
nbError
- The number of error- Throws:
javax.mail.MessagingException
- if a messaging error occurred
-
validateContent
protected void validateContent(WorkflowAwareContent content, int validationActionId, org.slf4j.Logger logger)
Validates a content after import- Parameters:
content
- The content to validatevalidationActionId
- Validation action ID to use for this contentlogger
- The logger
-
applyChanges
protected boolean applyChanges(ModifiableDefaultContent content, org.slf4j.Logger logger) throws RepositoryException
Does workflow action- Parameters:
content
- The synchronized contentlogger
- The logger- Returns:
- true if the content is considered as synchronized (the apply succeeded), false otherwise.
- Throws:
RepositoryException
- if an error occurs when trying to rollback pending changes in the repository.
-
applyChanges
protected boolean applyChanges(ModifiableDefaultContent content, Integer actionId, String event, org.slf4j.Logger logger) throws RepositoryException
Does workflow action- Parameters:
content
- The synchronized contentactionId
- Workflow actionevent
- Type of eventlogger
- The logger- Returns:
- true if the content is considered as synchronized (the apply succeeded), false otherwise.
- Throws:
RepositoryException
- if an error occurs when trying to rollback pending changes in the repository.
-
createContentAction
protected ModifiableDefaultContent createContentAction(String contentType, String workflowName, int initialActionId, String lang, String contentTitle, org.slf4j.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 titlelogger
- The logger- Returns:
- The content id, or null of a workflow error occured
-
_getExpressionsList
protected List<Expression> _getExpressionsList(String lang, String idValue, String contentType)
Construct the query to retrieve the content.- Parameters:
lang
- LangidValue
- Synchronization valuecontentType
- Content type- Returns:
- The
List
ofExpression
-
_getContentPathQuery
protected String _getContentPathQuery(String lang, String idValue, String contentType)
Construct the query to retrieve the content.- Parameters:
lang
- LangidValue
- Synchronization valuecontentType
- Content type- Returns:
- The XPATH query
-
_synchronizeMetadata
protected boolean _synchronizeMetadata(ModifiableDefaultContent content, ContentType contentType, String logicalMetadataPath, String completeMetadataPath, List<Object> remoteValue, boolean synchronize, boolean create, org.slf4j.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:
true
if changes were made
-
_removeMetadataIfExists
protected 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
-
_getMetadataHolder
protected 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
-
_updateRelation
protected boolean _updateRelation(ModifiableCompositeMetadata metadataToEdit, String metadataName, Content content)
Update the invert relation by adding the new value (Content) to the old values.- Parameters:
metadataToEdit
- Metadata holder to editmetadataName
- Metadata name to setcontent
- The content to add or remove- Returns:
true
if there are changes
-
_updateRelation
protected 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
-
updateSCCProperty
protected void updateSCCProperty(DefaultContent content) throws RepositoryException
Add the current synchronizable collection as property- Parameters:
content
- The synchronized content- Throws:
RepositoryException
- if an error occurred
-
_removeEmptyParameters
protected Map<String,Object> _removeEmptyParameters(Map<String,Object> parameters)
Remove empty parameters to the map- Parameters:
parameters
- the parameters- Returns:
- the map of none empty parameters
-
_isParamNotEmpty
protected boolean _isParamNotEmpty(Object parameterValue)
Check if the parameter value is empty- Parameters:
parameterValue
- the parameter value- Returns:
- true if the parameter value is empty
-
-