protected class JndiConnection.JndiSearchIterator extends java.lang.Object implements SearchIterator
| Modifier and Type | Field and Description |
|---|---|
private SearchRequest |
request
Search request.
|
private Response<java.lang.Void> |
response
Response data.
|
private ResultCode |
responseResultCode
Response result code.
|
private javax.naming.NamingEnumeration<javax.naming.directory.SearchResult> |
results
Results read from the search operation.
|
private javax.naming.ldap.LdapContext |
searchContext
Ldap context to search with.
|
private java.util.List<java.lang.String> |
searchReferences
Search reference URLs.
|
| Constructor and Description |
|---|
JndiSearchIterator(SearchRequest sr)
Creates a new jndi search iterator.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close any resources associated with this iterator.
|
protected java.lang.String |
formatDn(javax.naming.directory.SearchResult sr,
java.lang.String baseDn)
Returns a fully-qualified DN for the supplied search result.
|
Response<java.lang.Void> |
getResponse()
Returns the response data associated with this search or null if this iterator has more ldap entries to return.
|
protected javax.naming.directory.SearchControls |
getSearchControls(SearchRequest sr)
Returns a search controls object configured with the supplied search request.
|
protected java.lang.String |
getSearchDn(javax.naming.ldap.LdapContext ctx,
SearchRequest sr)
Determines the DN of the supplied search request.
|
protected int |
getSearchScope(SearchScope ss)
Returns the jndi integer constant for the supplied search scope.
|
boolean |
hasNext()
Returns true if the iteration has more elements.
|
protected ResultCode |
ignoreSearchException(ResultCode[] ignoreResultCodes,
javax.naming.NamingException e)
Determines whether the supplied naming exception should be ignored.
|
void |
initialize()
Initializes this jndi search iterator.
|
protected void |
initializeSearchContext(javax.naming.ldap.LdapContext ctx,
SearchRequest sr)
Adds any additional environment properties found in the supplied request to the supplied context.
|
SearchItem |
next()
Returns the next element in the iteration.
|
protected java.lang.String |
readCompositeName(java.lang.String s)
Uses a composite name to parse the supplied string.
|
protected java.lang.String[] |
readReferralUrls(javax.naming.ldap.LdapReferralException refEx)
Reads all referral URLs associated with this exception by invoking the search operation on the referral context
until all referrals have been read.
|
protected javax.naming.NamingEnumeration<javax.naming.directory.SearchResult> |
search(javax.naming.ldap.LdapContext ctx,
SearchRequest sr)
Executes
DirContext.search( javax.naming.Name, String, Object[], SearchControls). |
private final SearchRequest request
private Response<java.lang.Void> response
private ResultCode responseResultCode
private java.util.List<java.lang.String> searchReferences
private javax.naming.ldap.LdapContext searchContext
private javax.naming.NamingEnumeration<javax.naming.directory.SearchResult> results
public JndiSearchIterator(SearchRequest sr)
sr - search requestpublic void initialize()
throws LdapException
LdapException - if an error occursprotected void initializeSearchContext(javax.naming.ldap.LdapContext ctx,
SearchRequest sr)
throws javax.naming.NamingException
ctx - to initialize for searchingsr - to read properties fromjavax.naming.NamingException - if a property cannot be added to the contextprotected javax.naming.NamingEnumeration<javax.naming.directory.SearchResult> search(javax.naming.ldap.LdapContext ctx,
SearchRequest sr)
throws javax.naming.NamingException
DirContext.search( javax.naming.Name, String, Object[], SearchControls).ctx - to searchsr - to read properties fromjavax.naming.NamingException - if an error occursprotected javax.naming.directory.SearchControls getSearchControls(SearchRequest sr)
sr - search request containing configuration to create search controlsprotected int getSearchScope(SearchScope ss)
ss - search scopepublic boolean hasNext()
throws LdapException
SearchIteratorhasNext in interface SearchIteratorLdapException - if an error occurspublic SearchItem next() throws LdapException
SearchIteratornext in interface SearchIteratorLdapException - if an error occursprotected ResultCode ignoreSearchException(ResultCode[] ignoreResultCodes, javax.naming.NamingException e)
ignoreResultCodes - to match against the exceptione - naming exception to matchprotected java.lang.String[] readReferralUrls(javax.naming.ldap.LdapReferralException refEx)
refEx - to read URLs frompublic Response<java.lang.Void> getResponse()
SearchIteratorgetResponse in interface SearchIteratorprotected java.lang.String getSearchDn(javax.naming.ldap.LdapContext ctx,
SearchRequest sr)
throws javax.naming.NamingException
Context.getNameInNamespace() if it is
available, otherwise returns SearchRequest.getBaseDn().ctx - ldap context the search was performed onsr - search requestjavax.naming.NamingException - if an error occursprotected java.lang.String formatDn(javax.naming.directory.SearchResult sr,
java.lang.String baseDn)
throws javax.naming.NamingException
NameClassPair.getNameInNamespace(). Otherwise the behavior is controlled by JndiProviderConfig.getRemoveDnUrls().sr - to determine DN forbaseDn - that search was performed onjavax.naming.NamingException - if search result name cannot be formatted as a DNprotected java.lang.String readCompositeName(java.lang.String s)
throws javax.naming.InvalidNameException
s - composite name to readjavax.naming.InvalidNameException - if the supplied string is not a valid composite namepublic void close()
throws LdapException
SearchIteratorclose in interface SearchIteratorLdapException - if an error occurs