Class AbstractSimpleSynchronizableContentsCollection
- java.lang.Object
-
- org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
-
- org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
-
- org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
-
- All Implemented Interfaces:
SynchronizableContentsCollection,Configurable,Serviceable
- Direct Known Subclasses:
AbstractApogeeSynchronizableContentsCollection,AbstractDataSourceSynchronizableContentsCollection,UserPopulationSynchronizableContentsCollection
public abstract class AbstractSimpleSynchronizableContentsCollection extends AbstractSynchronizableContentsCollection
Abstract implementation ofSynchronizableContentsCollection.
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentHelper_contentHelperThe content helperprivate List<String>_handledContentsprotected SynchronizableContentsCollectionHelper_sccHelperSCC helperprotected SynchronizingContentOperatorExtensionPoint_synchronizingContentOperatorEPThe extension point for Synchronizing Content Operators-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_contentDAO, _contentTypeEP, _currentUserProvider, _hasGlobalError, _i18nUtils, _nbCreatedContents, _nbDeletedContents, _nbError, _nbNotChangedContents, _nbSynchronizedContents, _observationManager, _resolver, _synchroComponent, SCC_UNIQUE_ID
-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_contentPrefix, _contentType, _id, _initialActionId, _label, _languages, _modelId, _modelParamValues, _removalSync, _reportMails, _restrictedField, _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 AbstractSimpleSynchronizableContentsCollection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void_ensureTitleIsPresent(Content content, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger)protected boolean_fillContent(Map<String,List<Object>> remoteValues, ModifiableDefaultContent content, boolean create, org.slf4j.Logger logger)Fill the content with remote values.protected List<Content>_getContentsToRemove(AmetysObjectIterable<ModifiableDefaultContent> contents)Filter the contents to remove.protected String_getIdFieldValue(DefaultContent content)Get the value of metadata holding the unique identifier of the synchronized contentprotected void_handleContent(String id)Adds the given content as handled (i.e.protected ModifiableDefaultContent_importContent(String idValue, Map<String,Object> importParams, String lang, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger)Import a content from remote values.protected List<ModifiableDefaultContent>_importOrSynchronizeContent(String idValue, String lang, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)Imports or synchronizes a content for a given languageprotected List<ModifiableDefaultContent>_importOrSynchronizeContent(String idValue, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)Imports or synchronizes a content for each available languageprotected List<ModifiableDefaultContent>_importOrSynchronizeContents(Map<String,Object> searchParams, boolean forceImport, org.slf4j.Logger logger)Import or synchronize several contents from search params.protected List<ModifiableDefaultContent>_internalPopulate(org.slf4j.Logger logger)Internal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)protected boolean_isHandled(String id)Returns true if the given content is handledprotected ModifiableDefaultContent_synchronizeContent(ModifiableDefaultContent content, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger)Synchronize a content with remove values.protected booleanadditionalCommonOperations(ModifiableDefaultContent content, Map<String,List<Object>> remoteValues, Map<String,Object> importParams, boolean create, org.slf4j.Logger logger)Add specific fields to the content during import or synchronization.protected booleanadditionalImportOperations(ModifiableDefaultContent content, Map<String,List<Object>> remoteValues, Map<String,Object> importParams, org.slf4j.Logger logger)Add specific fields to the content.protected booleanadditionalSynchronizeOperations(ModifiableDefaultContent content, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger)Add specific fields to the content.voidconfigure(Configuration configuration)protected ModifiableDefaultContentcreateContentAction(String lang, String contentTitle, org.slf4j.Logger logger)Creates content action with result from requestModifiableDefaultContentgetContent(String lang, String idValue)Gets the content in the repositoryprotected abstract Map<String,Map<String,List<Object>>>getRemoteValues(Map<String,Object> parameters, org.slf4j.Logger logger)Search values and return the result organized by metadataintgetTotalCount(Map<String,Object> parameters, org.slf4j.Logger logger)Return the total number of results for the search.protected Map<String,Map<String,List<Object>>>getTransformedRemoteValues(Map<String,Object> parameters, org.slf4j.Logger logger)Search values and return the result organized by metadata and transformed by theSynchronizingContentOperatorif exists.List<ModifiableDefaultContent>importContent(String idValue, Map<String,Object> importParams, org.slf4j.Logger logger)Import a content from remote values.protected abstract Map<String,Map<String,Object>>internalSearch(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)Search values and return the result without any treatment.List<ModifiableDefaultContent>populate(org.slf4j.Logger logger)Populates contentsprotected abstract Map<String,Object>putIdParameter(String idValue)Set search parameters for the ID value.Map<String,Map<String,Object>>search(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)Search the data to import from parameters.voidservice(ServiceManager manager)voidsynchronizeContent(ModifiableDefaultContent content, org.slf4j.Logger logger)Synchronize a content with remove values.voidupdateSyncInformations(ModifiableDefaultContent content, String syncCode, org.slf4j.Logger logger)Method to update the synchronisation informations (collection and value of the ID field).protected voidvalidateContent(WorkflowAwareContent content, org.slf4j.Logger logger)Validates a content after import-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_getContentPathQuery, _getExpressionsList, _getMetadataHolder, _isParamNotEmpty, _removeEmptyParameters, _removeMetadataIfExists, _synchronizeMetadata, _updateRelation, _updateRelation, applyChanges, applyChanges, createContentAction, deleteUnexistingContents, sendErrorMail, updateSCCProperty, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_parseLanguages, _parseParameters, 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
getExternalOnlyFields, getIdField, getLocalAndExternalFields, handleRightAssignmentContext
-
-
-
-
Field Detail
-
_synchronizingContentOperatorEP
protected SynchronizingContentOperatorExtensionPoint _synchronizingContentOperatorEP
The extension point for Synchronizing Content Operators
-
_sccHelper
protected SynchronizableContentsCollectionHelper _sccHelper
SCC helper
-
_contentHelper
protected ContentHelper _contentHelper
The content helper
-
_handledContents
private List<String> _handledContents
-
-
Constructor Detail
-
AbstractSimpleSynchronizableContentsCollection
public AbstractSimpleSynchronizableContentsCollection()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classAbstractSynchronizableContentsCollection- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classAbstractStaticSynchronizableContentsCollection- Throws:
ConfigurationException
-
populate
public List<ModifiableDefaultContent> populate(org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollectionPopulates contents- Specified by:
populatein interfaceSynchronizableContentsCollection- Overrides:
populatein classAbstractSynchronizableContentsCollection- Parameters:
logger- The logger- Returns:
- Return the populated contents (imported or synchronized)
-
_internalPopulate
protected List<ModifiableDefaultContent> _internalPopulate(org.slf4j.Logger logger)
Description copied from class:AbstractSynchronizableContentsCollectionInternal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)- Specified by:
_internalPopulatein classAbstractSynchronizableContentsCollection- Parameters:
logger- The logger- Returns:
- The list of created/synchronized contents
-
_handleContent
protected void _handleContent(String id)
Adds the given content as handled (i.e. will not be removed if _removalSync is true)- Parameters:
id- The id of the content
-
_isHandled
protected boolean _isHandled(String id)
Returns true if the given content is handled- Parameters:
id- The content to test- Returns:
- true if the given content is handled
-
_importOrSynchronizeContent
protected List<ModifiableDefaultContent> _importOrSynchronizeContent(String idValue, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)
Imports or synchronizes a content for each available language- Parameters:
idValue- The unique identifier of the contentremoteValues- The remote valuesforceImport- To force import and ignoring the synchronize existing contents only optionlogger- The logger- Returns:
- The list of synchronized or imported contents
-
_importOrSynchronizeContent
protected List<ModifiableDefaultContent> _importOrSynchronizeContent(String idValue, String lang, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)
Imports or synchronizes a content for a given language- Parameters:
idValue- The unique identifier of the contentlang- The language of content to import or synchronizeremoteValues- The remote valuesforceImport- To force import and ignoring the synchronize existing contents only optionlogger- The logger- Returns:
- The list of imported and synchronized contents
-
synchronizeContent
public void synchronizeContent(ModifiableDefaultContent content, org.slf4j.Logger logger) throws Exception
Description copied from interface:SynchronizableContentsCollectionSynchronize a content with remove values.- Parameters:
content- The content to synchronizelogger- The logger- Throws:
Exception- if an error occurs.
-
_synchronizeContent
protected ModifiableDefaultContent _synchronizeContent(ModifiableDefaultContent content, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger) throws Exception
Synchronize a content with remove values.- Parameters:
content- The content to synchronizeremoteValues- Values to synchronizelogger- The logger- Returns:
- The synchronized content
- Throws:
Exception- if an error occurs.
-
importContent
public List<ModifiableDefaultContent> importContent(String idValue, Map<String,Object> importParams, org.slf4j.Logger logger) throws Exception
Description copied from interface:SynchronizableContentsCollectionImport a content from remote values.- Parameters:
idValue- Id (for import/synchronization) of the content to importimportParams- Additional parameterslogger- The logger- Returns:
- A list of created contents
- Throws:
Exception- if an error occurs.
-
putIdParameter
protected abstract Map<String,Object> putIdParameter(String idValue)
Set search parameters for the ID value.- Parameters:
idValue- Value to search- Returns:
- Map with the search parameters
-
_importContent
protected ModifiableDefaultContent _importContent(String idValue, Map<String,Object> importParams, String lang, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger) throws Exception
Import a content from remote values.- Parameters:
idValue- Id (for import/synchronization) of the content to importimportParams- Specific parameters for importlang- Lang of the contentremoteValues- Values of the contentlogger- The logger- Returns:
- The content created by import, or null
- Throws:
Exception- if an error occurs.
-
additionalImportOperations
protected boolean additionalImportOperations(ModifiableDefaultContent content, Map<String,List<Object>> remoteValues, Map<String,Object> importParams, org.slf4j.Logger logger)
Add specific fields to the content.- Parameters:
content- Content to updateremoteValues- Values of the contentimportParams- Import parameterslogger- The logger- Returns:
trueif there are changes
-
additionalSynchronizeOperations
protected boolean additionalSynchronizeOperations(ModifiableDefaultContent content, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger)
Add specific fields to the content.- Parameters:
content- Content to updateremoteValues- Values of the contentlogger- The logger- Returns:
trueif there are changes
-
additionalCommonOperations
protected boolean additionalCommonOperations(ModifiableDefaultContent content, Map<String,List<Object>> remoteValues, Map<String,Object> importParams, boolean create, org.slf4j.Logger logger)
Add specific fields to the content during import or synchronization.- Parameters:
content- Content to updateremoteValues- Values of the contentimportParams- the import paramscreate- true if the content has been newly createdlogger- The logger- Returns:
trueif there are changes
-
_ensureTitleIsPresent
private void _ensureTitleIsPresent(Content content, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger)
-
getContent
public ModifiableDefaultContent getContent(String lang, String idValue)
Description copied from interface:SynchronizableContentsCollectionGets the content in the repository- Parameters:
lang- the languageidValue- the content name- Returns:
- the content in the repository, or null if does not exist
-
createContentAction
protected ModifiableDefaultContent createContentAction(String lang, String contentTitle, org.slf4j.Logger logger)
Creates content action with result from request- Parameters:
lang- The languagecontentTitle- The content titlelogger- The logger- Returns:
- The content id, or null of a workflow error occured
-
_fillContent
protected boolean _fillContent(Map<String,List<Object>> remoteValues, ModifiableDefaultContent content, boolean create, org.slf4j.Logger logger)
Fill the content with remote values.- Parameters:
remoteValues- The remote valuescontent- The content to synchronizecreate-trueif content is creating, false if it is updatedlogger- The logger- Returns:
trueif changes were made
-
validateContent
protected void validateContent(WorkflowAwareContent content, org.slf4j.Logger logger)
Validates a content after import- Parameters:
content- The content to validatelogger- The logger
-
_getIdFieldValue
protected String _getIdFieldValue(DefaultContent content)
Get the value of metadata holding the unique identifier of the synchronized content- Parameters:
content- The content- Returns:
- The value
-
search
public Map<String,Map<String,Object>> search(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollectionSearch the data to import from parameters.- Parameters:
parameters- Parameters for the searchoffset- Begin of the searchlimit- Number of resultssort- Sort of results (ignored for LDAP results)logger- The logger- Returns:
- A map of remote values by content
-
internalSearch
protected abstract Map<String,Map<String,Object>> internalSearch(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Search values and return the result without any treatment.- Parameters:
parameters- Search parameters to restrict the searchoffset- Begin of the searchlimit- Number of resultssort- Sort of results (ignored for LDAP results)logger- The logger- Returns:
- Map of results without any treatment.
-
getTransformedRemoteValues
protected Map<String,Map<String,List<Object>>> getTransformedRemoteValues(Map<String,Object> parameters, org.slf4j.Logger logger)
Search values and return the result organized by metadata and transformed by theSynchronizingContentOperatorif exists.- Parameters:
parameters- Search parameters to restrict the searchlogger- The logger- Returns:
- Map of results organized by metadata.
-
getRemoteValues
protected abstract Map<String,Map<String,List<Object>>> getRemoteValues(Map<String,Object> parameters, org.slf4j.Logger logger)
Search values and return the result organized by metadata- Parameters:
parameters- Search parameters to restrict the searchlogger- The logger- Returns:
- Map of results organized by metadata.
-
updateSyncInformations
public void updateSyncInformations(ModifiableDefaultContent content, String syncCode, org.slf4j.Logger logger) throws Exception
Description copied from interface:SynchronizableContentsCollectionMethod to update the synchronisation informations (collection and value of the ID field).- Parameters:
content- Content to updatesyncCode- New synchronization codelogger- The logger- Throws:
Exception- if an error occurs.
-
getTotalCount
public int getTotalCount(Map<String,Object> parameters, org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollectionReturn the total number of results for the search.- Parameters:
parameters- Parameters for the searchlogger- The logger- Returns:
- The total count
-
_importOrSynchronizeContents
protected List<ModifiableDefaultContent> _importOrSynchronizeContents(Map<String,Object> searchParams, boolean forceImport, org.slf4j.Logger logger)
Import or synchronize several contents from search params.- Parameters:
searchParams- Search parametersforceImport- To force import and ignoring the synchronize existing contents only optionlogger- The logger- Returns:
- The
Listof imported or synchronizedModifiableDefaultContent
-
_getContentsToRemove
protected List<Content> _getContentsToRemove(AmetysObjectIterable<ModifiableDefaultContent> contents)
Description copied from class:AbstractSynchronizableContentsCollectionFilter the contents to remove.- Specified by:
_getContentsToRemovein classAbstractSynchronizableContentsCollection- Parameters:
contents- The list of all the available contents- Returns:
- The
ListofContentto remove.
-
-