1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.directory.server.protocol.shared.catalog;
22
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import org.apache.directory.server.constants.ApacheSchemaConstants;
28 import org.apache.directory.server.core.CoreSession;
29 import org.apache.directory.server.core.entry.ServerEntry;
30 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
31 import org.apache.directory.server.protocol.shared.store.DirectoryServiceOperation;
32 import org.apache.directory.shared.ldap.entry.EntryAttribute;
33 import org.apache.directory.shared.ldap.filter.FilterParser;
34 import org.apache.directory.shared.ldap.filter.SearchScope;
35 import org.apache.directory.shared.ldap.message.AliasDerefMode;
36 import org.apache.directory.shared.ldap.name.LdapDN;
37
38
39
40
41
42
43
44
45 public class GetCatalog implements DirectoryServiceOperation
46 {
47 private static final long serialVersionUID = -6657995003127926278L;
48
49
50
51
52
53 public Object execute( CoreSession session, LdapDN base ) throws Exception
54 {
55 String filter = "(objectClass=" + ApacheSchemaConstants.APACHE_CATALOG_ENTRY_OC + ")";
56
57 EntryFilteringCursor list = session.search(
58 LdapDN.EMPTY_LDAPDN,
59 SearchScope.SUBTREE,
60 FilterParser.parse( filter ),
61 AliasDerefMode.DEREF_ALWAYS,
62 null );
63
64 Map<String, String> catalog = new HashMap<String, String>();
65
66 list.beforeFirst();
67
68 while ( list.next() )
69 {
70 ServerEntry result = list.get();
71
72 String name = null;
73 EntryAttribute attribute = result.get( ApacheSchemaConstants.APACHE_CATALOGUE_ENTRY_NAME_AT );
74
75 if ( attribute != null )
76 {
77 name = attribute.getString();
78 }
79
80 String basedn = null;
81 attribute = result.get( ApacheSchemaConstants.APACHE_CATALOGUE_ENTRY_BASE_DN_AT );
82
83 if ( attribute != null )
84 {
85 basedn = attribute.getString();
86 }
87
88
89 catalog.put( name, basedn );
90 }
91
92 return catalog;
93 }
94 }