KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ca > directory > jxplorer > search > SearchExecute


1 package com.ca.directory.jxplorer.search;
2
3 import com.ca.commons.cbutil.*;
4
5 import java.util.*;
6 import java.util.logging.Logger JavaDoc;
7
8 import javax.naming.*;
9 import javax.naming.directory.*;
10
11 import com.ca.directory.jxplorer.*;
12 import com.ca.directory.jxplorer.tree.*;
13 import com.ca.directory.jxplorer.broker.*;
14 import com.ca.commons.naming.*;
15
16 /**
17 * This executes a search request from a particular base DN, using
18 * a particular filter, returning a particular set of attributes.
19 */

20
21 public class SearchExecute
22 {
23     private static Logger JavaDoc log = Logger.getLogger(SearchExecute.class.getName());
24
25     private SearchExecute() {} // class should not be instantiated
26

27    /**
28     * This executes a search request from a particular base DN, using
29     * a particular filter, returning a particular set of attributes.
30     * @param searchTree the search tree.
31     * @param baseDN the DN that the search will begin from.
32     * @param filter the LDAP search filter to be used.
33     * @param attribs a list of attributes the search should return (only these attributes, not the whole entry). //TE: TO DO...returning attributes... (should be a String[]).
34     * @param searchLevel either 0 = Search Base Object, 1 = Search Next Level or 2 = Search Full Subtree.
35     * @param searchBroker the broker that will fire off the search.
36     * .
37     */

38     
39     public static void run(SmartTree searchTree, DN baseDN, String JavaDoc filter, String JavaDoc[] attribs, int searchLevel, JNDIBroker searchBroker)
40     {
41         switch (searchLevel) //TE: info messages...
42
{
43             case 0: { log.info( "search: [ " + baseDN + "] [" + filter + "] [baseObject] "); break; }
44             case 1: { log.info( "search: [ " + baseDN + "] [" + filter + "] [singleLevel] "); break; }
45             case 2: { log.info( "search: [ " + baseDN + "] [" + filter + "] [wholeSubtree] "); break; }
46         }
47         
48         searchTree.entry=null; //TE: so that the last entry is cleared from attribute editor pane.
49
searchTree.clearTree();
50             
51         if ((baseDN.isEmpty()==false) && (baseDN.getRootRDN().equals("")))
52             baseDN.remove(0);
53                        
54         String JavaDoc baseDNString = baseDN.toString();
55         
56         searchBroker.search(baseDN, filter, searchLevel, attribs);
57     }
58 }
Popular Tags