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,PegaseSynchronizableContentsCollection,UserPopulationSynchronizableContentsCollection
public abstract class AbstractSimpleSynchronizableContentsCollection extends AbstractSynchronizableContentsCollection
Abstract implementation ofSynchronizableContentsCollection.
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentHelper_contentHelperThe content helperprotected SynchronizingContentOperatorExtensionPoint_synchronizingContentOperatorEPThe extension point for Synchronizing Content Operators-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_contentWorkflowHelper, _currentUserProvider, _hasGlobalError, _i18nUtils, _nbCreatedContents, _nbDeletedContents, _nbError, _nbNotChangedContents, _nbSynchronizedContents, _observationManager, SCC_UNIQUE_ID
-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_contentDAO, _contentPrefix, _contentType, _contentTypeEP, _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_DATA_NAME, RESULT_NB_CREATED_CONTENTS, RESULT_NB_DELETED_CONTENTS, RESULT_NB_NOT_CHANGED_CONTENTS, RESULT_NB_SYNCHRONIZED_CONTENTS
-
-
Constructor Summary
Constructors Constructor Description AbstractSimpleSynchronizableContentsCollection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean_editContent(WorkflowAwareContent content, Optional<View> view, Map<String,Object> values, Map<String,Object> additionalParameters, boolean create, Set<String> notSynchronizedContentIds, org.slf4j.Logger logger)Synchronize the content with given values.protected boolean_fillContent(Map<String,List<Object>> remoteValues, ModifiableContent content, Map<String,Object> additionalParameters, boolean create, org.slf4j.Logger logger)Fill the content with remote values.protected List<Content>_getContentsToRemove(AmetysObjectIterable<ModifiableContent> contents)Filter the contents to remove.protected void_handleContent(String id)Adds the given content as handled (i.e.protected ModifiableContent_importContent(String idValue, Map<String,Object> additionalParameters, String lang, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger)Import a content from remote values.protected Optional<ModifiableContent>_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<ModifiableContent>_importOrSynchronizeContent(String idValue, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)Imports or synchronizes a content for each available languageprotected List<ModifiableContent>_importOrSynchronizeContents(Map<String,Object> searchParameters, boolean forceImport, org.slf4j.Logger logger)Import or synchronize several contents from search params.protected List<ModifiableContent>_internalPopulate(org.slf4j.Logger logger)Internal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)protected boolean_isHandled(String id)Returns true if the given content is handledprotected ModifiableContent_synchronizeContent(ModifiableContent content, Map<String,List<Object>> remoteValues, org.slf4j.Logger logger)Synchronize a content with remove values.protected Map<String,Map<String,List<Object>>>_transformRemoteValues(Map<String,Map<String,List<Object>>> remoteValues, org.slf4j.Logger logger)Transform the given remote values by theSynchronizingContentOperatorif exists.voidconfigure(Configuration configuration)protected ModifiableContentcreateContentAction(String lang, String contentTitle, org.slf4j.Logger logger)Creates content action with result from requestprotected Map<String,Object>getAdditionalAttributeValues(String idValue, Content content, Map<String,Object> additionalParameters, boolean create, org.slf4j.Logger logger)Retrieves additional values to synchronize for a contentModifiableContentgetContent(String lang, String idValue)Gets the content in the repositoryprotected Set<String>getNotSynchronizedRelatedContentIds(Content content, Map<String,Object> contentValues, Map<String,Object> additionalParameters, String lang, org.slf4j.Logger logger)Retrieves the ids of the contents related to the given content but that are not part of the synchronizationprotected abstract Map<String,Map<String,List<Object>>>getRemoteValues(Map<String,Object> searchParameters, org.slf4j.Logger logger)Search values and return the result organized by attributesintgetTotalCount(Map<String,Object> searchParameters, org.slf4j.Logger logger)Return the total number of results for the search.protected Map<String,Map<String,List<Object>>>getTransformedRemoteValues(Map<String,Object> searchParameters, org.slf4j.Logger logger)Search values and return the result organized by attributes and transformed by theSynchronizingContentOperatorif exists.List<ModifiableContent>importContent(String idValue, Map<String,Object> additionalParameters, org.slf4j.Logger logger)Import a content from remote values.protected abstract Map<String,Map<String,Object>>internalSearch(Map<String,Object> searchParameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)Search values and return the result without any treatment.List<ModifiableContent>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> searchParameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)Search the data to import from parameters.voidservice(ServiceManager manager)voidsynchronizeContent(ModifiableContent content, org.slf4j.Logger logger)Synchronize a content with remove values.voidupdateSyncInformations(ModifiableContent 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
_deleteContents, _getAdditionalInputsForContentCreation, _getContentPathQuery, _getExpressionsList, _hasSomethingChanged, _isParamNotEmpty, _logSynchronizationResult, _removeEmptyParameters, createContentAction, deleteUnexistingContents, empty, getSynchronizationResult, sendErrorMail, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_parseLanguages, _parseParameters, _transformRemoteValuesCardinality, 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
additionalCommonOperations, additionalImportOperations, additionalSynchronizeOperations, getIdField, getLocalAndExternalFields, handleRightAssignmentContext
-
-
-
-
Field Detail
-
_synchronizingContentOperatorEP
protected SynchronizingContentOperatorExtensionPoint _synchronizingContentOperatorEP
The extension point for Synchronizing Content Operators
-
_contentHelper
protected ContentHelper _contentHelper
The content helper
-
-
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<ModifiableContent> 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<ModifiableContent> _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<ModifiableContent> _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 Optional<ModifiableContent> _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 imported or synchronized content
-
synchronizeContent
public void synchronizeContent(ModifiableContent 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 ModifiableContent _synchronizeContent(ModifiableContent 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<ModifiableContent> importContent(String idValue, Map<String,Object> additionalParameters, 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 importadditionalParameters- 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 ModifiableContent _importContent(String idValue, Map<String,Object> additionalParameters, 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 importadditionalParameters- 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.
-
getContent
public ModifiableContent 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 ModifiableContent 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 occurs
-
_fillContent
protected boolean _fillContent(Map<String,List<Object>> remoteValues, ModifiableContent content, Map<String,Object> additionalParameters, boolean create, org.slf4j.Logger logger) throws Exception
Fill the content with remote values.- Parameters:
remoteValues- The remote valuescontent- The content to synchronizeadditionalParameters- Additional parameterscreate-trueif content is creating, false if it is updatedlogger- The logger- Returns:
trueif the content has been modified,falseotherwise- Throws:
Exception- if an error occurs
-
_editContent
protected boolean _editContent(WorkflowAwareContent content, Optional<View> view, Map<String,Object> values, Map<String,Object> additionalParameters, boolean create, Set<String> notSynchronizedContentIds, org.slf4j.Logger logger) throws com.opensymphony.workflow.WorkflowException
Synchronize the content with given values.- Parameters:
content- The content to synchronizeview- the view containing the item to editvalues- the valuesadditionalParameters- Additional parameterscreate-trueif content is creating, false if it is updatednotSynchronizedContentIds- the ids of the contents related to the given content but that are not part of the synchronizationlogger- The logger- Returns:
trueif the content has been modified,falseotherwise- Throws:
com.opensymphony.workflow.WorkflowException- if an error occurs
-
validateContent
protected void validateContent(WorkflowAwareContent content, org.slf4j.Logger logger)
Validates a content after import- Parameters:
content- The content to validatelogger- The logger
-
search
public Map<String,Map<String,Object>> search(Map<String,Object> searchParameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollectionSearch the data to import from parameters.- Parameters:
searchParameters- 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> searchParameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Search values and return the result without any treatment.- Parameters:
searchParameters- 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> searchParameters, org.slf4j.Logger logger)
Search values and return the result organized by attributes and transformed by theSynchronizingContentOperatorif exists.- Parameters:
searchParameters- Search parameters to restrict the searchlogger- The logger- Returns:
- Map of results organized by attributes.
-
getRemoteValues
protected abstract Map<String,Map<String,List<Object>>> getRemoteValues(Map<String,Object> searchParameters, org.slf4j.Logger logger)
Search values and return the result organized by attributes- Parameters:
searchParameters- Search parameters to restrict the searchlogger- The logger- Returns:
- Map of results organized by attributes.
-
_transformRemoteValues
protected Map<String,Map<String,List<Object>>> _transformRemoteValues(Map<String,Map<String,List<Object>>> remoteValues, org.slf4j.Logger logger)
Transform the given remote values by theSynchronizingContentOperatorif exists.- Parameters:
remoteValues- The remote valueslogger- The logger- Returns:
- the transformed values
-
getAdditionalAttributeValues
protected Map<String,Object> getAdditionalAttributeValues(String idValue, Content content, Map<String,Object> additionalParameters, boolean create, org.slf4j.Logger logger)
Retrieves additional values to synchronize for a content- Parameters:
idValue- id value of the contentcontent- The contentadditionalParameters- Additional parameterscreate-trueif the content has been newly created,falseotherwiselogger- The logger- Returns:
- the values to add
-
getNotSynchronizedRelatedContentIds
protected Set<String> getNotSynchronizedRelatedContentIds(Content content, Map<String,Object> contentValues, Map<String,Object> additionalParameters, String lang, org.slf4j.Logger logger)
Retrieves the ids of the contents related to the given content but that are not part of the synchronization- Parameters:
content- contentcontentValues- the content values that will be setadditionalParameters- Additional parameterslang- Language of the contentlogger- The logger- Returns:
- the ids of the contents that are not part of the synchronization
-
updateSyncInformations
public void updateSyncInformations(ModifiableContent 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> searchParameters, org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollectionReturn the total number of results for the search.- Parameters:
searchParameters- Parameters for the searchlogger- The logger- Returns:
- The total count
-
_importOrSynchronizeContents
protected List<ModifiableContent> _importOrSynchronizeContents(Map<String,Object> searchParameters, boolean forceImport, org.slf4j.Logger logger)
Import or synchronize several contents from search params.- Parameters:
searchParameters- Search parametersforceImport- To force import and ignoring the synchronize existing contents only optionlogger- The logger- Returns:
- The
Listof imported or synchronizedModifiableContent
-
_getContentsToRemove
protected List<Content> _getContentsToRemove(AmetysObjectIterable<ModifiableContent> 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.
-
-