|
Spring LDAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.ldap.core.support.DefaultIncrementalAttributesMapper
public class DefaultIncrementalAttributesMapper
Utility class that helps with reading all attribute values from Active Directory using Incremental Retrieval of Multi-valued Properties.
Example usage of this attribute mapper:
List values = DefaultIncrementalAttributeMapper.lookupAttributeValues(ldapTemplate, theDn, "oneAttribute"); Attributes attrs = DefaultIncrementalAttributeMapper.lookupAttributeValues(ldapTemplate, theDn, new Object[]{"oneAttribute", "anotherAttribute"});For greater control, e.g. explicitly specifying the requested page size, create and use an instance yourself:
IncrementalAttributesMapper incrementalAttributeMapper = new DefaultIncrementalAttributeMapper(10, "someAttribute"); while (incrementalAttributeMapper.hasMore()) { ldap.lookup(entrDn, incrementalAttributeMapper.getAttributesForLookup(), incrementalAttributeMapper); } List values = incrementalAttributeMapper.getValues("someAttribute");
NOTE: Instances of this class are highly stateful and must not be reused or shared between threads in any way.
NOTE: Instances of this class can only be used with lookups. No support is given for searches.
lookupAttributes(org.springframework.ldap.core.LdapOperations, javax.naming.Name, String[])
,
lookupAttributeValues(org.springframework.ldap.core.LdapOperations, javax.naming.Name, String)
Constructor Summary | |
---|---|
DefaultIncrementalAttributesMapper(int pageSize,
String attributeName)
Create an instance for the requested attribute with a specific page size. |
|
DefaultIncrementalAttributesMapper(int pageSize,
String[] attributeNames)
Create an instance for the requested attributes with a specific page size. |
|
DefaultIncrementalAttributesMapper(String attributeName)
Create an instance for the requested attribute. |
|
DefaultIncrementalAttributesMapper(String[] attributeNames)
Create an instance for the requested attributes. |
Method Summary | |
---|---|
String[] |
getAttributesForLookup()
Get properly formatted attributes for use in the next query. |
Attributes |
getCollectedAttributes()
Get all collected values for all managed attributes as an Attributes instance. |
List<Object> |
getValues(String attributeName)
Get all of the collected values for the specified attribute. |
boolean |
hasMore()
Check whether another query iteration is required to get all values for all attributes. |
static Attributes |
lookupAttributes(LdapOperations ldapOperations,
Name dn,
String attribute)
Lookup all values for the specified attribute, looping through the results incrementally if necessary. |
static Attributes |
lookupAttributes(LdapOperations ldapOperations,
Name dn,
String[] attributes)
Lookup all values for the specified attributes, looping through the results incrementally if necessary. |
static Attributes |
lookupAttributes(LdapOperations ldapOperations,
String dn,
String attribute)
Lookup all values for the specified attribute, looping through the results incrementally if necessary. |
static Attributes |
lookupAttributes(LdapOperations ldapOperations,
String dn,
String[] attributes)
Lookup all values for the specified attributes, looping through the results incrementally if necessary. |
static List<Object> |
lookupAttributeValues(LdapOperations ldapOperations,
Name dn,
String attribute)
Lookup all values for the specified attribute, looping through the results incrementally if necessary. |
static List<Object> |
lookupAttributeValues(LdapOperations ldapOperations,
String dn,
String attribute)
Lookup all values for the specified attribute, looping through the results incrementally if necessary. |
DefaultIncrementalAttributesMapper |
mapFromAttributes(Attributes attributes)
Goes through all of the attributes to record their values and figure out whether a new query iteration is needed to get more values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultIncrementalAttributesMapper(String attributeName)
attributeName
- the name of the attribute that this instance handles.
This is the attribute name that will be requested, and whose
values are managed.public DefaultIncrementalAttributesMapper(String[] attributeNames)
attributeNames
- the name of the attributes that this instance handles.
These are the attribute names that will be requested, and whose
values are managed.public DefaultIncrementalAttributesMapper(int pageSize, String attributeName)
pageSize
- the requested page size that will be included in range query attribute names.attributeName
- the name of the attribute that this instance handles.
This is the attribute name that will be requested, and whose
values are managed.public DefaultIncrementalAttributesMapper(int pageSize, String[] attributeNames)
pageSize
- the requested page size that will be included in range query attribute names.attributeNames
- the name of the attributes that this instance handles.
These are the attribute names that will be requested, and whose
values are managed.Method Detail |
---|
public final DefaultIncrementalAttributesMapper mapFromAttributes(Attributes attributes) throws NamingException
IncrementalAttributesMapper
mapFromAttributes
in interface AttributesMapper<DefaultIncrementalAttributesMapper>
mapFromAttributes
in interface IncrementalAttributesMapper<DefaultIncrementalAttributesMapper>
attributes
- attributes from a SearchResult.
NamingException
- if any error occurs mapping the attributespublic final List<Object> getValues(String attributeName)
IncrementalAttributesMapper
getValues
in interface IncrementalAttributesMapper<DefaultIncrementalAttributesMapper>
attributeName
- the attribute to get values for.
null
if the requested attribute has not been returned by the server (attribute did not exist).public final Attributes getCollectedAttributes()
IncrementalAttributesMapper
getCollectedAttributes
in interface IncrementalAttributesMapper<DefaultIncrementalAttributesMapper>
public final boolean hasMore()
IncrementalAttributesMapper
hasMore
in interface IncrementalAttributesMapper<DefaultIncrementalAttributesMapper>
true
if there are more values for at least one of the managed attributes,
false
otherwise.public final String[] getAttributesForLookup()
IncrementalAttributesMapper
getAttributesForLookup
in interface IncrementalAttributesMapper<DefaultIncrementalAttributesMapper>
LdapTemplate.lookup(javax.naming.Name, String[], org.springframework.ldap.core.AttributesMapper)
in the next iteration.public static Attributes lookupAttributes(LdapOperations ldapOperations, String dn, String attribute)
ldapOperations
- The instance to use for performing the actual lookup.dn
- The distinguished name of the object to find.attribute
- name of the attribute to request.
null
, though the actual attribute may not be set if it was not
set on the requested object.public static Attributes lookupAttributes(LdapOperations ldapOperations, String dn, String[] attributes)
ldapOperations
- The instance to use for performing the actual lookup.dn
- The distinguished name of the object to find.attributes
- names of the attributes to request.
null
, though the actual attributes may not be set if they was not
set on the requested object.public static Attributes lookupAttributes(LdapOperations ldapOperations, Name dn, String attribute)
ldapOperations
- The instance to use for performing the actual lookup.dn
- The distinguished name of the object to find.attribute
- name of the attribute to request.
null
, though the actual attribute may not be set if it was not
set on the requested object.public static Attributes lookupAttributes(LdapOperations ldapOperations, Name dn, String[] attributes)
ldapOperations
- The instance to use for performing the actual lookup.dn
- The distinguished name of the object to find.attributes
- names of the attributes to request.
null
, though the actual attributes may not be set if they was not
set on the requested object.public static List<Object> lookupAttributeValues(LdapOperations ldapOperations, String dn, String attribute)
ldapOperations
- The instance to use for performing the actual lookup.dn
- The distinguished name of the object to find.attribute
- name of the attribute to request.
null
, an empty list indicates that the attribute was not set or empty.public static List<Object> lookupAttributeValues(LdapOperations ldapOperations, Name dn, String attribute)
ldapOperations
- The instance to use for performing the actual lookup.dn
- The distinguished name of the object to find.attribute
- name of the attribute to request.
null
, an empty list indicates that the attribute was not set or empty.
|
Spring LDAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |