Class LDAPCollectionHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.util.ldap.AbstractLDAPConnector
-
- org.ametys.plugins.contentio.synchronize.impl.LDAPCollectionHelper
-
- All Implemented Interfaces:
LogEnabled,Component,Serviceable
public class LDAPCollectionHelper extends AbstractLDAPConnector implements Component
Helper component forSynchronizableContentsCollections which need to access a LDAP
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentTypeExtensionPoint_contentTypeEPThe content type extension pointstatic StringROLEAvalon Role-
Fields inherited from class org.ametys.core.util.ldap.AbstractLDAPConnector
__DEFAULT_PAGE_SIZE, _ldapAdminPassword, _ldapAdminRelativeDN, _ldapAliasDerefMode, _ldapAuthenticationMethod, _ldapBaseDN, _ldapFollowReferrals, _ldapUrl, _ldapUseSSL, _pagingSupported, _serverSideSorting
-
-
Constructor Summary
Constructors Constructor Description LDAPCollectionHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_cleanup(Context context, NamingEnumeration result, org.slf4j.Logger logger)Clean a connection to a ldap server.void_delayedInitialize(String dataSourceId)Call this method with the datasource id to initialize this componentprotected Object_getIdValue(String idKey, SearchResult entry, org.slf4j.Logger logger)Gets id value from a ldap entryprotected int_getScope(String scopeStr)Get the scope as an integer (handlable by the SearchControls) from the scope string.protected SearchControls_getSearchControls(Map<String,List<String>> mapping, String searchScope)Get the LDAP search controls.intgetNbErrors()Returns the number of errors which occuredsearch(String, int, String, String, String, int, int, Map, String, Logger)booleanhasGlobalError()Returns true if the a global error occured duringsearch(String, int, String, String, String, int, int, Map, String, Logger)Map<String,Map<String,Object>>search(String collectionId, int pageSize, String relativeDN, String filter, String searchScope, int offset, int limit, Map<String,List<String>> mapping, String idKey, org.slf4j.Logger logger)Search over the LDAP the data from the filter.voidservice(ServiceManager serviceManager)voidtransformTypedAttributes(Map<String,Map<String,List<Object>>> results, String contentTypeId, Set<String> allAttributes)Transform date and datetime attributes on each result line from timestamp to LocalDate (date) or ZonedDateTime (datetime)-
Methods inherited from class org.ametys.core.util.ldap.AbstractLDAPConnector
_cleanup, _getConfigParameter, _getContextEnv, _getFilter, _getRootContextEnv, _getSearchScope, _hasMoreEntries, _search, _search, _search, _search, _setResultsControls, _testConnectionsPooled, _testPagingSupported, getSortByFields, isPagingSupported
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_contentTypeEP
protected ContentTypeExtensionPoint _contentTypeEP
The content type extension point
-
-
Constructor Detail
-
LDAPCollectionHelper
public LDAPCollectionHelper()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classAbstractLDAPConnector- Throws:
ServiceException
-
_delayedInitialize
public void _delayedInitialize(String dataSourceId) throws Exception
Description copied from class:AbstractLDAPConnectorCall this method with the datasource id to initialize this component- Overrides:
_delayedInitializein classAbstractLDAPConnector- Parameters:
dataSourceId- The id of the datasource- Throws:
Exception- If an error occurs.
-
search
public Map<String,Map<String,Object>> search(String collectionId, int pageSize, String relativeDN, String filter, String searchScope, int offset, int limit, Map<String,List<String>> mapping, String idKey, org.slf4j.Logger logger)
Search over the LDAP the data from the filter. After calling this method, call the methodsgetNbErrors()andhasGlobalError()to know about error which occured.- Parameters:
collectionId- The id of the collection being synchronizedpageSize- The page size for the searchrelativeDN- the name of the context or object to searchfilter- the filter expression to use for the searchsearchScope- The search scopeoffset- Begin of the searchlimit- Number of resultsmapping- The mapping for retrieving the remote values (keys are metadata paths)idKey- The key where to search the id value of the contentlogger- The logger- Returns:
- A map containing the content ids (keys) to import with their remote values (key is attribute, value is the remote value).
-
getNbErrors
public int getNbErrors()
Returns the number of errors which occuredsearch(String, int, String, String, String, int, int, Map, String, Logger)- Returns:
- the number of errors which occured
search(String, int, String, String, String, int, int, Map, String, Logger)
-
hasGlobalError
public boolean hasGlobalError()
Returns true if the a global error occured duringsearch(String, int, String, String, String, int, int, Map, String, Logger)- Returns:
- true if the a global error occured during
search(String, int, String, String, String, int, int, Map, String, Logger)
-
_getSearchControls
protected SearchControls _getSearchControls(Map<String,List<String>> mapping, String searchScope) throws ProcessingException
Get the LDAP search controls.- Parameters:
mapping- The mappingsearchScope- The search scope- Returns:
- the search controls.
- Throws:
ProcessingException- if the scope is not valid
-
_getScope
protected int _getScope(String scopeStr) throws ProcessingException
Get the scope as an integer (handlable by the SearchControls) from the scope string.- Parameters:
scopeStr- the scope string.- Returns:
- the scope as an integer.
- Throws:
ProcessingException- if the given scope is not valid
-
_getIdValue
protected Object _getIdValue(String idKey, SearchResult entry, org.slf4j.Logger logger) throws NamingException
Gets id value from a ldap entry- Parameters:
idKey- The key where to search the id valueentry- The ldap entrylogger- The logger- Returns:
- The attribute value
- Throws:
NamingException- if a ldap query error occurred
-
_cleanup
protected void _cleanup(Context context, NamingEnumeration result, org.slf4j.Logger logger)
Clean a connection to a ldap server.- Parameters:
context- The connection to the database to close.result- The result to close.logger- The logger
-
transformTypedAttributes
public void transformTypedAttributes(Map<String,Map<String,List<Object>>> results, String contentTypeId, Set<String> allAttributes)
Transform date and datetime attributes on each result line from timestamp to LocalDate (date) or ZonedDateTime (datetime)- Parameters:
results- The results from LDAP sourcecontentTypeId- Content type ID from which attributes come fromallAttributes- All mapped attributes
-
-