View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.server.schema.bootstrap;
21  
22  
23  import java.util.Comparator;
24  
25  import javax.naming.NamingException;
26  
27  import jdbm.helper.StringComparator;
28  
29  import org.apache.commons.collections.comparators.ComparableComparator;
30  import org.apache.directory.server.constants.MetaSchemaConstants;
31  import org.apache.directory.server.schema.registries.Registries;
32  import org.apache.directory.server.schema.registries.SyntaxRegistry;
33  import org.apache.directory.shared.ldap.NotImplementedException;
34  import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
35  import org.apache.directory.shared.ldap.schema.MatchingRule;
36  import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
37  import org.apache.directory.shared.ldap.schema.Normalizer;
38  import org.apache.directory.shared.ldap.schema.ObjectIdentifierComparator;
39  import org.apache.directory.shared.ldap.schema.ObjectIdentifierNormalizer;
40  import org.apache.directory.shared.ldap.schema.Syntax;
41  
42  
43  /**
44   * A producer of MatchingRule objects for the apachemeta schema.
45   * Modified by hand from generated code
46   *
47   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
48   * @version $Rev$
49   */
50  public class ApachemetaMatchingRuleProducer extends AbstractBootstrapProducer
51  {
52      
53      
54      public ApachemetaMatchingRuleProducer()
55      {
56          super( ProducerTypeEnum.MATCHING_RULE_PRODUCER );
57      }
58  
59  
60      // ------------------------------------------------------------------------
61      // BootstrapProducer Methods
62      // ------------------------------------------------------------------------
63  
64  
65      /**
66       * @see BootstrapProducer#produce(Registries, ProducerCallback)
67       */
68      public void produce( Registries registries, ProducerCallback cb )
69          throws NamingException
70      {
71          MatchingRule matchingRule = null;
72          
73          matchingRule = new NameOrNumericIdMatch( registries.getOidRegistry(), MetaSchemaConstants.SCHEMA_NAME );
74          cb.schemaObjectProduced( this, matchingRule.getOid(), matchingRule );
75          
76          matchingRule = new ObjectClassTypeMatch();
77          cb.schemaObjectProduced( this, matchingRule.getOid(), matchingRule );
78          
79          matchingRule = new NumericOidMatch( registries.getSyntaxRegistry() );
80          cb.schemaObjectProduced( this, matchingRule.getOid(), matchingRule );
81          
82          matchingRule = new SupDITStructureRuleMatch( registries.getSyntaxRegistry() );
83          cb.schemaObjectProduced( this, matchingRule.getOid(), matchingRule );
84          
85          matchingRule = new RuleIdMatch( registries.getSyntaxRegistry() );
86          cb.schemaObjectProduced( this, matchingRule.getOid(), matchingRule );
87      }
88      
89      
90      public static class RuleIdMatch implements MatchingRule
91      {
92          private static final long serialVersionUID = 1L;
93          private static final String OID = "1.3.6.1.4.1.18060.0.4.0.1.4";
94          private final Syntax syntax;
95          private final String[] NAMES = new String[] { "ruleIdMatch" };
96          
97          
98          RuleIdMatch( SyntaxRegistry registry ) throws NamingException
99          {
100             syntax = registry.lookup( "1.3.6.1.4.1.1466.115.121.1.26" );
101         }
102         
103         public Comparator getComparator() throws NamingException
104         {
105             return new ComparableComparator();
106         }
107         
108         public Normalizer getNormalizer() throws NamingException
109         {
110             return new DeepTrimToLowerNormalizer();
111         }
112 
113         public Syntax getSyntax() throws NamingException
114         {
115             return syntax;
116         }
117 
118         public String getDescription()
119         {
120             return "Rule identifier of this DIT structure rule";
121         }
122 
123         public String getName()
124         {
125             return NAMES[0];
126         }
127 
128         public String[] getNamesRef()
129         {
130             return NAMES;
131         }
132 
133         public String getOid()
134         {
135             return OID;
136         }
137 
138         public boolean isObsolete()
139         {
140             return false;
141         }
142 
143         public String getSchema()
144         {
145             return MetaSchemaConstants.SCHEMA_NAME;
146         }
147 
148         public void setSchema( String schemaName )
149         {
150             throw new NotImplementedException();
151         }
152     }
153     
154     
155     public static class SupDITStructureRuleMatch implements MatchingRule
156     {
157         private static final String OID = "1.3.6.1.4.1.18060.0.4.0.1.3";
158         private static final long serialVersionUID = 1L;
159         String[] NAMES = new String[] { "supDITStructureRuleMatch" };
160         Syntax syntax;
161         
162         
163         public SupDITStructureRuleMatch( SyntaxRegistry registry ) throws NamingException
164         {
165             this.syntax = registry.lookup( "1.3.6.1.4.1.1466.115.121.1.17" );
166         }
167         
168         
169         public Comparator getComparator() throws NamingException
170         {
171             return new StringComparator();
172         }
173 
174         public Normalizer getNormalizer() throws NamingException
175         {
176             return new DeepTrimToLowerNormalizer();
177         }
178 
179         public Syntax getSyntax() throws NamingException
180         {
181             return syntax;
182         }
183 
184         public String getDescription()
185         {
186             return "A matching rule matching dit structure rule attributes";
187         }
188 
189         public String getName()
190         {
191             return NAMES[0];
192         }
193 
194         public String[] getNamesRef()
195         {
196             return NAMES;
197         }
198 
199         public String getOid()
200         {
201             return OID;
202         }
203 
204         public boolean isObsolete()
205         {
206             return false;
207         }
208 
209         public String getSchema()
210         {
211             return MetaSchemaConstants.SCHEMA_NAME;
212         }
213 
214         public void setSchema( String schemaName )
215         {
216             throw new NotImplementedException();
217         }
218     }
219     
220     
221     public static class NumericOidMatch implements MatchingRule
222     {
223         private static final String OID = "1.3.6.1.4.1.18060.0.4.0.1.2";
224 
225         private static final long serialVersionUID = 1L;
226 
227         final String[] NAMES = new String[] { "numericOidMatch" };
228         Syntax syntax;
229         
230         public NumericOidMatch( SyntaxRegistry registry ) throws NamingException
231         {
232             this.syntax = registry.lookup( "1.3.6.1.4.1.1466.115.121.1.38" );
233         }
234         
235         public Comparator getComparator() throws NamingException
236         {
237             return new ObjectIdentifierComparator();
238         }
239 
240         public Normalizer getNormalizer() throws NamingException
241         {
242             return new ObjectIdentifierNormalizer();
243         }
244 
245         public Syntax getSyntax() throws NamingException
246         {
247             return syntax;
248         }
249 
250         public String getDescription()
251         {
252             return "a matching rule for numeric oids";
253         }
254 
255         public String getName()
256         {
257             return NAMES[0];
258         }
259 
260         public String[] getNamesRef()
261         {
262             return NAMES;
263         }
264 
265         public String getOid()
266         {
267             return OID;
268         }
269 
270         public boolean isObsolete()
271         {
272             return false;
273         }
274 
275         public String getSchema()
276         {
277             return MetaSchemaConstants.SCHEMA_NAME;
278         }
279 
280         public void setSchema( String schemaName )
281         {
282             throw new NotImplementedException();
283         }
284     }
285 
286     
287     public static class ObjectClassTypeMatch implements MatchingRule
288     {
289         private static final long serialVersionUID = 1L;
290         public static final Comparator COMPARATOR = new ApachemetaComparatorProducer.ObjectClassTypeComparator(); 
291         public static final Normalizer NORMALIZER = new NoOpNormalizer();
292         public static final Syntax SYNTAX = new ApachemetaSyntaxProducer.ObjectClassTypeSyntax();
293         public static final String OID = "1.3.6.1.4.1.18060.0.4.0.1.1";
294         
295         private static final String[] NAMES = new String[] { "objectClassTypeMatch" };
296         
297         public Comparator getComparator() throws NamingException
298         {
299             return COMPARATOR;
300         }
301 
302         
303         public Normalizer getNormalizer() throws NamingException
304         {
305             return NORMALIZER;
306         }
307 
308         public Syntax getSyntax() throws NamingException
309         {
310             return SYNTAX;
311         }
312 
313         public String getDescription()
314         {
315             return "objectClassTypeMatch: for mathing AUXILIARY, STRUCTURAL, ABSTRACT";
316         }
317 
318         public String getName()
319         {
320             return NAMES[0];
321         }
322 
323         public String[] getNamesRef()
324         {
325             return NAMES;
326         }
327 
328         public String getOid()
329         {
330             return OID;
331         }
332 
333         public boolean isObsolete()
334         {
335             return false;
336         }
337 
338         public String getSchema()
339         {
340             return MetaSchemaConstants.SCHEMA_NAME;
341         }
342 
343         public void setSchema( String schemaName )
344         {
345             throw new NotImplementedException();
346         }
347     }
348 }