1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ldap.server.interceptor;
18
19
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.Iterator;
23 import java.util.List;
24 import java.util.ListIterator;
25 import java.util.Map;
26
27 import javax.naming.ConfigurationException;
28 import javax.naming.Name;
29 import javax.naming.NamingEnumeration;
30 import javax.naming.NamingException;
31 import javax.naming.directory.Attributes;
32 import javax.naming.directory.ModificationItem;
33 import javax.naming.directory.SearchControls;
34
35 import org.apache.ldap.common.filter.ExprNode;
36 import org.apache.ldap.server.configuration.ContextPartitionConfiguration;
37 import org.apache.ldap.server.configuration.InterceptorConfiguration;
38 import org.apache.ldap.server.configuration.MutableInterceptorConfiguration;
39 import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
40 import org.apache.ldap.server.partition.ContextPartitionNexus;
41
42
43 /***
44 * Manages the chain of {@link Interceptor}s.
45 *
46 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
47 * @version $Rev: 264732 $, $Date: 2005-08-30 04:04:51 -0400 (Tue, 30 Aug 2005) $
48 */
49 public class InterceptorChain
50 {
51 private final Interceptor FINAL_INTERCEPTOR = new Interceptor()
52 {
53 private ContextPartitionNexus nexus;
54
55 public void init( ContextFactoryConfiguration factoryCfg, InterceptorConfiguration cfg )
56 {
57 this.nexus = factoryCfg.getPartitionNexus();
58 }
59
60
61 public void destroy()
62 {
63
64 }
65
66
67 public Attributes getRootDSE( NextInterceptor next ) throws NamingException
68 {
69 return nexus.getRootDSE();
70 }
71
72
73 public Name getMatchedName( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
74 {
75 return ( Name ) nexus.getMatchedName( dn, normalized ).clone();
76 }
77
78
79 public Name getSuffix( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
80 {
81 return ( Name ) nexus.getSuffix( dn, normalized ).clone();
82 }
83
84
85 public Iterator listSuffixes( NextInterceptor next, boolean normalized ) throws NamingException
86 {
87 return nexus.listSuffixes( normalized );
88 }
89
90
91 public void delete( NextInterceptor next, Name name ) throws NamingException
92 {
93 nexus.delete( name );
94 }
95
96
97 public void add( NextInterceptor next, String upName, Name normName, Attributes entry ) throws NamingException
98 {
99 nexus.add( upName, normName, entry );
100 }
101
102
103 public void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException
104 {
105 nexus.modify( name, modOp, mods );
106 }
107
108
109 public void modify( NextInterceptor next, Name name, ModificationItem[] mods ) throws NamingException
110 {
111 nexus.modify( name, mods );
112 }
113
114
115 public NamingEnumeration list( NextInterceptor next, Name base ) throws NamingException
116 {
117 return nexus.list( base );
118 }
119
120
121 public NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
122 {
123 return nexus.search( base, env, filter, searchCtls );
124 }
125
126
127 public Attributes lookup( NextInterceptor next, Name name ) throws NamingException
128 {
129 return ( Attributes ) nexus.lookup( name ).clone();
130 }
131
132
133 public Attributes lookup( NextInterceptor next, Name dn, String[] attrIds ) throws NamingException
134 {
135 return ( Attributes ) nexus.lookup( dn, attrIds ).clone();
136 }
137
138
139 public boolean hasEntry( NextInterceptor next, Name name ) throws NamingException
140 {
141 return nexus.hasEntry( name );
142 }
143
144
145 public boolean isSuffix( NextInterceptor next, Name name ) throws NamingException
146 {
147 return nexus.isSuffix( name );
148 }
149
150
151 public void modifyRn( NextInterceptor next, Name name, String newRn, boolean deleteOldRn ) throws NamingException
152 {
153 nexus.modifyRn( name, newRn, deleteOldRn );
154 }
155
156
157 public void move( NextInterceptor next, Name oriChildName, Name newParentName ) throws NamingException
158 {
159 nexus.move( oriChildName, newParentName );
160 }
161
162
163 public void move( NextInterceptor next, Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
164 {
165 nexus.move( oriChildName, newParentName, newRn, deleteOldRn );
166 }
167
168
169 public void addContextPartition( NextInterceptor next, ContextPartitionConfiguration cfg ) throws NamingException
170 {
171 nexus.addContextPartition( cfg );
172 }
173
174
175 public void removeContextPartition( NextInterceptor next, Name suffix ) throws NamingException
176 {
177 nexus.removeContextPartition( suffix );
178 }
179 };
180
181 private final Map name2entry = new HashMap();
182
183 private final Entry tail;
184
185 private Entry head;
186
187 private ContextFactoryConfiguration factoryCfg;
188
189 /***
190 * Create a new interceptor chain.
191 */
192 public InterceptorChain()
193 {
194 MutableInterceptorConfiguration tailCfg = new MutableInterceptorConfiguration();
195 tailCfg.setName( "tail" );
196 tailCfg.setInterceptor( FINAL_INTERCEPTOR );
197 tail = new Entry( null, null, tailCfg );
198 head = tail;
199 }
200
201
202 /***
203 * Initializes and registers all interceptors according to the specified
204 * {@link ContextFactoryConfiguration}.
205 */
206 public synchronized void init( ContextFactoryConfiguration factoryCfg ) throws NamingException
207 {
208 this.factoryCfg = factoryCfg;
209
210
211 FINAL_INTERCEPTOR.init( factoryCfg, null );
212
213
214 ListIterator i = factoryCfg.getStartupConfiguration().getInterceptorConfigurations().listIterator();
215 Interceptor interceptor = null;
216 try
217 {
218 while( i.hasNext() )
219 {
220 InterceptorConfiguration cfg = ( InterceptorConfiguration ) i.next();
221 register( cfg );
222 }
223 }
224 catch ( Throwable t )
225 {
226
227 destroy();
228
229 if ( t instanceof NamingException )
230 {
231 throw ( NamingException ) t;
232 }
233 else
234 {
235 throw new InterceptorException( interceptor, "Failed to initialize interceptor chain.", t );
236 }
237 }
238 }
239
240
241 /***
242 * Deinitializes and deregisters all interceptors this chain contains.
243 */
244 public synchronized void destroy()
245 {
246 List entries = new ArrayList();
247 Entry e = tail;
248 do
249 {
250 entries.add( e );
251 e = e.prevEntry;
252 }
253 while ( e != null );
254
255 Iterator i = entries.iterator();
256 while ( i.hasNext() )
257 {
258 e = ( Entry ) i.next();
259 if( e != tail )
260 {
261 try
262 {
263 deregister( e.configuration.getName() );
264 }
265 catch ( Throwable t )
266 {
267 t.printStackTrace();
268 }
269 }
270 }
271 }
272
273
274 /***
275 * Returns the registered interceptor with the specified name.
276 * @return <tt>null</tt> if the specified name doesn't exist.
277 */
278 public Interceptor get( String interceptorName )
279 {
280 Entry e = (Entry) name2entry.get( interceptorName );
281 if( e == null )
282 {
283 return null;
284 }
285
286 return e.configuration.getInterceptor();
287 }
288
289 /***
290 * Returns the list of all registered interceptors.
291 */
292 public synchronized List getAll()
293 {
294 List result = new ArrayList();
295 Entry e = head;
296 do
297 {
298 result.add( e.configuration.getInterceptor() );
299 e = e.nextEntry;
300 }
301 while ( e != tail );
302
303 return result;
304 }
305
306 public synchronized void addFirst( InterceptorConfiguration cfg ) throws NamingException
307 {
308 register0( cfg, head );
309 }
310
311 public synchronized void addLast( InterceptorConfiguration cfg ) throws NamingException
312 {
313 register0( cfg, tail );
314 }
315
316 public synchronized void addBefore( String nextInterceptorName, InterceptorConfiguration cfg ) throws NamingException
317 {
318 Entry e = (Entry) name2entry.get( nextInterceptorName );
319 if( e == null )
320 {
321 throw new ConfigurationException( "Interceptor not found: " + nextInterceptorName );
322 }
323 register0( cfg, e );
324 }
325
326 public synchronized InterceptorConfiguration remove( String interceptorName ) throws NamingException
327 {
328 return deregister( interceptorName );
329 }
330
331 public synchronized void addAfter( String prevInterceptorName, InterceptorConfiguration cfg ) throws NamingException
332 {
333 Entry e = (Entry) name2entry.get( prevInterceptorName );
334 if( e == null )
335 {
336 throw new ConfigurationException( "Interceptor not found: " + prevInterceptorName );
337 }
338 register0( cfg, e.nextEntry );
339 }
340
341
342 /***
343 * Adds and initializes an interceptor with the specified configuration.
344 */
345 private void register( InterceptorConfiguration cfg ) throws NamingException
346 {
347 checkAddable( cfg );
348 register0( cfg, tail );
349 }
350
351
352 /***
353 * Removes and deinitializes the interceptor with the specified name.
354 */
355 private InterceptorConfiguration deregister( String name ) throws ConfigurationException
356 {
357 Entry entry = checkOldName( name );
358 Entry prevEntry = entry.prevEntry;
359 Entry nextEntry = entry.nextEntry;
360
361 if( nextEntry == null )
362 {
363
364 return null;
365 }
366
367 if ( prevEntry == null )
368 {
369 nextEntry.prevEntry = null;
370 head = nextEntry;
371 }
372 else
373 {
374 prevEntry.nextEntry = nextEntry;
375 nextEntry.prevEntry = prevEntry;
376 }
377
378 name2entry.remove( name );
379 entry.configuration.getInterceptor().destroy();
380
381 return entry.configuration;
382 }
383
384
385 private void register0( InterceptorConfiguration cfg, Entry nextEntry ) throws NamingException
386 {
387 String name = cfg.getName();
388 Interceptor interceptor = cfg.getInterceptor();
389 interceptor.init( factoryCfg, cfg );
390
391 Entry newEntry;
392 if( nextEntry == head )
393 {
394 newEntry = new Entry( null, head, cfg );
395 head.prevEntry = newEntry;
396 head = newEntry;
397 }
398 else if( head == tail )
399 {
400 newEntry = new Entry( null, tail, cfg );
401 tail.prevEntry = newEntry;
402 head = newEntry;
403 }
404 else
405 {
406 newEntry = new Entry( nextEntry.prevEntry, nextEntry, cfg );
407 nextEntry.prevEntry.nextEntry = newEntry;
408 nextEntry.prevEntry = newEntry;
409 }
410
411 name2entry.put( name, newEntry );
412 }
413
414
415 /***
416 * Throws an exception when the specified interceptor name is not registered in this chain.
417 *
418 * @return An interceptor entry with the specified name.
419 */
420 private Entry checkOldName( String baseName ) throws ConfigurationException
421 {
422 Entry e = ( Entry ) name2entry.get( baseName );
423
424 if ( e == null )
425 {
426 throw new ConfigurationException( "Unknown interceptor name:" + baseName );
427 }
428
429 return e;
430 }
431
432
433 /***
434 * Checks the specified interceptor name is already taken and throws an exception if already taken.
435 */
436 private void checkAddable( InterceptorConfiguration cfg ) throws ConfigurationException
437 {
438 if ( name2entry.containsKey( cfg.getName() ) )
439 {
440 throw new ConfigurationException( "Other interceptor is using name '" + cfg.getName() + "'" );
441 }
442 }
443
444
445 public Attributes getRootDSE() throws NamingException
446 {
447 Interceptor head = this.head.configuration.getInterceptor();
448 NextInterceptor next = this.head.nextInterceptor;
449 try
450 {
451 return head.getRootDSE( next );
452 }
453 catch ( NamingException ne )
454 {
455 throw ne;
456 }
457 catch ( Throwable e )
458 {
459 throwInterceptorException( head, e );
460 throw new InternalError();
461 }
462 }
463
464
465 public Name getMatchedName( Name name, boolean normalized ) throws NamingException
466 {
467 Interceptor head = this.head.configuration.getInterceptor();
468 NextInterceptor next = this.head.nextInterceptor;
469 try
470 {
471 return head.getMatchedName( next, name, normalized );
472 }
473 catch ( NamingException ne )
474 {
475 throw ne;
476 }
477 catch ( Throwable e )
478 {
479 throwInterceptorException( head, e );
480 throw new InternalError();
481 }
482 }
483
484
485 public Name getSuffix( Name name, boolean normalized ) throws NamingException
486 {
487 Interceptor head = this.head.configuration.getInterceptor();
488 NextInterceptor next = this.head.nextInterceptor;
489 try
490 {
491 return head.getSuffix( next, name, normalized );
492 }
493 catch ( NamingException ne )
494 {
495 throw ne;
496 }
497 catch ( Throwable e )
498 {
499 throwInterceptorException( head, e );
500 throw new InternalError();
501 }
502 }
503
504
505 public Iterator listSuffixes( boolean normalized ) throws NamingException
506 {
507 Interceptor head = this.head.configuration.getInterceptor();
508 NextInterceptor next = this.head.nextInterceptor;
509 try
510 {
511 return head.listSuffixes( next, normalized );
512 }
513 catch ( NamingException ne )
514 {
515 throw ne;
516 }
517 catch ( Throwable e )
518 {
519 throwInterceptorException( head, e );
520 throw new InternalError();
521 }
522 }
523
524 public void addContextPartition( ContextPartitionConfiguration cfg ) throws NamingException
525 {
526 Interceptor head = this.head.configuration.getInterceptor();
527 NextInterceptor next = this.head.nextInterceptor;
528 try
529 {
530 head.addContextPartition( next, cfg );
531 }
532 catch ( NamingException ne )
533 {
534 throw ne;
535 }
536 catch ( Throwable e )
537 {
538 throwInterceptorException( head, e );
539 throw new InternalError();
540 }
541 }
542
543 public void removeContextPartition( Name suffix ) throws NamingException
544 {
545 Interceptor head = this.head.configuration.getInterceptor();
546 NextInterceptor next = this.head.nextInterceptor;
547 try
548 {
549 head.removeContextPartition( next, suffix );
550 }
551 catch ( NamingException ne )
552 {
553 throw ne;
554 }
555 catch ( Throwable e )
556 {
557 throwInterceptorException( head, e );
558 throw new InternalError();
559 }
560 }
561
562 public void delete( Name name ) throws NamingException
563 {
564 Interceptor head = this.head.configuration.getInterceptor();
565 NextInterceptor next = this.head.nextInterceptor;
566 try
567 {
568 head.delete( next, name );
569 }
570 catch ( NamingException ne )
571 {
572 throw ne;
573 }
574 catch ( Throwable e )
575 {
576 throwInterceptorException( head, e );
577 }
578 }
579
580
581 public void add( String upName, Name normName, Attributes entry ) throws NamingException
582 {
583 Interceptor head = this.head.configuration.getInterceptor();
584 NextInterceptor next = this.head.nextInterceptor;
585 try
586 {
587 head.add( next, upName, normName, entry );
588 }
589 catch ( NamingException ne )
590 {
591 throw ne;
592 }
593 catch ( Throwable e )
594 {
595 throwInterceptorException( head, e );
596 }
597 }
598
599
600 public void modify( Name name, int modOp, Attributes mods ) throws NamingException
601 {
602 Interceptor head = this.head.configuration.getInterceptor();
603 NextInterceptor next = this.head.nextInterceptor;
604 try
605 {
606 head.modify( next, name, modOp, mods );
607 }
608 catch ( NamingException ne )
609 {
610 throw ne;
611 }
612 catch ( Throwable e )
613 {
614 throwInterceptorException( head, e );
615 }
616 }
617
618
619 public void modify( Name name, ModificationItem[] mods ) throws NamingException
620 {
621 Interceptor head = this.head.configuration.getInterceptor();
622 NextInterceptor next = this.head.nextInterceptor;
623 try
624 {
625 head.modify( next, name, mods );
626 }
627 catch ( NamingException ne )
628 {
629 throw ne;
630 }
631 catch ( Throwable e )
632 {
633 throwInterceptorException( head, e );
634 }
635 }
636
637
638 public NamingEnumeration list( Name base ) throws NamingException
639 {
640 Interceptor head = this.head.configuration.getInterceptor();
641 NextInterceptor next = this.head.nextInterceptor;
642 try
643 {
644 return head.list( next, base );
645 }
646 catch ( NamingException ne )
647 {
648 throw ne;
649 }
650 catch ( Throwable e )
651 {
652 throwInterceptorException( head, e );
653 throw new InternalError();
654 }
655 }
656
657
658 public NamingEnumeration search( Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
659 {
660 Interceptor head = this.head.configuration.getInterceptor();
661 NextInterceptor next = this.head.nextInterceptor;
662 try
663 {
664 return head.search( next, base, env, filter, searchCtls );
665 }
666 catch ( NamingException ne )
667 {
668 throw ne;
669 }
670 catch ( Throwable e )
671 {
672 throwInterceptorException( head, e );
673 throw new InternalError();
674 }
675 }
676
677
678 public Attributes lookup( Name name ) throws NamingException
679 {
680 Interceptor head = this.head.configuration.getInterceptor();
681 NextInterceptor next = this.head.nextInterceptor;
682 try
683 {
684 return head.lookup( next, name );
685 }
686 catch ( NamingException ne )
687 {
688 throw ne;
689 }
690 catch ( Throwable e )
691 {
692 throwInterceptorException( head, e );
693 throw new InternalError();
694 }
695 }
696
697
698 public Attributes lookup( Name dn, String[] attrIds ) throws NamingException
699 {
700 Interceptor head = this.head.configuration.getInterceptor();
701 NextInterceptor next = this.head.nextInterceptor;
702 try
703 {
704 return head.lookup( next, dn, attrIds );
705 }
706 catch ( NamingException ne )
707 {
708 throw ne;
709 }
710 catch ( Throwable e )
711 {
712 throwInterceptorException( head, e );
713 throw new InternalError();
714 }
715 }
716
717
718 public boolean hasEntry( Name name ) throws NamingException
719 {
720 Interceptor head = this.head.configuration.getInterceptor();
721 NextInterceptor next = this.head.nextInterceptor;
722 try
723 {
724 return head.hasEntry( next, name );
725 }
726 catch ( NamingException ne )
727 {
728 throw ne;
729 }
730 catch ( Throwable e )
731 {
732 throwInterceptorException( head, e );
733 throw new InternalError();
734 }
735 }
736
737
738 public boolean isSuffix( Name name ) throws NamingException
739 {
740 Interceptor head = this.head.configuration.getInterceptor();
741 NextInterceptor next = this.head.nextInterceptor;
742 try
743 {
744 return head.isSuffix( next, name );
745 }
746 catch ( NamingException ne )
747 {
748 throw ne;
749 }
750 catch ( Throwable e )
751 {
752 throwInterceptorException( head, e );
753 throw new InternalError();
754 }
755 }
756
757
758 public void modifyRn( Name name, String newRn, boolean deleteOldRn ) throws NamingException
759 {
760 Interceptor head = this.head.configuration.getInterceptor();
761 NextInterceptor next = this.head.nextInterceptor;
762 try
763 {
764 head.modifyRn( next, name, newRn, deleteOldRn );
765 }
766 catch ( NamingException ne )
767 {
768 throw ne;
769 }
770 catch ( Throwable e )
771 {
772 throwInterceptorException( head, e );
773 }
774 }
775
776
777 public void move( Name oriChildName, Name newParentName ) throws NamingException
778 {
779 Interceptor head = this.head.configuration.getInterceptor();
780 NextInterceptor next = this.head.nextInterceptor;
781 try
782 {
783 head.move( next, oriChildName, newParentName );
784 }
785 catch ( NamingException ne )
786 {
787 throw ne;
788 }
789 catch ( Throwable e )
790 {
791 throwInterceptorException( head, e );
792 }
793 }
794
795
796 public void move( Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
797 {
798 Interceptor head = this.head.configuration.getInterceptor();
799 NextInterceptor next = this.head.nextInterceptor;
800 try
801 {
802 head.move( next, oriChildName, newParentName, newRn, deleteOldRn );
803 }
804 catch ( NamingException ne )
805 {
806 throw ne;
807 }
808 catch ( Throwable e )
809 {
810 throwInterceptorException( head, e );
811 }
812 }
813
814
815 /***
816 * Represents an internal entry of this chain.
817 */
818 private class Entry
819 {
820 private Entry prevEntry;
821
822 private Entry nextEntry;
823
824 private final InterceptorConfiguration configuration;
825
826 private final NextInterceptor nextInterceptor;
827
828
829 private Entry( Entry prevEntry, Entry nextEntry,
830 InterceptorConfiguration configuration )
831 {
832 if( configuration == null )
833 {
834 throw new NullPointerException( "configuration" );
835 }
836
837 this.prevEntry = prevEntry;
838 this.nextEntry = nextEntry;
839 this.configuration = configuration;
840 this.nextInterceptor = new NextInterceptor()
841 {
842 public Attributes getRootDSE() throws NamingException
843 {
844 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
845
846 try
847 {
848 return interceptor.getRootDSE( Entry.this.nextEntry.nextInterceptor );
849 }
850 catch ( NamingException ne )
851 {
852 throw ne;
853 }
854 catch ( Throwable e )
855 {
856 throwInterceptorException( interceptor, e );
857 throw new InternalError();
858 }
859 }
860
861 public Name getMatchedName( Name dn, boolean normalized ) throws NamingException
862 {
863 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
864
865 try
866 {
867 return interceptor.getMatchedName( Entry.this.nextEntry.nextInterceptor, dn, normalized );
868 }
869 catch ( NamingException ne )
870 {
871 throw ne;
872 }
873 catch ( Throwable e )
874 {
875 throwInterceptorException( interceptor, e );
876 throw new InternalError();
877 }
878 }
879
880 public Name getSuffix( Name dn, boolean normalized ) throws NamingException
881 {
882 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
883
884 try
885 {
886 return interceptor.getSuffix( Entry.this.nextEntry.nextInterceptor, dn, normalized );
887 }
888 catch ( NamingException ne )
889 {
890 throw ne;
891 }
892 catch ( Throwable e )
893 {
894 throwInterceptorException( interceptor, e );
895 throw new InternalError();
896 }
897 }
898
899 public Iterator listSuffixes( boolean normalized ) throws NamingException
900 {
901 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
902
903 try
904 {
905 return interceptor.listSuffixes( Entry.this.nextEntry.nextInterceptor, normalized );
906 }
907 catch ( NamingException ne )
908 {
909 throw ne;
910 }
911 catch ( Throwable e )
912 {
913 throwInterceptorException( interceptor, e );
914 throw new InternalError();
915 }
916 }
917
918 public void delete( Name name ) throws NamingException
919 {
920 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
921
922 try
923 {
924 interceptor.delete( Entry.this.nextEntry.nextInterceptor, name );
925 }
926 catch ( NamingException ne )
927 {
928 throw ne;
929 }
930 catch ( Throwable e )
931 {
932 throwInterceptorException( interceptor, e );
933 }
934 }
935
936 public void add( String upName, Name normName, Attributes entry ) throws NamingException
937 {
938 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
939
940 try
941 {
942 interceptor.add( Entry.this.nextEntry.nextInterceptor, upName, normName, entry );
943 }
944 catch ( NamingException ne )
945 {
946 throw ne;
947 }
948 catch ( Throwable e )
949 {
950 throwInterceptorException( interceptor, e );
951 }
952 }
953
954 public void modify( Name name, int modOp, Attributes mods ) throws NamingException
955 {
956 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
957
958 try
959 {
960 interceptor.modify( Entry.this.nextEntry.nextInterceptor, name, modOp, mods );
961 }
962 catch ( NamingException ne )
963 {
964 throw ne;
965 }
966 catch ( Throwable e )
967 {
968 throwInterceptorException( interceptor, e );
969 }
970 }
971
972 public void modify( Name name, ModificationItem[] mods ) throws NamingException
973 {
974 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
975
976 try
977 {
978 interceptor.modify( Entry.this.nextEntry.nextInterceptor, name, mods );
979 }
980 catch ( NamingException ne )
981 {
982 throw ne;
983 }
984 catch ( Throwable e )
985 {
986 throwInterceptorException( interceptor, e );
987 }
988 }
989
990 public NamingEnumeration list( Name base ) throws NamingException
991 {
992 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
993
994 try
995 {
996 return interceptor.list( Entry.this.nextEntry.nextInterceptor, base );
997 }
998 catch ( NamingException ne )
999 {
1000 throw ne;
1001 }
1002 catch ( Throwable e )
1003 {
1004 throwInterceptorException( interceptor, e );
1005 throw new InternalError();
1006 }
1007 }
1008
1009 public NamingEnumeration search( Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
1010 {
1011 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1012
1013 try
1014 {
1015 return interceptor.search( Entry.this.nextEntry.nextInterceptor, base, env, filter, searchCtls );
1016 }
1017 catch ( NamingException ne )
1018 {
1019 throw ne;
1020 }
1021 catch ( Throwable e )
1022 {
1023 throwInterceptorException( interceptor, e );
1024 throw new InternalError();
1025 }
1026 }
1027
1028 public Attributes lookup( Name name ) throws NamingException
1029 {
1030 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1031
1032 try
1033 {
1034 return interceptor.lookup( Entry.this.nextEntry.nextInterceptor, name );
1035 }
1036 catch ( NamingException ne )
1037 {
1038 throw ne;
1039 }
1040 catch ( Throwable e )
1041 {
1042 throwInterceptorException( interceptor, e );
1043 throw new InternalError();
1044 }
1045 }
1046
1047 public Attributes lookup( Name dn, String[] attrIds ) throws NamingException
1048 {
1049 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1050
1051 try
1052 {
1053 return interceptor.lookup( Entry.this.nextEntry.nextInterceptor, dn, attrIds );
1054 }
1055 catch ( NamingException ne )
1056 {
1057 throw ne;
1058 }
1059 catch ( Throwable e )
1060 {
1061 throwInterceptorException( interceptor, e );
1062 throw new InternalError();
1063 }
1064 }
1065
1066 public boolean hasEntry( Name name ) throws NamingException
1067 {
1068 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1069
1070 try
1071 {
1072 return interceptor.hasEntry( Entry.this.nextEntry.nextInterceptor, name );
1073 }
1074 catch ( NamingException ne )
1075 {
1076 throw ne;
1077 }
1078 catch ( Throwable e )
1079 {
1080 throwInterceptorException( interceptor, e );
1081 throw new InternalError();
1082 }
1083 }
1084
1085 public boolean isSuffix( Name name ) throws NamingException
1086 {
1087 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1088
1089 try
1090 {
1091 return interceptor.isSuffix( Entry.this.nextEntry.nextInterceptor, name );
1092 }
1093 catch ( NamingException ne )
1094 {
1095 throw ne;
1096 }
1097 catch ( Throwable e )
1098 {
1099 throwInterceptorException( interceptor, e );
1100 throw new InternalError();
1101 }
1102 }
1103
1104 public void modifyRn( Name name, String newRn, boolean deleteOldRn ) throws NamingException
1105 {
1106 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1107
1108 try
1109 {
1110 interceptor.modifyRn( Entry.this.nextEntry.nextInterceptor, name, newRn, deleteOldRn );
1111 }
1112 catch ( NamingException ne )
1113 {
1114 throw ne;
1115 }
1116 catch ( Throwable e )
1117 {
1118 throwInterceptorException( interceptor, e );
1119 }
1120 }
1121
1122 public void move( Name oriChildName, Name newParentName ) throws NamingException
1123 {
1124 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1125
1126 try
1127 {
1128 interceptor.move( Entry.this.nextEntry.nextInterceptor, oriChildName, newParentName );
1129 }
1130 catch ( NamingException ne )
1131 {
1132 throw ne;
1133 }
1134 catch ( Throwable e )
1135 {
1136 throwInterceptorException( interceptor, e );
1137 }
1138 }
1139
1140 public void move( Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
1141 {
1142 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1143
1144 try
1145 {
1146 interceptor.move( Entry.this.nextEntry.nextInterceptor, oriChildName, newParentName, newRn, deleteOldRn );
1147 }
1148 catch ( NamingException ne )
1149 {
1150 throw ne;
1151 }
1152 catch ( Throwable e )
1153 {
1154 throwInterceptorException( interceptor, e );
1155 }
1156 }
1157
1158 public void addContextPartition( ContextPartitionConfiguration cfg ) throws NamingException
1159 {
1160 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1161
1162 try
1163 {
1164 interceptor.addContextPartition( Entry.this.nextEntry.nextInterceptor, cfg );
1165 }
1166 catch ( NamingException ne )
1167 {
1168 throw ne;
1169 }
1170 catch ( Throwable e )
1171 {
1172 throwInterceptorException( interceptor, e );
1173 throw new InternalError();
1174 }
1175 }
1176
1177 public void removeContextPartition( Name suffix ) throws NamingException
1178 {
1179 Interceptor interceptor = Entry.this.nextEntry.configuration.getInterceptor();
1180
1181 try
1182 {
1183 interceptor.removeContextPartition( Entry.this.nextEntry.nextInterceptor, suffix );
1184 }
1185 catch ( NamingException ne )
1186 {
1187 throw ne;
1188 }
1189 catch ( Throwable e )
1190 {
1191 throwInterceptorException( interceptor, e );
1192 throw new InternalError();
1193 }
1194 }
1195 };
1196 }
1197 }
1198
1199
1200 private static void throwInterceptorException( Interceptor interceptor, Throwable e ) throws InterceptorException
1201 {
1202 throw new InterceptorException( interceptor, "Unexpected exception.", e );
1203 }
1204 }