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 private static int__LDAP_DEFAULT_PAGE_SIZEprotected static String__PARAM_ADDITIONAL_SEARCH_FILTERName of parameter holding the additional search filterprotected static String__PARAM_EMAIL_METADATA_NAMEName of parameter for the email metadataprotected static String__PARAM_FIRSTNAME_METADATA_NAMEName of parameter for the firstname metadataprotected static String__PARAM_LASTNAME_METADATA_NAMEName of parameter for the lastname metadataprotected static String__PARAM_LOGIN_METADATA_NAMEName of parameter for the login metadataprotected 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_METADATA_REFName of parameter into mapping holding the path of metadataprotected 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 Set<String>_extFieldsExternal fieldsprotected JSONUtils_jsonUtilsThe JSON utilsprotected static org.slf4j.Logger_LOGGERThe loggerprotected ServiceManager_managerThe service managerprotected Map<String,Map<String,List<String>>>_mappingMapping of the metadata with source dataprotected Set<String>_syncFieldsSynchronized fieldsprotected UserPopulationDAO_userPopulationDAOThe DAO for user populationsprotected UserSCCHelper_userSCCHelperThe user SCC helper-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_contentHelper, _synchronizingContentOperatorEP
-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_contentTypeEP, _currentUserProvider, _hasGlobalError, _i18nUtils, _nbCreatedContents, _nbDeletedContents, _nbError, _nbNotChangedContents, _nbSynchronizedContents, _observationManager, _synchroComponent, SCC_UNIQUE_ID
-
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_contentDAO, _contentPrefix, _contentType, _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_PROPERTY
-
-
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 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 voidconfigureDataSource(Configuration configuration)Configure the data source parameters.protected voidconfigureSearchModel()Configure the search model used by SCCSearchTool.StringgetAdditionalSearchFilter()Get the additional filter for searchingStringgetEmailMetadata()Get the metadata name for the emailSet<String>getExternalOnlyFields(Map<String,Object> additionalParameters)Get the path of field that are valued externally only.StringgetFirstNameMetadata()Get the metadata name for the first nameStringgetIdField()Get the path of metadata holding the unique identifierStringgetLastNameMetadata()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)StringgetLoginMetadata()Get the metadata name for the loginStringgetPopulationId()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 metadatabooleanhandleRightAssignmentContext()Return true if aRightAssignmentContextshould be automatically generated for the contents of this SCCprotected 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.voidservice(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, deleteUnexistingContents, empty, 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
-
-
-
-
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:
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<ModifiableDefaultContent> _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> 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:AbstractSimpleSynchronizableContentsCollectionSearch values and return the result without any treatment.- Specified by:
internalSearchin 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:AbstractSimpleSynchronizableContentsCollectionFill the content with remote values.- Overrides:
_fillContentin classAbstractSimpleSynchronizableContentsCollection- 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
-
getRemoteValues
protected Map<String,Map<String,List<Object>>> getRemoteValues(Map<String,Object> parameters, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollectionSearch values and return the result organized by metadata- Specified by:
getRemoteValuesin 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:SynchronizableContentsCollectionGet 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:SynchronizableContentsCollectionGet 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:SynchronizableContentsCollectionGet 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: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
-
-