src/share/classes/com/sun/jndi/url/ldap/ldapURLContext.java

Print this page
rev 10430 : imported patch typos


 545         }
 546     }
 547 
 548     // divert the search operation when name has a single component
 549     public NamingEnumeration<SearchResult> search(Name name,
 550         String filterExpr,
 551         Object[] filterArgs,
 552         SearchControls cons)
 553         throws NamingException {
 554 
 555         if (name.size() == 1) {
 556             return search(name.get(0), filterExpr, filterArgs, cons);
 557         } else if (LdapURL.hasQueryComponents(name.get(0))) {
 558             throw new InvalidNameException(name.toString());
 559         } else {
 560             return super.search(name, filterExpr, filterArgs, cons);
 561         }
 562     }
 563 
 564     // Search using the LDAP URL in name.
 565     // LDAP URL query components override the search argments.
 566     private NamingEnumeration<SearchResult> searchUsingURL(String name)
 567         throws NamingException {
 568 
 569         LdapURL url = new LdapURL(name);
 570 
 571         ResolveResult res = getRootURLContext(name, myEnv);
 572         DirContext ctx = (DirContext)res.getResolvedObj();
 573         try {
 574             return ctx.search(res.getRemainingName(),
 575                               setFilterUsingURL(url),
 576                               setSearchControlsUsingURL(url));
 577         } finally {
 578             ctx.close();
 579         }
 580     }
 581 
 582     /*
 583      * Initialize a String filter using the LDAP URL filter component.
 584      * If filter is not present in the URL it is initialized to its default
 585      * value as specified in RFC-2255.




 545         }
 546     }
 547 
 548     // divert the search operation when name has a single component
 549     public NamingEnumeration<SearchResult> search(Name name,
 550         String filterExpr,
 551         Object[] filterArgs,
 552         SearchControls cons)
 553         throws NamingException {
 554 
 555         if (name.size() == 1) {
 556             return search(name.get(0), filterExpr, filterArgs, cons);
 557         } else if (LdapURL.hasQueryComponents(name.get(0))) {
 558             throw new InvalidNameException(name.toString());
 559         } else {
 560             return super.search(name, filterExpr, filterArgs, cons);
 561         }
 562     }
 563 
 564     // Search using the LDAP URL in name.
 565     // LDAP URL query components override the search arguments.
 566     private NamingEnumeration<SearchResult> searchUsingURL(String name)
 567         throws NamingException {
 568 
 569         LdapURL url = new LdapURL(name);
 570 
 571         ResolveResult res = getRootURLContext(name, myEnv);
 572         DirContext ctx = (DirContext)res.getResolvedObj();
 573         try {
 574             return ctx.search(res.getRemainingName(),
 575                               setFilterUsingURL(url),
 576                               setSearchControlsUsingURL(url));
 577         } finally {
 578             ctx.close();
 579         }
 580     }
 581 
 582     /*
 583      * Initialize a String filter using the LDAP URL filter component.
 584      * If filter is not present in the URL it is initialized to its default
 585      * value as specified in RFC-2255.