1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.schema.bootstrap;
21
22
23 import java.lang.reflect.InvocationTargetException;
24 import java.lang.reflect.Method;
25
26 import javax.naming.NamingException;
27
28 import org.apache.directory.server.schema.DnNormalizer;
29 import org.apache.directory.server.schema.NameAndOptionalUIDNormalizer;
30 import org.apache.directory.server.schema.bootstrap.ProducerTypeEnum;
31 import org.apache.directory.server.schema.registries.Registries;
32 import org.apache.directory.shared.ldap.schema.CachingNormalizer;
33 import org.apache.directory.shared.ldap.schema.DeepTrimNormalizer;
34 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
35 import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
36 import org.apache.directory.shared.ldap.schema.Normalizer;
37 import org.apache.directory.shared.ldap.schema.ObjectIdentifierNormalizer;
38
39
40
41
42
43
44
45
46
47 public class SystemNormalizerProducer extends AbstractBootstrapProducer
48 {
49 public SystemNormalizerProducer()
50 {
51 super( ProducerTypeEnum.NORMALIZER_PRODUCER );
52 }
53
54
55 public static class CachingDeepTrimToLowerNormalizer extends CachingNormalizer
56 {
57 private static final long serialVersionUID = 1L;
58
59 public CachingDeepTrimToLowerNormalizer()
60 {
61 super( new DeepTrimToLowerNormalizer() );
62 }
63 }
64
65
66 public static class CachingDeepTrimNormalizer extends CachingNormalizer
67 {
68 private static final long serialVersionUID = 1L;
69
70 public CachingDeepTrimNormalizer()
71 {
72 super( new DeepTrimNormalizer() );
73 }
74 }
75
76
77 public static class CachingDnNormalizer extends CachingNormalizer
78 {
79 private static final long serialVersionUID = 1L;
80
81
82 private final static Class[] parameterTypes = new Class[] { Registries.class };
83
84
85 public CachingDnNormalizer()
86 {
87 super( new DnNormalizer() );
88 }
89
90
91 public void setRegistries( Registries registries ) throws NamingException
92 {
93 injectRegistries( super.normalizer, registries );
94 }
95
96
97 private void injectRegistries( Object obj, Registries registries ) throws NamingException
98 {
99 String className = obj.getClass().getName();
100
101 try
102 {
103 Method method = obj.getClass().getMethod( "setRegistries", parameterTypes );
104
105 if ( method == null )
106 {
107 return;
108 }
109
110 Object[] args = new Object[] { registries };
111 method.invoke( obj, args );
112 }
113 catch ( SecurityException e )
114 {
115 NamingException ne = new NamingException( "SyntaxChecker class "+ className
116 + " could not have the Registries dependency injected." );
117 ne.setRootCause( e );
118 throw ne;
119 }
120 catch ( NoSuchMethodException e )
121 {
122
123 }
124 catch ( IllegalArgumentException e )
125 {
126 NamingException ne = new NamingException( "SyntaxChecker class "+ className
127 + " could not have the Registries dependency injected." );
128 ne.setRootCause( e );
129 throw ne;
130 }
131 catch ( IllegalAccessException e )
132 {
133 NamingException ne = new NamingException( "SyntaxChecker class "+ className
134 + " could not have the Registries dependency injected." );
135 ne.setRootCause( e );
136 throw ne;
137 }
138 catch ( InvocationTargetException e )
139 {
140 NamingException ne = new NamingException( "SyntaxChecker class "+ className
141 + " could not have the Registries dependency injected." );
142 ne.setRootCause( e );
143 throw ne;
144 }
145 }
146 }
147
148
149 public void produce( Registries registries, ProducerCallback cb ) throws NamingException
150 {
151 Normalizer normalizer;
152
153
154
155
156
157
158
159
160 normalizer = new CachingDnNormalizer();
161 ( ( CachingDnNormalizer ) normalizer ).setRegistries( registries );
162 cb.schemaObjectProduced( this, "2.5.13.1", normalizer );
163
164
165
166
167
168 normalizer = new CachingDeepTrimToLowerNormalizer();
169 cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.2", normalizer );
170
171
172
173
174
175 normalizer = new CachingDeepTrimToLowerNormalizer();
176 cb.schemaObjectProduced( this, "2.5.13.11", normalizer );
177
178
179
180
181
182 normalizer = new CachingDeepTrimToLowerNormalizer();
183 cb.schemaObjectProduced( this, "2.5.13.2", normalizer );
184
185
186
187
188
189 normalizer = new CachingDeepTrimToLowerNormalizer();
190 cb.schemaObjectProduced( this, "2.5.13.3", normalizer );
191
192
193
194
195
196 normalizer = new CachingDeepTrimToLowerNormalizer();
197 cb.schemaObjectProduced( this, "2.5.13.4", normalizer );
198
199
200
201
202
203 normalizer = new NoOpNormalizer();
204 cb.schemaObjectProduced( this, "2.5.13.6", normalizer );
205
206
207
208
209
210 normalizer = new ObjectIdentifierNormalizer();
211 cb.schemaObjectProduced( this, "2.5.13.0", normalizer );
212
213
214
215
216
217 normalizer = new NoOpNormalizer();
218 cb.schemaObjectProduced( this, "2.5.13.8", normalizer );
219
220
221
222
223
224 normalizer = new NoOpNormalizer();
225 cb.schemaObjectProduced( this, "2.5.13.10", normalizer );
226
227
228
229
230
231 normalizer = new NoOpNormalizer();
232 cb.schemaObjectProduced( this, "2.5.13.14", normalizer );
233
234
235
236
237
238 normalizer = new NoOpNormalizer();
239 cb.schemaObjectProduced( this, "2.5.13.15", normalizer );
240
241
242
243
244
245 normalizer = new NoOpNormalizer();
246 cb.schemaObjectProduced( this, "2.5.13.16", normalizer );
247
248
249
250
251
252 normalizer = new NoOpNormalizer();
253 cb.schemaObjectProduced( this, "2.5.13.17", normalizer );
254
255
256
257
258
259 normalizer = new NoOpNormalizer();
260 cb.schemaObjectProduced( this, "2.5.13.18", normalizer );
261
262
263
264
265
266 normalizer = new NoOpNormalizer();
267 cb.schemaObjectProduced( this, "2.5.13.20", normalizer );
268
269
270
271
272
273 normalizer = new NoOpNormalizer();
274 cb.schemaObjectProduced( this, "2.5.13.21", normalizer );
275
276
277
278
279
280 normalizer = new NoOpNormalizer();
281 cb.schemaObjectProduced( this, "2.5.13.22", normalizer );
282
283
284
285
286
287 normalizer = new NameAndOptionalUIDNormalizer();
288 cb.schemaObjectProduced( this, "2.5.13.23", normalizer );
289
290
291
292
293
294 normalizer = new CachingDeepTrimNormalizer();
295 cb.schemaObjectProduced( this, "2.5.13.24", normalizer );
296
297
298
299
300
301 normalizer = new CachingDeepTrimNormalizer();
302 cb.schemaObjectProduced( this, "2.5.13.27", normalizer );
303
304
305
306
307
308 normalizer = new CachingDeepTrimNormalizer();
309 cb.schemaObjectProduced( this, "2.5.13.28", normalizer );
310
311
312
313
314
315 normalizer = new NoOpNormalizer();
316 cb.schemaObjectProduced( this, "2.5.13.29", normalizer );
317
318
319
320
321
322 normalizer = new NoOpNormalizer();
323 cb.schemaObjectProduced( this, "2.5.13.30", normalizer );
324
325
326
327
328
329
330
331
332 normalizer = new NoOpNormalizer();
333 cb.schemaObjectProduced( this, "2.5.13.31", normalizer );
334
335
336
337
338
339 normalizer = new CachingDeepTrimNormalizer();
340 cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.1", normalizer );
341
342
343
344
345
346
347
348
349
350
351 normalizer = new NoOpNormalizer();
352 cb.schemaObjectProduced( this, "2.5.13.13", normalizer );
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368 normalizer = new CachingDeepTrimNormalizer();
369 cb.schemaObjectProduced( this, "2.5.13.5", normalizer );
370
371 normalizer = new CachingDeepTrimNormalizer();
372 cb.schemaObjectProduced( this, "2.5.13.7", normalizer );
373
374 normalizer = new CachingDeepTrimToLowerNormalizer();
375 cb.schemaObjectProduced( this, "2.5.13.12", normalizer );
376
377
378
379
380
381
382
383
384
385 normalizer = new CachingDeepTrimToLowerNormalizer();
386 cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.3", normalizer );
387 }
388 }