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 of
SynchronizableContentsCollection
.-
Field Summary
Modifier and TypeFieldDescriptionprotected ContentHelper
The content helperThe extension point for Synchronizing Content OperatorsFields 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, _ignoreRestrictions, _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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
_addEditInputsForSCC
(Map<String, Object> inputs, WorkflowAwareContent content, Logger logger) Add the inputs specific for the SCC to the inputs for edit content function.protected boolean
_editContent
(WorkflowAwareContent content, Optional<View> view, Map<String, Object> values, Map<String, Object> additionalParameters, boolean create, Set<String> notSynchronizedContentIds, Logger logger) Synchronize the content with given values.protected boolean
_fillContent
(Map<String, List<Object>> remoteValues, ModifiableContent content, Map<String, Object> additionalParameters, boolean create, Logger logger) Fill the content with remote values.Filter the contents to remove._getEditInputs
(WorkflowAwareContent content, Optional<View> view, Map<String, Object> values, Map<String, Object> additionalParameters, boolean create, Set<String> notSynchronizedContentIds, Logger logger) Get the inputs for edit content function.Get the context parameters to add to inputs for edit content functionprotected 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, Logger logger) Import a content from remote values.protected Optional<ModifiableContent>
_importOrSynchronizeContent
(String idValue, String lang, Map<String, List<Object>> remoteValues, boolean forceImport, Logger logger) Imports or synchronizes a content for a given languageprotected List<ModifiableContent>
_importOrSynchronizeContent
(String idValue, Map<String, List<Object>> remoteValues, boolean forceImport, Logger logger) Imports or synchronizes a content for each available languageprotected List<ModifiableContent>
_importOrSynchronizeContents
(Map<String, Object> searchParameters, boolean forceImport, Logger logger) Import or synchronize several contents from search params.protected List<ModifiableContent>
_internalPopulate
(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, Logger logger) Synchronize a content with remove values.Transform the given remote values by theSynchronizingContentOperator
if exists.void
configure
(Configuration configuration) protected ModifiableContent
createContentAction
(String lang, String contentTitle, Logger logger) Creates content action with result from requestgetAdditionalAttributeValues
(String idValue, Content content, Map<String, Object> additionalParameters, boolean create, Logger logger) Retrieves additional values to synchronize for a contentgetContent
(String lang, String idValue) Gets the content in the repositorygetNotSynchronizedRelatedContentIds
(Content content, Map<String, Object> contentValues, Map<String, Object> additionalParameters, String lang, Logger logger) Retrieves the ids of the contents related to the given content but that are not part of the synchronizationgetRemoteValues
(Map<String, Object> searchParameters, Logger logger) Search values and return the result organized by attributesint
getTotalCount
(Map<String, Object> searchParameters, Logger logger) Return the total number of results for the search.getTransformedRemoteValues
(Map<String, Object> searchParameters, Logger logger) Search values and return the result organized by attributes and transformed by theSynchronizingContentOperator
if exists.Import a content from remote values.internalSearch
(Map<String, Object> searchParameters, int offset, int limit, List<Object> sort, Logger logger) Search values and return the result without any treatment.Populates contentsputIdParameter
(String idValue) Set search parameters for the ID value.search
(Map<String, Object> searchParameters, int offset, int limit, List<Object> sort, Logger logger) Search the data to import from parameters.void
service
(ServiceManager manager) void
synchronizeContent
(ModifiableContent content, Logger logger) Synchronize a content with remove values.void
updateSyncInformations
(ModifiableContent content, String syncCode, Logger logger) Method to update the synchronisation informations (collection and value of the ID field).protected void
validateContent
(WorkflowAwareContent content, Logger logger) Validates a content after importMethods 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, ignoreRestrictions, 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 Details
-
_synchronizingContentOperatorEP
The extension point for Synchronizing Content Operators -
_contentHelper
The content helper
-
-
Constructor Details
-
AbstractSimpleSynchronizableContentsCollection
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractSynchronizableContentsCollection
- Throws:
ServiceException
-
configure
- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classAbstractStaticSynchronizableContentsCollection
- Throws:
ConfigurationException
-
populate
Description copied from interface:SynchronizableContentsCollection
Populates contents- Specified by:
populate
in interfaceSynchronizableContentsCollection
- Overrides:
populate
in classAbstractSynchronizableContentsCollection
- Parameters:
logger
- The logger- Returns:
- Return the populated contents (imported or synchronized)
-
_internalPopulate
Description copied from class:AbstractSynchronizableContentsCollection
Internal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)
- Specified by:
_internalPopulate
in classAbstractSynchronizableContentsCollection
- Parameters:
logger
- The logger- Returns:
- The list of created/synchronized contents
-
_handleContent
Adds the given content as handled (i.e. will not be removed if _removalSync is true)- Parameters:
id
- The id of the content
-
_isHandled
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, 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, 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
Description copied from interface:SynchronizableContentsCollection
Synchronize 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, Logger logger) throws ExceptionSynchronize 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, Logger logger) throws ExceptionDescription copied from interface:SynchronizableContentsCollection
Import 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
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, throws ExceptionList<Object>> remoteValues, Logger logger) 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
Description copied from interface:SynchronizableContentsCollection
Gets 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
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, throws ExceptionObject> additionalParameters, boolean create, Logger logger) Fill the content with remote values.- Parameters:
remoteValues
- The remote valuescontent
- The content to synchronizeadditionalParameters
- Additional parameterscreate
-true
if content is creating, false if it is updatedlogger
- The logger- Returns:
true
if the content has been modified,false
otherwise- Throws:
Exception
- if an error occurs
-
_editContent
protected boolean _editContent(WorkflowAwareContent content, Optional<View> view, Map<String, Object> values, Map<String, throws com.opensymphony.workflow.WorkflowExceptionObject> additionalParameters, boolean create, Set<String> notSynchronizedContentIds, Logger logger) Synchronize the content with given values.- Parameters:
content
- The content to synchronizeview
- the view containing the item to editvalues
- the valuesadditionalParameters
- Additional parameterscreate
-true
if 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:
true
if the content has been modified,false
otherwise- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occurs
-
_getEditInputs
protected Map<String,Object> _getEditInputs(WorkflowAwareContent content, Optional<View> view, Map<String, Object> values, Map<String, Object> additionalParameters, boolean create, Set<String> notSynchronizedContentIds, Logger logger) Get the inputs for edit content function.- Parameters:
content
- The content to synchronizeview
- the view containing the item to editvalues
- the valuesadditionalParameters
- Additional parameterscreate
-true
if 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:
- the input parameters
-
_addEditInputsForSCC
protected void _addEditInputsForSCC(Map<String, Object> inputs, WorkflowAwareContent content, Logger logger) Add the inputs specific for the SCC to the inputs for edit content function.- Parameters:
inputs
- The inputs to completecontent
- The content to synchronizelogger
- The logger
-
_getEditInputsContextParameters
protected Map<String,Object> _getEditInputsContextParameters(Optional<View> view, Map<String, Object> values, boolean create) Get the context parameters to add to inputs for edit content function- Parameters:
view
- the view containing the item to editvalues
- the valuescreate
-true
if content is creating,false
if it is updated- Returns:
- the context parameters
-
validateContent
Validates a content after import- Parameters:
content
- The content to validatelogger
- The logger
-
search
public Map<String,Map<String, searchObject>> (Map<String, Object> searchParameters, int offset, int limit, List<Object> sort, Logger logger) Description copied from interface:SynchronizableContentsCollection
Search 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, internalSearchObject>> (Map<String, Object> searchParameters, int offset, int limit, List<Object> sort, 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, getTransformedRemoteValuesList<Object>>> (Map<String, Object> searchParameters, Logger logger) Search values and return the result organized by attributes and transformed by theSynchronizingContentOperator
if 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, getRemoteValuesList<Object>>> (Map<String, Object> searchParameters, 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, _transformRemoteValuesList<Object>>> (Map<String, Map<String, List<Object>>> remoteValues, Logger logger) Transform the given remote values by theSynchronizingContentOperator
if 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, Logger logger) Retrieves additional values to synchronize for a content- Parameters:
idValue
- id value of the contentcontent
- The contentadditionalParameters
- Additional parameterscreate
-true
if the content has been newly created,false
otherwiselogger
- The logger- Returns:
- the values to add
-
getNotSynchronizedRelatedContentIds
protected Set<String> getNotSynchronizedRelatedContentIds(Content content, Map<String, Object> contentValues, Map<String, Object> additionalParameters, String lang, 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, Logger logger) throws Exception Description copied from interface:SynchronizableContentsCollection
Method 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
Description copied from interface:SynchronizableContentsCollection
Return 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, 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
List
of imported or synchronizedModifiableContent
-
_getContentsToRemove
Description copied from class:AbstractSynchronizableContentsCollection
Filter the contents to remove.- Specified by:
_getContentsToRemove
in classAbstractSynchronizableContentsCollection
- Parameters:
contents
- The list of all the available contents- Returns:
- The
List
ofContent
to remove.
-