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.xdbm.impl.avl;
22
23
24 import org.apache.directory.api.ldap.model.exception.LdapException;
25 import org.apache.directory.api.ldap.model.exception.LdapOtherException;
26 import org.apache.directory.api.ldap.model.schema.AttributeType;
27 import org.apache.directory.api.ldap.model.schema.MatchingRule;
28 import org.apache.directory.api.ldap.model.schema.SchemaManager;
29 import org.apache.directory.api.ldap.model.schema.comparators.UuidComparator;
30 import org.apache.directory.server.i18n.I18n;
31 import org.apache.directory.server.xdbm.ParentIdAndRdn;
32 import org.apache.directory.server.xdbm.ParentIdAndRdnComparator;
33
34
35
36
37
38
39
40 public class AvlRdnIndex extends AvlIndex<ParentIdAndRdn>
41 {
42 public AvlRdnIndex()
43 {
44 super();
45 }
46
47
48 public AvlRdnIndex( String attributeId )
49 {
50 super( attributeId, true );
51 }
52
53
54 @Override
55 public void init( SchemaManager schemaManager, AttributeType attributeType ) throws LdapException
56 {
57 this.attributeType = attributeType;
58
59 MatchingRule mr = attributeType.getEquality();
60
61 if ( mr == null )
62 {
63 mr = attributeType.getOrdering();
64 }
65
66 if ( mr == null )
67 {
68 mr = attributeType.getSubstring();
69 }
70
71 normalizer = mr.getNormalizer();
72
73 if ( normalizer == null )
74 {
75 throw new LdapOtherException( I18n.err( I18n.ERR_212, attributeType ) );
76 }
77
78 ParentIdAndRdnComparator<String> comp = new ParentIdAndRdnComparator<>( mr.getOid() );
79
80 UuidComparator.INSTANCE.setSchemaManager( schemaManager );
81
82
83
84
85
86
87 forward = new AvlTable<ParentIdAndRdn, String>( attributeType.getName(), comp, UuidComparator.INSTANCE,
88 false );
89 reverse = new AvlTable<String, ParentIdAndRdn>( attributeType.getName(), UuidComparator.INSTANCE, comp,
90 false );
91 }
92 }