Class RecursiveSearchResultHandler

  • All Implemented Interfaces:
    ExtendedSearchResultHandler, ResultHandler<javax.naming.directory.SearchResult,​javax.naming.directory.SearchResult>, SearchResultHandler

    public class RecursiveSearchResultHandler
    extends CopySearchResultHandler
    implements ExtendedSearchResultHandler
    RecursiveSearchResultHandler recursively searches based on a supplied attribute and merges those results into the original result set. For the following LDIF:
       dn: uugid=group1,ou=groups,dc=vt,dc=edu
       uugid: group1
       member: uugid=group2,ou=groups,dc=vt,dc=edu
    
       dn: uugid=group2,ou=groups,dc=vt,dc=edu
       uugid: group2
     

    With the following code:

       RecursiveSearchResultHandler rsh = new RecurseSearchResultHandler(
         ldap, "member", new String[]{"uugid"});
     

    Will produce this result for the query (uugid=group1):

       dn: uugid=group1,ou=groups,dc=vt,dc=edu
       uugid: group1
       uugid: group2
       member: uugid=group2,ou=groups,dc=vt,dc=edu
     
    Version:
    $Revision: 1330 $ $Date: 2010-05-24 00:10:53 +0200 (Mon, 24 May 2010) $
    Author:
    Middleware Services
    • Constructor Detail

      • RecursiveSearchResultHandler

        public RecursiveSearchResultHandler()
        Default constructor.
      • RecursiveSearchResultHandler

        public RecursiveSearchResultHandler​(java.lang.String searchAttr,
                                            java.lang.String[] mergeAttrs)
        Creates a new RecursiveAttributeHandler with the supplied search attribute and merge attributes.
        Parameters:
        searchAttr - String
        mergeAttrs - String[]
      • RecursiveSearchResultHandler

        public RecursiveSearchResultHandler​(Ldap l,
                                            java.lang.String searchAttr,
                                            java.lang.String[] mergeAttrs)
        Creates a new RecursiveAttributeHandler with the supplied ldap, search attribute, and merge attributes.
        Parameters:
        l - Ldap
        searchAttr - String
        mergeAttrs - String[]
    • Method Detail

      • getSearchAttribute

        public java.lang.String getSearchAttribute()
        Returns the attribute name that will be recursively searched on.
        Returns:
        String attribute name
      • setSearchAttribute

        public void setSearchAttribute​(java.lang.String s)
        Sets the attribute name that will be recursively searched on.
        Parameters:
        s - String
      • getMergeAttributes

        public java.lang.String[] getMergeAttributes()
        Returns the attribute names that will be merged by the recursive search.
        Returns:
        String[] attribute names
      • setMergeAttributes

        public void setMergeAttributes​(java.lang.String[] s)
        Sets the attribute name that will be merged by the recursive search.
        Parameters:
        s - String[]
      • initalizeReturnAttributes

        protected void initalizeReturnAttributes()
        Initializes the return attributes array. Must be called after both searchAttribute and mergeAttributes have been set.
      • process

        public java.util.List<javax.naming.directory.SearchResult> process​(SearchCriteria sc,
                                                                           javax.naming.NamingEnumeration<? extends javax.naming.directory.SearchResult> en,
                                                                           java.lang.Class<?>[] ignore)
                                                                    throws javax.naming.NamingException
        This will enumerate through the supplied NamingEnumeration and return a List of those results. The results are unaltered and the dn is ignored. Any exceptions passed into this method will be ignored and results will be returned as if no exception occurred.
        Specified by:
        process in interface ResultHandler<javax.naming.directory.SearchResult,​javax.naming.directory.SearchResult>
        Overrides:
        process in class AbstractResultHandler<javax.naming.directory.SearchResult,​javax.naming.directory.SearchResult>
        Parameters:
        sc - SearchCriteria used to find enumeration
        en - NamingEnumeration LDAP results
        ignore - Class[] of exception types to ignore
        Returns:
        List - LDAP results
        Throws:
        javax.naming.NamingException - if the LDAP returns an error
      • process

        public java.util.List<javax.naming.directory.SearchResult> process​(SearchCriteria sc,
                                                                           java.util.List<? extends javax.naming.directory.SearchResult> l)
                                                                    throws javax.naming.NamingException
        This will enumerate through the supplied List and return a List of those results. The results are unaltered and the dn is ignored.
        Specified by:
        process in interface ResultHandler<javax.naming.directory.SearchResult,​javax.naming.directory.SearchResult>
        Overrides:
        process in class AbstractResultHandler<javax.naming.directory.SearchResult,​javax.naming.directory.SearchResult>
        Parameters:
        sc - SearchCriteria used to find enumeration
        l - List LDAP results
        Returns:
        List - LDAP results
        Throws:
        javax.naming.NamingException - if the LDAP returns an error