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 ofSynchronizableContentsCollection
to be synchronized with aUserPopulation
of the CMS.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
__LDAP_DEFAULT_PAGE_SIZE
protected static String
__PARAM_ADDITIONAL_SEARCH_FILTER
Name of parameter holding the additional search filterprotected static String
__PARAM_EMAIL_METADATA_NAME
Name of parameter for the email metadataprotected static String
__PARAM_FIRSTNAME_METADATA_NAME
Name of parameter for the firstname metadataprotected static String
__PARAM_LASTNAME_METADATA_NAME
Name of parameter for the lastname metadataprotected static String
__PARAM_LOGIN_METADATA_NAME
Name of parameter for the login metadataprotected static String
__PARAM_MAPPING
Name of parameter holding the fields mappingprotected static String
__PARAM_MAPPING_ATTRIBUTE_PREFIX
Name of parameter into mapping holding the remote attributeprotected static String
__PARAM_MAPPING_METADATA_REF
Name of parameter into mapping holding the path of metadataprotected static String
__PARAM_MAPPING_SYNCHRO
Name of parameter into mapping holding the synchronized propertyprotected static String
__PARAM_POPULATION_ID
Name of parameter holding the id of populationprotected DeleteUserComponent
_deleteUserComponent
The delete user componentprotected Set<String>
_extFields
External fieldsprotected JSONUtils
_jsonUtils
The JSON utilsprotected static org.slf4j.Logger
_LOGGER
The loggerprotected ServiceManager
_manager
The service managerprotected Map<String,Map<String,List<String>>>
_mapping
Mapping of the metadata with source dataprotected Set<String>
_syncFields
Synchronized fieldsprotected UserPopulationDAO
_userPopulationDAO
The DAO for user populationsprotected UserSCCHelper
_userSCCHelper
The user SCC helper-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_contentHelper, _sccHelper, _synchronizingContentOperatorEP
-
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 UserPopulationSynchronizableContentsCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_fillContent(Map<String,List<Object>> remoteValues, ModifiableDefaultContent content, boolean create, org.slf4j.Logger logger)
Fill the content with remote values.private Set<String>
_getUserDirectoryKeys(Map<String,Object> field, String prefix)
protected List<ModifiableDefaultContent>
_internalPopulate(org.slf4j.Logger logger)
Internal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)
private Map<String,Map<String,Object>>
_internalSearch(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger, boolean getRemoteValues)
Internal searchprotected void
configureDataSource(Configuration configuration)
Configure the data source parameters.protected void
configureSearchModel()
Configure the search model used by SCCSearchTool.protected void
deleteUnexistingContents(org.slf4j.Logger logger)
Delete contents created by a previous synchronization which does not exist anymore in remote sourceString
getAdditionalSearchFilter()
Get the additional filter for searchingString
getEmailMetadata()
Get the metadata name for the emailSet<String>
getExternalOnlyFields(Map<String,Object> additionalParameters)
Get the path of field that are valued externally only.String
getFirstNameMetadata()
Get the metadata name for the first nameString
getIdField()
Get the path of metadata holding the unique identifierString
getLastNameMetadata()
Get the metadata name for the last nameSet<String>
getLocalAndExternalFields(Map<String,Object> additionalParameters)
Get the path of tri-state fields (with local and external values)String
getLoginMetadata()
Get the metadata name for the loginString
getPopulationId()
Get the id of the user populationprotected Map<String,Map<String,List<Object>>>
getRemoteValues(Map<String,Object> parameters, org.slf4j.Logger logger)
Search values and return the result organized by metadataprotected 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.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> parameters, int offset, int limit, org.slf4j.Logger logger, boolean getRemoteValues)
Search contents from a LDAP user directory of the population.void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_getContentsToRemove, _getIdFieldValue, _handleContent, _importContent, _importOrSynchronizeContent, _importOrSynchronizeContent, _importOrSynchronizeContents, _isHandled, _synchronizeContent, additionalCommonOperations, additionalImportOperations, additionalSynchronizeOperations, configure, createContentAction, getContent, getTotalCount, getTransformedRemoteValues, importContent, populate, search, synchronizeContent, updateSyncInformations, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_getContentPathQuery, _getExpressionsList, _getMetadataHolder, _isParamNotEmpty, _removeEmptyParameters, _removeMetadataIfExists, _synchronizeMetadata, _updateRelation, _updateRelation, applyChanges, applyChanges, createContentAction, sendErrorMail, updateSCCProperty, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_parseLanguages, _parseParameters, 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
handleRightAssignmentContext
-
-
-
-
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_LOGIN_METADATA_NAME
protected static final String __PARAM_LOGIN_METADATA_NAME
Name of parameter for the login metadata- See Also:
- Constant Field Values
-
__PARAM_FIRSTNAME_METADATA_NAME
protected static final String __PARAM_FIRSTNAME_METADATA_NAME
Name of parameter for the firstname metadata- See Also:
- Constant Field Values
-
__PARAM_LASTNAME_METADATA_NAME
protected static final String __PARAM_LASTNAME_METADATA_NAME
Name of parameter for the lastname metadata- See Also:
- Constant Field Values
-
__PARAM_EMAIL_METADATA_NAME
protected static final String __PARAM_EMAIL_METADATA_NAME
Name of parameter for the email metadata- 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_METADATA_REF
protected static final String __PARAM_MAPPING_METADATA_REF
Name of parameter into mapping holding the path of metadata- 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
-
__LDAP_DEFAULT_PAGE_SIZE
private static final int __LDAP_DEFAULT_PAGE_SIZE
- See Also:
- Constant Field Values
-
_userPopulationDAO
protected UserPopulationDAO _userPopulationDAO
The DAO for user populations
-
_manager
protected ServiceManager _manager
The service manager
-
_jsonUtils
protected JSONUtils _jsonUtils
The JSON utils
-
_userSCCHelper
protected UserSCCHelper _userSCCHelper
The user SCC helper
-
_deleteUserComponent
protected DeleteUserComponent _deleteUserComponent
The delete user component
-
_mapping
protected Map<String,Map<String,List<String>>> _mapping
Mapping of the metadata with source data
-
_syncFields
protected Set<String> _syncFields
Synchronized fields
-
_extFields
protected Set<String> _extFields
External fields
-
-
Constructor Detail
-
UserPopulationSynchronizableContentsCollection
public UserPopulationSynchronizableContentsCollection()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractSimpleSynchronizableContentsCollection
- Throws:
ServiceException
-
configureDataSource
protected void configureDataSource(Configuration configuration) throws ConfigurationException
Description copied from class:AbstractStaticSynchronizableContentsCollection
Configure the data source parameters.- Specified by:
configureDataSource
in classAbstractStaticSynchronizableContentsCollection
- Parameters:
configuration
- Configuration to read- Throws:
ConfigurationException
- If an error occurs
-
configureSearchModel
protected void configureSearchModel()
Description copied from class:AbstractStaticSynchronizableContentsCollection
Configure the search model used by SCCSearchTool.- Specified by:
configureSearchModel
in classAbstractStaticSynchronizableContentsCollection
-
_internalPopulate
protected List<ModifiableDefaultContent> _internalPopulate(org.slf4j.Logger logger)
Description copied from class:AbstractSynchronizableContentsCollection
Internal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)
- Overrides:
_internalPopulate
in 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> parameters, 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 directoryparameters
- Parameters for the searchoffset
- Begin of the searchlimit
- Number of resultslogger
- The loggergetRemoteValues
- if true, values are organized by the metadata mapping- Returns:
- Contents found in LDAP
-
internalSearch
protected Map<String,Map<String,Object>> internalSearch(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Search values and return the result without any treatment.- Specified by:
internalSearch
in classAbstractSimpleSynchronizableContentsCollection
- 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.
-
_internalSearch
private Map<String,Map<String,Object>> _internalSearch(Map<String,Object> parameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger, boolean getRemoteValues)
Internal search- Parameters:
parameters
- the search parametersoffset
- starting indexlimit
- max number of resultssort
- not usedlogger
- the loggergetRemoteValues
- to get remote values or not- Returns:
- The search result
-
_fillContent
protected boolean _fillContent(Map<String,List<Object>> remoteValues, ModifiableDefaultContent content, boolean create, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Fill the content with remote values.- Overrides:
_fillContent
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
remoteValues
- The remote valuescontent
- The content to synchronizecreate
-true
if content is creating, false if it is updatedlogger
- The logger- Returns:
true
if changes were made
-
getRemoteValues
protected Map<String,Map<String,List<Object>>> getRemoteValues(Map<String,Object> parameters, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Search values and return the result organized by metadata- Specified by:
getRemoteValues
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
parameters
- Search parameters to restrict the searchlogger
- The logger- Returns:
- Map of results organized by metadata.
-
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:SynchronizableContentsCollection
Get the path of metadata holding the unique identifier- Returns:
- the path to the metadata. Can be null.
-
getLoginMetadata
public String getLoginMetadata()
Get the metadata name for the login- Returns:
- The the metadata name for the login
-
getFirstNameMetadata
public String getFirstNameMetadata()
Get the metadata name for the first name- Returns:
- The the metadata name for the first name
-
getLastNameMetadata
public String getLastNameMetadata()
Get the metadata name for the last name- Returns:
- The the metadata name for the last name
-
getEmailMetadata
public String getEmailMetadata()
Get the metadata name for the email- Returns:
- The the metadata name for the email
-
getAdditionalSearchFilter
public String getAdditionalSearchFilter()
Get the additional filter for searching- Returns:
- The additional filter for searching
-
getExternalOnlyFields
public Set<String> getExternalOnlyFields(Map<String,Object> additionalParameters)
Description copied from interface:SynchronizableContentsCollection
Get the path of field that are valued externally only.- Parameters:
additionalParameters
- Additional parameters- Returns:
- the external fields
-
getLocalAndExternalFields
public Set<String> getLocalAndExternalFields(Map<String,Object> additionalParameters)
Description copied from interface:SynchronizableContentsCollection
Get the path of tri-state fields (with local and external values)- Parameters:
additionalParameters
- Additional parameters- Returns:
- the synchronized fields
-
_getUserDirectoryKeys
private Set<String> _getUserDirectoryKeys(Map<String,Object> field, String prefix)
-
putIdParameter
protected Map<String,Object> putIdParameter(String idValue)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Set search parameters for the ID value.- Specified by:
putIdParameter
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
idValue
- Value to search- Returns:
- Map with the search parameters
-
deleteUnexistingContents
protected void deleteUnexistingContents(org.slf4j.Logger logger)
Description copied from class:AbstractSynchronizableContentsCollection
Delete contents created by a previous synchronization which does not exist anymore in remote source- Overrides:
deleteUnexistingContents
in classAbstractSynchronizableContentsCollection
- Parameters:
logger
- The logger
-
-