Class UserPopulationSynchronizableContentsCollection
- java.lang.Object
-
- org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
-
- org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
-
- org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
-
- org.ametys.plugins.userdirectory.synchronize.UserPopulationSynchronizableContentsCollection
-
- All Implemented Interfaces:
SynchronizableContentsCollection,Configurable,Serviceable
public class UserPopulationSynchronizableContentsCollection extends AbstractSimpleSynchronizableContentsCollection
Implementation ofSynchronizableContentsCollectionto be synchronized with aUserPopulationof the CMS.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String__PARAM_ADDITIONAL_SEARCH_FILTERName of parameter holding the additional search filterprotected static String__PARAM_EMAIL_ATTRIBUTE_NAMEName of parameter for the email attributeprotected static String__PARAM_FIRSTNAME_ATTRIBUTE_NAMEName of parameter for the firstname attributeprotected static String__PARAM_LASTNAME_ATTRIBUTE_NAMEName of parameter for the lastname attributeprotected static String__PARAM_MAPPINGName of parameter holding the fields mappingprotected static String__PARAM_MAPPING_ATTRIBUTE_PREFIXName of parameter into mapping holding the remote attributeprotected static String__PARAM_MAPPING_ATTRIBUTE_REFName of parameter into mapping holding the path of attributeprotected static String__PARAM_MAPPING_SYNCHROName of parameter into mapping holding the synchronized propertyprotected static String__PARAM_POPULATION_IDName of parameter holding the id of populationprotected DeleteUserComponent_deleteUserComponentThe delete user componentprotected JSONUtils_jsonUtilsThe JSON utilsprotected static org.slf4j.Logger_LOGGERThe loggerprotected ServiceManager_managerThe service managerprotected Map<String,Map<String,List<String>>>_mappingMapping of the attributes with source dataprotected Set<String>_syncFieldsSynchronized fieldsprotected UserPopulationDAO_userPopulationDAOThe DAO for user populations-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_contentHelper, _synchronizingContentOperatorEP
-
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 UserPopulationSynchronizableContentsCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int_deleteContents(List<Content> contentsToRemove, org.slf4j.Logger logger)Delete contents.protected List<ModifiableContent>_internalPopulate(org.slf4j.Logger logger)Internal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)protected voidconfigureDataSource(Configuration configuration)Configure the data source parameters.protected voidconfigureSearchModel()Configure the search model used by SCCSearchTool.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 contentStringgetAdditionalSearchFilter()Get the additional filter for searchingStringgetEmailAttributeName()Get the attribute name for the emailStringgetFirstNameAttributeName()Get the attribute name for the first nameStringgetIdField()Get the path of metadata holding the unique identifierStringgetLastNameAttributeName()Get the attribute name for the last nameSet<String>getLocalAndExternalFields(Map<String,Object> additionalParameters)Get the path of tri-state fields (with local and external values)StringgetLoginAttributeName()Get the attribute name for the loginStringgetPopulationId()Get the id of the user populationprotected Map<String,Map<String,List<Object>>>getRemoteValues(Map<String,Object> searchParameters, org.slf4j.Logger logger)Search values and return the result organized by attributesbooleanhandleRightAssignmentContext()Return true if aRightAssignmentContextshould be automatically generated for the contents of this SCCprotected 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.protected Map<String,Object>putIdParameter(String idValue)Set search parameters for the ID value.protected Map<String,Map<String,Object>>searchLDAP(LdapUserDirectory userDirectory, Map<String,Object> searchParameters, int offset, int limit, org.slf4j.Logger logger, boolean getRemoteValues)Search contents from a LDAP user directory of the population.voidservice(ServiceManager manager)-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_editContent, _fillContent, _getContentsToRemove, _handleContent, _importContent, _importOrSynchronizeContent, _importOrSynchronizeContent, _importOrSynchronizeContents, _isHandled, _synchronizeContent, _transformRemoteValues, configure, createContentAction, getContent, getNotSynchronizedRelatedContentIds, getTotalCount, getTransformedRemoteValues, importContent, populate, search, synchronizeContent, updateSyncInformations, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_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, 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
-
-
-
-
Field Detail
-
__PARAM_POPULATION_ID
protected static final String __PARAM_POPULATION_ID
Name of parameter holding the id of population- See Also:
- Constant Field Values
-
__PARAM_FIRSTNAME_ATTRIBUTE_NAME
protected static final String __PARAM_FIRSTNAME_ATTRIBUTE_NAME
Name of parameter for the firstname attribute- See Also:
- Constant Field Values
-
__PARAM_LASTNAME_ATTRIBUTE_NAME
protected static final String __PARAM_LASTNAME_ATTRIBUTE_NAME
Name of parameter for the lastname attribute- See Also:
- Constant Field Values
-
__PARAM_EMAIL_ATTRIBUTE_NAME
protected static final String __PARAM_EMAIL_ATTRIBUTE_NAME
Name of parameter for the email attribute- See Also:
- Constant Field Values
-
__PARAM_MAPPING
protected static final String __PARAM_MAPPING
Name of parameter holding the fields mapping- See Also:
- Constant Field Values
-
__PARAM_ADDITIONAL_SEARCH_FILTER
protected static final String __PARAM_ADDITIONAL_SEARCH_FILTER
Name of parameter holding the additional search filter- See Also:
- Constant Field Values
-
__PARAM_MAPPING_SYNCHRO
protected static final String __PARAM_MAPPING_SYNCHRO
Name of parameter into mapping holding the synchronized property- See Also:
- Constant Field Values
-
__PARAM_MAPPING_ATTRIBUTE_REF
protected static final String __PARAM_MAPPING_ATTRIBUTE_REF
Name of parameter into mapping holding the path of attribute- See Also:
- Constant Field Values
-
__PARAM_MAPPING_ATTRIBUTE_PREFIX
protected static final String __PARAM_MAPPING_ATTRIBUTE_PREFIX
Name of parameter into mapping holding the remote attribute- See Also:
- Constant Field Values
-
_LOGGER
protected static final org.slf4j.Logger _LOGGER
The logger
-
_userPopulationDAO
protected UserPopulationDAO _userPopulationDAO
The DAO for user populations
-
_manager
protected ServiceManager _manager
The service manager
-
_jsonUtils
protected JSONUtils _jsonUtils
The JSON utils
-
_deleteUserComponent
protected DeleteUserComponent _deleteUserComponent
The delete user component
-
_mapping
protected Map<String,Map<String,List<String>>> _mapping
Mapping of the attributes with source data
-
_syncFields
protected Set<String> _syncFields
Synchronized fields
-
-
Constructor Detail
-
UserPopulationSynchronizableContentsCollection
public UserPopulationSynchronizableContentsCollection()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classAbstractSimpleSynchronizableContentsCollection- Throws:
ServiceException
-
handleRightAssignmentContext
public boolean handleRightAssignmentContext()
Description copied from interface:SynchronizableContentsCollectionReturn true if aRightAssignmentContextshould be automatically generated for the contents of this SCC- Returns:
- true to automatically generate a
RightAssignmentContext. Return false if the rights of contents of this SCC are handle by its ownRightAssignmentContext
-
configureDataSource
protected void configureDataSource(Configuration configuration) throws ConfigurationException
Description copied from class:AbstractStaticSynchronizableContentsCollectionConfigure the data source parameters.- Specified by:
configureDataSourcein classAbstractStaticSynchronizableContentsCollection- Parameters:
configuration- Configuration to read- Throws:
ConfigurationException- If an error occurs
-
configureSearchModel
protected void configureSearchModel()
Description copied from class:AbstractStaticSynchronizableContentsCollectionConfigure the search model used by SCCSearchTool.- Specified by:
configureSearchModelin classAbstractStaticSynchronizableContentsCollection
-
_internalPopulate
protected List<ModifiableContent> _internalPopulate(org.slf4j.Logger logger)
Description copied from class:AbstractSynchronizableContentsCollectionInternal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)- Overrides:
_internalPopulatein classAbstractSimpleSynchronizableContentsCollection- Parameters:
logger- The logger- Returns:
- The list of created/synchronized contents
-
searchLDAP
protected Map<String,Map<String,Object>> searchLDAP(LdapUserDirectory userDirectory, Map<String,Object> searchParameters, int offset, int limit, org.slf4j.Logger logger, boolean getRemoteValues)
Search contents from a LDAP user directory of the population. To avoid code duplication and useless operations, we return aMap<String,Map<String,Object>> if getRemoteValues is set to false andMap<String,Map<String,List<Object>>> if remoteValues is true. Without this operation, we have to duplicate the code of searchLDAP and _internalSearch methods.- Parameters:
userDirectory- The LDAP user directorysearchParameters- Parameters for the searchoffset- Begin of the searchlimit- Number of resultslogger- The loggergetRemoteValues- iftrue, values are organized by the attribute mapping- Returns:
- Contents found in LDAP
-
internalSearch
protected Map<String,Map<String,Object>> internalSearch(Map<String,Object> searchParameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollectionSearch values and return the result without any treatment.- Specified by:
internalSearchin classAbstractSimpleSynchronizableContentsCollection- 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.
-
getRemoteValues
protected Map<String,Map<String,List<Object>>> getRemoteValues(Map<String,Object> searchParameters, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollectionSearch values and return the result organized by attributes- Specified by:
getRemoteValuesin classAbstractSimpleSynchronizableContentsCollection- Parameters:
searchParameters- Search parameters to restrict the searchlogger- The logger- Returns:
- Map of results organized by attributes.
-
getAdditionalAttributeValues
protected Map<String,Object> getAdditionalAttributeValues(String idValue, Content content, Map<String,Object> additionalParameters, boolean create, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollectionRetrieves additional values to synchronize for a content- Overrides:
getAdditionalAttributeValuesin classAbstractSimpleSynchronizableContentsCollection- 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
-
getPopulationId
public String getPopulationId()
Get the id of the user population- Returns:
- The id of user population
-
getIdField
public String getIdField()
Description copied from interface:SynchronizableContentsCollectionGet the path of metadata holding the unique identifier- Returns:
- the path to the metadata. Can be null.
-
getLoginAttributeName
public String getLoginAttributeName()
Get the attribute name for the login- Returns:
- The the attribute name for the login
-
getFirstNameAttributeName
public String getFirstNameAttributeName()
Get the attribute name for the first name- Returns:
- The the attribute name for the first name
-
getLastNameAttributeName
public String getLastNameAttributeName()
Get the attribute name for the last name- Returns:
- The the attribute name for the last name
-
getEmailAttributeName
public String getEmailAttributeName()
Get the attribute name for the email- Returns:
- The the attribute name for the email
-
getAdditionalSearchFilter
public String getAdditionalSearchFilter()
Get the additional filter for searching- Returns:
- The additional filter for searching
-
getLocalAndExternalFields
public Set<String> getLocalAndExternalFields(Map<String,Object> additionalParameters)
Description copied from interface:SynchronizableContentsCollectionGet the path of tri-state fields (with local and external values)- Parameters:
additionalParameters- Additional parameters- Returns:
- the synchronized fields
-
putIdParameter
protected Map<String,Object> putIdParameter(String idValue)
Description copied from class:AbstractSimpleSynchronizableContentsCollectionSet search parameters for the ID value.- Specified by:
putIdParameterin classAbstractSimpleSynchronizableContentsCollection- Parameters:
idValue- Value to search- Returns:
- Map with the search parameters
-
_deleteContents
protected int _deleteContents(List<Content> contentsToRemove, org.slf4j.Logger logger)
Description copied from class:AbstractSynchronizableContentsCollectionDelete contents.- Overrides:
_deleteContentsin classAbstractSynchronizableContentsCollection- Parameters:
contentsToRemove- List of contents to removelogger- The logger- Returns:
- the number of deleted contents
-
-