001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2006-2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.api.plugin;
028    
029    import org.opends.messages.Message;
030    import org.opends.server.types.ResultCode;
031    import org.opends.server.types.DN;
032    import org.opends.server.types.DisconnectReason;
033    
034    import java.util.List;
035    
036    /**
037     * This class defines a data structure that holds information about
038     * the result of processing by a plugin.
039     */
040    @org.opends.server.types.PublicAPI(
041        stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
042        mayInstantiate=true,
043        mayExtend=false,
044        mayInvoke=true)
045    public final class PluginResult
046    {
047      /**
048       * Defines a startup plugin result consisting of either continue
049       * skip further plugins, or stop startup with an error message.
050       */
051      public static final class Startup
052      {
053        // Whether to continue startup.
054        private final boolean continueProcessing;
055    
056        // Whether to invoke the rest of the plugins.
057        private final boolean continuePluginProcessing;
058    
059        // An message explaining why startup should stop.
060        private final Message errorMessage;
061    
062        private static Startup DEFAULT_RESULT =
063            new Startup(true, true, null);
064    
065        /**
066         * Construct a new startup plugin result.
067         *
068         * @param continueProcessing Whether to continue startup.
069         * @param continuePluginProcessing Whether to invoke the rest
070         * of the plugins.
071         * @param errorMessage An message explaining why startup should
072         * stop.
073         */
074        private Startup(boolean continueProcessing,
075                        boolean continuePluginProcessing,
076                        Message errorMessage)
077        {
078          this.continueProcessing = continueProcessing;
079          this.errorMessage = errorMessage;
080          this.continuePluginProcessing = continuePluginProcessing;
081        }
082    
083        /**
084         * Defines a continue processing startup plugin result.
085         *
086         * @return a continue processing startup plugin result.
087         */
088        public static Startup continueStartup()
089        {
090          return DEFAULT_RESULT;
091        }
092    
093        /**
094         * Defines a skip further plugin processing startup plugin result.
095         *
096         * @return  a skip further plugin processing startup plugin
097         * result.
098         */
099        public static Startup skipFurtherPluginProcesssing()
100        {
101          return new Startup(true, false, null);
102        }
103    
104        /**
105         * Defines a new stop processing startup plugin result.
106         *
107         * @param errorMessage An message explaining why processing
108         * should stop for the given entry.
109         *
110         * @return a new stop processing startup plugin result.
111         */
112        public static Startup stopStartup(Message errorMessage)
113        {
114          return new Startup(false, false, errorMessage);
115        }
116    
117        /**
118         * Whether to continue startup.
119         *
120         * @return <code>true</code> if processing should continue
121         * or <code>false</code> otherwise.
122         */
123        public boolean continueProcessing()
124        {
125          return continueProcessing;
126        }
127    
128        /**
129         * Whether to invoke the rest of the plugins.
130         *
131         * @return <code>true</code> if the rest of the plugins should
132         * be invoked for <code>false</code> to skip the rest of the
133         * plugins.
134         */
135        public boolean continuePluginProcessing()
136        {
137          return continuePluginProcessing;
138        }
139    
140        /**
141         * Retrieves the error message if <code>continueProcessing</code>
142         * returned <code>false</code>.
143         *
144         * @return An error message explaining why processing should
145         * stop or <code>null</code> if none is provided.
146         */
147        public Message getErrorMessage()
148        {
149          return errorMessage;
150        }
151      }
152    
153      /**
154       * Defines a pre parse plugin result for core server operation
155       * processing consisting of either continue, skip further
156       * plugins, or stop operation processing with a result code,
157       * matched DN, referral URLs, and error message.
158       */
159      public static final class PreParse
160      {
161        // Whether to continue operation processing.
162        private final boolean continueProcessing;
163    
164        // Whether to invoke the rest of the plugins.
165        private final boolean continuePluginProcessing;
166    
167        // An message explaining why processing should stop.
168        private final Message errorMessage;
169    
170        // The matched DN for this result.
171        private final DN matchedDN;
172    
173        // The set of referral URLs for this result.
174        private final List<String> referralURLs;
175    
176        // The result code for this result.
177        private final ResultCode resultCode;
178    
179        private static PreParse DEFAULT_RESULT =
180            new PreParse(true, true, null, null, null, null);
181    
182        /**
183         * Construct a new pre parse plugin result.
184         *
185         * @param continueProcessing Whether to continue startup.
186         * @param continuePluginProcessing Whether to invoke the rest
187         * of the plugins.
188         * @param errorMessage An message explaining why processing
189         * should stop.
190         * @param resultCode The result code for this result.
191         * @param matchedDN The matched DN for this result.
192         * @param referralURLs The set of referral URLs for this result.
193         * stop.
194         */
195        private PreParse (boolean continueProcessing,
196                          boolean continuePluginProcessing,
197                          Message errorMessage,
198                          ResultCode resultCode, DN matchedDN,
199                          List<String> referralURLs)
200        {
201          this.continueProcessing = continueProcessing;
202          this.errorMessage = errorMessage;
203          this.continuePluginProcessing = continuePluginProcessing;
204          this.resultCode = resultCode;
205          this.matchedDN = matchedDN;
206          this.referralURLs = referralURLs;
207        }
208    
209        /**
210         * Defines a continue processing pre parse plugin result.
211         *
212         * @return a continue processing pre parse plugin result.
213         */
214        public static PreParse continueOperationProcessing()
215        {
216          return DEFAULT_RESULT;
217        }
218    
219        /**
220         * Defines a skip further plugin processing pre parse plugin
221         * result.
222         *
223         * @return  a skip further plugin processing pre parse plugin
224         * result.
225         */
226        public static PreParse skipFurtherPluginProcesssing()
227        {
228          return new PreParse(true, false, null, null, null, null);
229        }
230    
231        /**
232         * Defines a new stop processing pre parse plugin result.
233         *
234         * @param resultCode The result code for this result.
235         * @param errorMessage An message explaining why processing
236         * should stop.
237         * @param matchedDN The matched DN for this result.
238         * @param referralURLs The set of referral URLs for this result.
239         *
240         * @return a new stop processing pre parse plugin result.
241         */
242        public static PreParse stopProcessing(ResultCode resultCode,
243                                              Message errorMessage,
244                                              DN matchedDN,
245                                              List<String> referralURLs)
246        {
247          return new PreParse(false, false, errorMessage, resultCode,
248              matchedDN, referralURLs);
249        }
250    
251        /**
252         * Contrust a new stop processing pre parse plugin result.
253         *
254         * @param resultCode The result code for this result.
255         * @param errorMessage An message explaining why processing
256         * should stop.
257         *
258         * @return a new stop processing pre parse plugin result.
259         */
260        public static PreParse stopProcessing(ResultCode resultCode,
261                                              Message errorMessage)
262        {
263          return new PreParse(false, false, errorMessage, resultCode,
264              null, null);
265        }
266    
267        /**
268         * Whether to continue operation processing.
269         *
270         * @return <code>true</code> if processing should continue
271         * or <code>false</code> otherwise.
272         */
273        public boolean continueProcessing()
274        {
275          return continueProcessing;
276        }
277    
278        /**
279         * Whether to invoke the rest of the plugins.
280         *
281         * @return <code>true</code> if the rest of the plugins should
282         * be invoked for <code>false</code> to skip the rest of the
283         * plugins.
284         */
285        public boolean continuePluginProcessing()
286        {
287          return continuePluginProcessing;
288        }
289    
290        /**
291         * Retrieves the error message if <code>continueProcessing</code>
292         * returned <code>false</code>.
293         *
294         * @return An error message explaining why processing should
295         * stop or <code>null</code> if none is provided.
296         */
297        public Message getErrorMessage()
298        {
299          return errorMessage;
300        }
301    
302        /**
303         * Retrieves the result code for the operation
304         * if <code>continueProcessing</code> returned <code>false</code>.
305         *
306         * @return the result code for the operation or <code>null</code>
307         * if none is provided.
308         */
309        public ResultCode getResultCode()
310        {
311          return resultCode;
312        }
313    
314        /**
315         * Retrieves the matched DN for the operation
316         * if <code>continueProcessing</code> returned <code>false</code>.
317         *
318         * @return the matched DN for the operation or <code>null</code>
319         * if none is provided.
320         */
321        public DN getMatchedDN()
322        {
323          return matchedDN;
324        }
325    
326        /**
327         * Retrieves the referral URLs for the operation
328         * if <code>continueProcessing</code> returned <code>false</code>.
329         *
330         * @return the refferal URLs for the operation or
331         * <code>null</code> if none is provided.
332         */
333        public List<String> getReferralURLs()
334        {
335          return referralURLs;
336        }
337      }
338    
339      /**
340       * Defines a pre operation plugin result for core server operation
341       * processing consisting of either continue, skip further
342       * plugins, or stop operation processing with a result code,
343       * matched DN, referral URLs, and error message.
344       */
345      public static final class PreOperation
346      {
347        // Whether to continue operation processing.
348        private final boolean continueProcessing;
349    
350        // Whether to invoke the rest of the plugins.
351        private final boolean continuePluginProcessing;
352    
353        // An message explaining why processing should stop.
354        private final Message errorMessage;
355    
356        // The matched DN for this result.
357        private final DN matchedDN;
358    
359        // The set of referral URLs for this result.
360        private final List<String> referralURLs;
361    
362        // The result code for this result.
363        private final ResultCode resultCode;
364    
365        private static PreOperation DEFAULT_RESULT =
366            new PreOperation(true, true, null, null, null, null);
367    
368        /**
369         * Construct a new pre operation plugin result.
370         *
371         * @param continueProcessing Whether to continue startup.
372         * @param continuePluginProcessing Whether to invoke the rest
373         * of the plugins.
374         * @param errorMessage An message explaining why processing
375         * should stop.
376         * @param resultCode The result code for this result.
377         * @param matchedDN The matched DN for this result.
378         * @param referralURLs The set of referral URLs for this result.
379         * stop.
380         */
381        private PreOperation (boolean continueProcessing,
382                              boolean continuePluginProcessing,
383                              Message errorMessage,
384                              ResultCode resultCode, DN matchedDN,
385                              List<String> referralURLs)
386        {
387          this.continueProcessing = continueProcessing;
388          this.errorMessage = errorMessage;
389          this.continuePluginProcessing = continuePluginProcessing;
390          this.resultCode = resultCode;
391          this.matchedDN = matchedDN;
392          this.referralURLs = referralURLs;
393        }
394    
395        /**
396         * Defines a continue processing pre operation plugin result.
397         *
398         * @return a continue processing pre operation plugin result.
399         */
400        public static PreOperation continueOperationProcessing()
401        {
402          return DEFAULT_RESULT;
403        }
404    
405        /**
406         * Defines a skip further plugin processing pre operation plugin
407         * result.
408         *
409         * @return  a skip further plugin processing pre operation plugin
410         * result.
411         */
412        public static PreOperation skipFurtherPluginProcesssing()
413        {
414          return new PreOperation(true, false, null, null, null, null);
415        }
416    
417        /**
418         * Defines a new stop processing pre operation plugin result.
419         *
420         * @param resultCode The result code for this result.
421         * @param errorMessage An message explaining why processing
422         * should stop.
423         * @param matchedDN The matched DN for this result.
424         * @param referralURLs The set of referral URLs for this result.
425         *
426         * @return a new stop processing pre operation plugin result.
427         */
428        public static PreOperation stopProcessing(
429            ResultCode resultCode, Message errorMessage, DN matchedDN,
430            List<String> referralURLs)
431        {
432          return new PreOperation(false, false, errorMessage, resultCode,
433              matchedDN, referralURLs);
434        }
435    
436        /**
437         * Contrust a new stop processing pre operation plugin result.
438         *
439         * @param resultCode The result code for this result.
440         * @param errorMessage An message explaining why processing
441         * should stop.
442         *
443         * @return a new stop processing pre operation plugin result.
444         */
445        public static PreOperation stopProcessing(ResultCode resultCode,
446                                                  Message errorMessage)
447        {
448          return new PreOperation(false, false, errorMessage, resultCode,
449              null, null);
450        }
451    
452        /**
453         * Whether to continue operation processing.
454         *
455         * @return <code>true</code> if processing should continue
456         * or <code>false</code> otherwise.
457         */
458        public boolean continueProcessing()
459        {
460          return continueProcessing;
461        }
462    
463        /**
464         * Whether to invoke the rest of the plugins.
465         *
466         * @return <code>true</code> if the rest of the plugins should
467         * be invoked for <code>false</code> to skip the rest of the
468         * plugins.
469         */
470        public boolean continuePluginProcessing()
471        {
472          return continuePluginProcessing;
473        }
474    
475        /**
476         * Retrieves the error message if <code>continueProcessing</code>
477         * returned <code>false</code>.
478         *
479         * @return An error message explaining why processing should
480         * stop or <code>null</code> if none is provided.
481         */
482        public Message getErrorMessage()
483        {
484          return errorMessage;
485        }
486    
487        /**
488         * Retrieves the result code for the operation
489         * if <code>continueProcessing</code> returned <code>false</code>.
490         *
491         * @return the result code for the operation or <code>null</code>
492         * if none is provided.
493         */
494        public ResultCode getResultCode()
495        {
496          return resultCode;
497        }
498    
499        /**
500         * Retrieves the matched DN for the operation
501         * if <code>continueProcessing</code> returned <code>false</code>.
502         *
503         * @return the matched DN for the operation or <code>null</code>
504         * if none is provided.
505         */
506        public DN getMatchedDN()
507        {
508          return matchedDN;
509        }
510    
511        /**
512         * Retrieves the referral URLs for the operation
513         * if <code>continueProcessing</code> returned <code>false</code>.
514         *
515         * @return the refferal URLs for the operation or
516         * <code>null</code> if none is provided.
517         */
518        public List<String> getReferralURLs()
519        {
520          return referralURLs;
521        }
522      }
523    
524      /**
525       * Defines a post operation plugin result for core server operation
526       * processing consisting of either continue, skip further
527       * plugins, or stop operation processing with a result code,
528       * matched DN, referral URLs, and error message.
529       */
530      public static final class PostOperation
531      {
532        // Whether to continue operation processing.
533        private final boolean continueProcessing;
534    
535        // An message explaining why processing should stop.
536        private final Message errorMessage;
537    
538        // The matched DN for this result.
539        private final DN matchedDN;
540    
541        // The set of referral URLs for this result.
542        private final List<String> referralURLs;
543    
544        // The result code for this result.
545        private final ResultCode resultCode;
546    
547        private static PostOperation DEFAULT_RESULT =
548            new PostOperation(true, null, null, null, null);
549    
550        /**
551         * Constructs a new post operation plugin result.
552         *
553         * @param continueProcessing Whether to continue startup.
554         * @param errorMessage An message explaining why processing
555         * should stop.
556         * @param resultCode The result code for this result.
557         * @param matchedDN The matched DN for this result.
558         * @param referralURLs The set of referral URLs for this result.
559         */
560        private PostOperation(boolean continueProcessing,
561                              Message errorMessage,
562                              ResultCode resultCode, DN matchedDN,
563                              List<String> referralURLs)
564        {
565          this.continueProcessing = continueProcessing;
566          this.errorMessage = errorMessage;
567          this.resultCode = resultCode;
568          this.matchedDN = matchedDN;
569          this.referralURLs = referralURLs;
570        }
571    
572        /**
573         * Defines a continue processing post operation plugin result.
574         *
575         * @return a continue processing post operation plugin result.
576         */
577        public static PostOperation continueOperationProcessing()
578        {
579          return DEFAULT_RESULT;
580        }
581    
582        /**
583         * Defines a new stop processing post operation plugin result.
584         *
585         * @param resultCode The result code for this result.
586         * @param errorMessage An message explaining why processing
587         * should stop.
588         * @param matchedDN The matched DN for this result.
589         * @param referralURLs The set of referral URLs for this result.
590         *
591         * @return a new stop processing post operation plugin result.
592         */
593        public static PostOperation stopProcessing(
594            ResultCode resultCode, Message errorMessage, DN matchedDN,
595            List<String> referralURLs)
596        {
597          return new PostOperation(false, errorMessage, resultCode,
598              matchedDN, referralURLs);
599        }
600    
601        /**
602         * Contrust a new stop processing post operation plugin result.
603         *
604         * @param resultCode The result code for this result.
605         * @param errorMessage An message explaining why processing
606         * should stop.
607         *
608         * @return a new stop processing post operation plugin result.
609         */
610        public static PostOperation stopProcessing(ResultCode resultCode,
611                                                   Message errorMessage)
612        {
613          return new PostOperation(false, errorMessage, resultCode, null,
614              null);
615        }
616    
617        /**
618         * Whether to continue operation processing.
619         *
620         * @return <code>true</code> if processing should continue
621         * or <code>false</code> otherwise.
622         */
623        public boolean continueProcessing()
624        {
625          return continueProcessing;
626        }
627    
628        /**
629         * Retrieves the error message if <code>continueProcessing</code>
630         * returned <code>false</code>.
631         *
632         * @return An error message explaining why processing should
633         * stop or <code>null</code> if none is provided.
634         */
635        public Message getErrorMessage()
636        {
637          return errorMessage;
638        }
639    
640        /**
641         * Retrieves the result code for the operation
642         * if <code>continueProcessing</code> returned <code>false</code>.
643         *
644         * @return the result code for the operation or <code>null</code>
645         * if none is provided.
646         */
647        public ResultCode getResultCode()
648        {
649          return resultCode;
650        }
651    
652        /**
653         * Retrieves the matched DN for the operation
654         * if <code>continueProcessing</code> returned <code>false</code>.
655         *
656         * @return the matched DN for the operation or <code>null</code>
657         * if none is provided.
658         */
659        public DN getMatchedDN()
660        {
661          return matchedDN;
662        }
663    
664        /**
665         * Retrieves the referral URLs for the operation
666         * if <code>continueProcessing</code> returned <code>false</code>.
667         *
668         * @return the refferal URLs for the operation or
669         * <code>null</code> if none is provided.
670         */
671        public List<String> getReferralURLs()
672        {
673          return referralURLs;
674        }
675      }
676    
677    
678      /**
679       * Defines a post response plugin result for core server operation
680       * processing consisting of either continue or skip further
681       * plugins.
682       */
683      public static final class PostResponse
684      {
685        // Whether to invoke the rest of the plugins.
686        private final boolean continuePluginProcessing;
687    
688        private static PostResponse DEFAULT_RESULT =
689            new PostResponse(true);
690    
691        /**
692         * Constructs a new post response plugin result.
693         *
694         * @param continuePluginProcessing Whether to invoke the rest
695         * of the plugins.
696         */
697        private PostResponse (boolean continuePluginProcessing)
698        {
699          this.continuePluginProcessing = continuePluginProcessing;
700        }
701    
702        /**
703         * Defines a continue processing post response plugin result.
704         *
705         * @return a continue processing post response plugin result.
706         */
707        public static PostResponse continueOperationProcessing()
708        {
709          return DEFAULT_RESULT;
710        }
711    
712        /**
713         * Defines a skip further plugin processing post response plugin
714         *  result.
715         *
716         * @return  a skip further plugin processing post response plugin
717         *  result.
718         */
719        public static PostResponse skipFurtherPluginProcesssing()
720        {
721          return new PostResponse(false);
722        }
723    
724        /**
725         * Whether to invoke the rest of the plugins.
726         *
727         * @return <code>true</code> if the rest of the plugins should
728         * be invoked for <code>false</code> to skip the rest of the
729         * plugins.
730         */
731        public boolean continuePluginProcessing()
732        {
733          return continuePluginProcessing;
734        }
735      }
736    
737      /**
738       * Defines a LDIF plugin result for import from LDIF
739       * processing consisting of either continue, skip further
740       * plugins, or stop processing with an error message.
741       */
742      public static final class ImportLDIF
743      {
744        // Whether to continue operation processing.
745        private final boolean continueProcessing;
746    
747        // Whether to invoke the rest of the plugins.
748        private final boolean continuePluginProcessing;
749    
750        // An message explaining why processing should stop.
751        private final Message errorMessage;
752    
753        private static ImportLDIF DEFAULT_RESULT =
754            new ImportLDIF(true, true, null);
755    
756        /**
757         * Construct a new import LDIF plugin result.
758         *
759         * @param continueProcessing Whether to continue startup.
760         * @param continuePluginProcessing Whether to invoke the rest
761         * of the plugins.
762         * @param errorMessage An message explaining why startup should
763         * stop.
764         */
765        private ImportLDIF(boolean continueProcessing,
766                           boolean continuePluginProcessing,
767                           Message errorMessage)
768        {
769          this.continueProcessing = continueProcessing;
770          this.errorMessage = errorMessage;
771          this.continuePluginProcessing = continuePluginProcessing;
772        }
773    
774        /**
775         * Defines a continue processing LDIF import plugin result.
776         *
777         * @return a continue processing LDIF import plugin result.
778         */
779        public static ImportLDIF continueEntryProcessing()
780        {
781          return DEFAULT_RESULT;
782        }
783    
784        /**
785         * Defines a skip further plugin processing LDIF import plugin
786         *  result.
787         *
788         * @return  a skip further plugin processing LDIF import plugin
789         *  result.
790         */
791        public static ImportLDIF skipFurtherPluginProcesssing()
792        {
793          return new ImportLDIF(true, false, null);
794        }
795    
796        /**
797         * Defines a new stop processing LDIF import plugin result.
798         *
799         * @param errorMessage An message explaining why processing
800         * should stop for the given entry.
801         *
802         * @return a new stop processing LDIF import plugin result.
803         */
804        public static ImportLDIF stopEntryProcessing(Message errorMessage)
805        {
806          return new ImportLDIF(false, false, errorMessage);
807        }
808    
809        /**
810         * Whether to continue operation processing.
811         *
812         * @return <code>true</code> if processing should continue
813         * or <code>false</code> otherwise.
814         */
815        public boolean continueProcessing()
816        {
817          return continueProcessing;
818        }
819    
820        /**
821         * Whether to invoke the rest of the plugins.
822         *
823         * @return <code>true</code> if the rest of the plugins should
824         * be invoked for <code>false</code> to skip the rest of the
825         * plugins.
826         */
827        public boolean continuePluginProcessing()
828        {
829          return continuePluginProcessing;
830        }
831    
832        /**
833         * Retrieves the error message if <code>continueProcessing</code>
834         * returned <code>false</code>.
835         *
836         * @return An error message explaining why processing should
837         * stop or <code>null</code> if none is provided.
838         */
839        public Message getErrorMessage()
840        {
841          return errorMessage;
842        }
843      }
844    
845      /**
846       * Defines a subordinate modify DN plugin result for core server
847       * operation processing consisting of either continue, skip further
848       * plugins, or stop operation processing with a result code,
849       * matched DN, referral URLs, and error message.
850       */
851      public static final class SubordinateModifyDN
852      {
853        // Whether to continue operation processing.
854        private final boolean continueProcessing;
855    
856        // Whether to invoke the rest of the plugins.
857        private final boolean continuePluginProcessing;
858    
859        // An message explaining why processing should stop.
860        private final Message errorMessage;
861    
862        // The matched DN for this result.
863        private final DN matchedDN;
864    
865        // The set of referral URLs for this result.
866        private final List<String> referralURLs;
867    
868        // The result code for this result.
869        private final ResultCode resultCode;
870    
871        private static SubordinateModifyDN DEFAULT_RESULT =
872            new SubordinateModifyDN(true, true, null, null, null, null);
873    
874        /**
875         * Construct a new subordinate modify DN plugin result.
876         *
877         * @param continueProcessing Whether to continue startup.
878         * @param continuePluginProcessing Whether to invoke the rest
879         * of the plugins.
880         * @param errorMessage An message explaining why processing
881         * should stop.
882         * @param resultCode The result code for this result.
883         * @param matchedDN The matched DN for this result.
884         * @param referralURLs The set of referral URLs for this result.
885         * stop.
886         */
887        private SubordinateModifyDN(boolean continueProcessing,
888                                    boolean continuePluginProcessing,
889                                    Message errorMessage,
890                                    ResultCode resultCode, DN matchedDN,
891                                    List<String> referralURLs)
892        {
893          this.continueProcessing = continueProcessing;
894          this.errorMessage = errorMessage;
895          this.continuePluginProcessing = continuePluginProcessing;
896          this.resultCode = resultCode;
897          this.matchedDN = matchedDN;
898          this.referralURLs = referralURLs;
899        }
900    
901        /**
902         * Defines a continue processing subordinate modify DN plugin
903         *  result.
904         *
905         * @return a continue processing subordinate modify DN plugin
906         *  result.
907         */
908        public static SubordinateModifyDN continueOperationProcessing()
909        {
910          return DEFAULT_RESULT;
911        }
912    
913        /**
914         * Defines a skip further plugin processing subordinate modify DN
915         * plugin result.
916         *
917         * @return  a skip further plugin processing subordinate modify DN
918         * plugin result.
919         */
920        public static SubordinateModifyDN skipFurtherPluginProcesssing()
921        {
922          return new SubordinateModifyDN(true, false, null, null, null,
923              null);
924        }
925    
926        /**
927         * Defines a new stop processing subordinate modify DN plugin
928         * result.
929         *
930         * @param resultCode The result code for this result.
931         * @param errorMessage An message explaining why processing
932         * should stop.
933         * @param matchedDN The matched DN for this result.
934         * @param referralURLs The set of referral URLs for this result.
935         *
936         * @return a new stop processing subordinate modify DN plugin
937         * result.
938         */
939        public static SubordinateModifyDN stopProcessing(
940            ResultCode resultCode, Message errorMessage, DN matchedDN,
941            List<String> referralURLs)
942        {
943          return new SubordinateModifyDN(false, false, errorMessage,
944              resultCode, matchedDN, referralURLs);
945        }
946    
947        /**
948         * Contrust a new stop processing subordinate modify DN plugin
949         * result.
950         *
951         * @param resultCode The result code for this result.
952         * @param errorMessage An message explaining why processing
953         * should stop.
954         *
955         * @return a new stop processing subordinate modify DN plugin
956         * result.
957         */
958        public static SubordinateModifyDN stopProcessing(
959            ResultCode resultCode, Message errorMessage)
960        {
961          return new SubordinateModifyDN(false, false, errorMessage,
962              resultCode, null, null);
963        }
964    
965        /**
966         * Whether to continue operation processing.
967         *
968         * @return <code>true</code> if processing should continue
969         * or <code>false</code> otherwise.
970         */
971        public boolean continueProcessing()
972        {
973          return continueProcessing;
974        }
975    
976        /**
977         * Whether to invoke the rest of the plugins.
978         *
979         * @return <code>true</code> if the rest of the plugins should
980         * be invoked for <code>false</code> to skip the rest of the
981         * plugins.
982         */
983        public boolean continuePluginProcessing()
984        {
985          return continuePluginProcessing;
986        }
987    
988        /**
989         * Retrieves the error message if <code>continueProcessing</code>
990         * returned <code>false</code>.
991         *
992         * @return An error message explaining why processing should
993         * stop or <code>null</code> if none is provided.
994         */
995        public Message getErrorMessage()
996        {
997          return errorMessage;
998        }
999    
1000        /**
1001         * Retrieves the result code for the operation
1002         * if <code>continueProcessing</code> returned <code>false</code>.
1003         *
1004         * @return the result code for the operation or <code>null</code>
1005         * if none is provided.
1006         */
1007        public ResultCode getResultCode()
1008        {
1009          return resultCode;
1010        }
1011    
1012        /**
1013         * Retrieves the matched DN for the operation
1014         * if <code>continueProcessing</code> returned <code>false</code>.
1015         *
1016         * @return the matched DN for the operation or <code>null</code>
1017         * if none is provided.
1018         */
1019        public DN getMatchedDN()
1020        {
1021          return matchedDN;
1022        }
1023    
1024        /**
1025         * Retrieves the referral URLs for the operation
1026         * if <code>continueProcessing</code> returned <code>false</code>.
1027         *
1028         * @return the refferal URLs for the operation or
1029         * <code>null</code> if none is provided.
1030         */
1031        public List<String> getReferralURLs()
1032        {
1033          return referralURLs;
1034        }
1035      }
1036    
1037      /**
1038       * Defines an intermediate response plugin result for core server
1039       *  operation processing consisting of either continue, skip further
1040       * plugins, or stop operation processing with a result code,
1041       * matched DN, referral URLs, and error message.
1042       */
1043      public static final class IntermediateResponse
1044      {
1045        // Whether to continue operation processing.
1046        private final boolean continueProcessing;
1047    
1048        // Whether to invoke the rest of the plugins.
1049        private final boolean continuePluginProcessing;
1050    
1051        // Whether to send the intermediate response to the client.
1052        private final boolean sendResponse;
1053    
1054        // An message explaining why processing should stop.
1055        private final Message errorMessage;
1056    
1057        // The matched DN for this result.
1058        private final DN matchedDN;
1059    
1060        // The set of referral URLs for this result.
1061        private final List<String> referralURLs;
1062    
1063        // The result code for this result.
1064        private final ResultCode resultCode;
1065    
1066        private static IntermediateResponse DEFAULT_RESULT =
1067            new IntermediateResponse(true, true, true, null, null, null,
1068                null);
1069    
1070        /**
1071         * Construct a new intermediate response plugin result.
1072         *
1073         * @param continueProcessing Whether to continue startup.
1074         * @param continuePluginProcessing Whether to invoke the rest
1075         * of the plugins.
1076         * @param sendResponse Whether to send the intermediate response
1077         * to the client.
1078         * @param errorMessage An message explaining why processing
1079         * should stop.
1080         * @param resultCode The result code for this result.
1081         * @param matchedDN The matched DN for this result.
1082         * @param referralURLs The set of referral URLs for this result.
1083         * stop.
1084         */
1085        private IntermediateResponse(boolean continueProcessing,
1086                                     boolean continuePluginProcessing,
1087                                     boolean sendResponse,
1088                                     Message errorMessage,
1089                                     ResultCode resultCode, DN matchedDN,
1090                                     List<String> referralURLs)
1091        {
1092          this.continueProcessing = continueProcessing;
1093          this.errorMessage = errorMessage;
1094          this.continuePluginProcessing = continuePluginProcessing;
1095          this.resultCode = resultCode;
1096          this.matchedDN = matchedDN;
1097          this.referralURLs = referralURLs;
1098          this.sendResponse = sendResponse;
1099        }
1100    
1101        /**
1102         * Defines a continue processing intermediate response plugin
1103         * result.
1104         *
1105         * @param sendResponse Whether to send the intermediate response
1106         * to the client.
1107         * @return a continue processing intermediate response plugin
1108         * result.
1109         */
1110        public static IntermediateResponse
1111        continueOperationProcessing(boolean sendResponse)
1112        {
1113          if(sendResponse)
1114          {
1115            return DEFAULT_RESULT;
1116          }
1117          else
1118          {
1119            return new IntermediateResponse(true, true, sendResponse,
1120                null, null, null, null);
1121          }
1122        }
1123    
1124        /**
1125         * Defines a skip further plugin processing intermediate response
1126         * plugin result.
1127         *
1128         * @param sendResponse Whether to send the intermediate response
1129         * to the client.
1130         *
1131         * @return  a skip further plugin processing intermediate response
1132         * plugin result.
1133         */
1134        public static IntermediateResponse
1135        skipFurtherPluginProcesssing(boolean sendResponse)
1136        {
1137          return new IntermediateResponse(true, false, sendResponse,
1138              null, null, null, null);
1139        }
1140    
1141        /**
1142         * Defines a new stop processing intermediate response plugin
1143         * result.
1144         *
1145         * @param sendResponse Whether to send the intermediate response
1146         * to the client.
1147         * @param resultCode The result code for this result.
1148         * @param errorMessage An message explaining why processing
1149         * should stop.
1150         * @param matchedDN The matched DN for this result.
1151         * @param referralURLs The set of referral URLs for this result.
1152         *
1153         * @return a new stop processing intermediate response plugin
1154         * result.
1155         */
1156        public static IntermediateResponse stopProcessing(
1157            boolean sendResponse, ResultCode resultCode,
1158            Message errorMessage, DN matchedDN, List<String> referralURLs)
1159        {
1160          return new IntermediateResponse(false, false, sendResponse,
1161              errorMessage, resultCode, matchedDN, referralURLs);
1162        }
1163    
1164        /**
1165         * Contrust a new stop processing intermediate response plugin
1166         * result.
1167         *
1168         * @param sendResponse Whether to send the intermediate response
1169         * to the client.
1170         * @param resultCode The result code for this result.
1171         * @param errorMessage An message explaining why processing
1172         * should stop.
1173         *
1174         * @return a new stop processing intermediate response plugin
1175         * result.
1176         */
1177        public static IntermediateResponse stopProcessing(
1178            boolean sendResponse, ResultCode resultCode,
1179            Message errorMessage)
1180        {
1181          return new IntermediateResponse(false, false, sendResponse,
1182              errorMessage, resultCode, null, null);
1183        }
1184    
1185        /**
1186         * Whether to continue operation processing.
1187         *
1188         * @return <code>true</code> if processing should continue
1189         * or <code>false</code> otherwise.
1190         */
1191        public boolean continueProcessing()
1192        {
1193          return continueProcessing;
1194        }
1195    
1196        /**
1197         * Whether to invoke the rest of the plugins.
1198         *
1199         * @return <code>true</code> if the rest of the plugins should
1200         * be invoked for <code>false</code> to skip the rest of the
1201         * plugins.
1202         */
1203        public boolean continuePluginProcessing()
1204        {
1205          return continuePluginProcessing;
1206        }
1207    
1208        /**
1209         * Whether to send the intermediate response to the client.
1210         *
1211         * @return <code>true</code> if the intermediate response should
1212         * be sent to the client or <code>false</code> otherwise.
1213         */
1214        public boolean sendResponse()
1215        {
1216          return sendResponse;
1217        }
1218    
1219        /**
1220         * Retrieves the error message if <code>continueProcessing</code>
1221         * returned <code>false</code>.
1222         *
1223         * @return An error message explaining why processing should
1224         * stop or <code>null</code> if none is provided.
1225         */
1226        public Message getErrorMessage()
1227        {
1228          return errorMessage;
1229        }
1230    
1231        /**
1232         * Retrieves the result code for the operation
1233         * if <code>continueProcessing</code> returned <code>false</code>.
1234         *
1235         * @return the result code for the operation or <code>null</code>
1236         * if none is provided.
1237         */
1238        public ResultCode getResultCode()
1239        {
1240          return resultCode;
1241        }
1242    
1243        /**
1244         * Retrieves the matched DN for the operation
1245         * if <code>continueProcessing</code> returned <code>false</code>.
1246         *
1247         * @return the matched DN for the operation or <code>null</code>
1248         * if none is provided.
1249         */
1250        public DN getMatchedDN()
1251        {
1252          return matchedDN;
1253        }
1254    
1255        /**
1256         * Retrieves the referral URLs for the operation
1257         * if <code>continueProcessing</code> returned <code>false</code>.
1258         *
1259         * @return the refferal URLs for the operation or
1260         * <code>null</code> if none is provided.
1261         */
1262        public List<String> getReferralURLs()
1263        {
1264          return referralURLs;
1265        }
1266      }
1267    
1268      /**
1269       * Defines a post connect plugin result for client connection
1270       * processing consisting of either continue, skip further
1271       * plugins, or stop.
1272       */
1273      public static final class PostConnect
1274      {
1275        // Whether to continue connection processing.
1276        private final boolean continueProcessing;
1277    
1278        // Whether to invoke the rest of the plugins.
1279        private final boolean continuePluginProcessing;
1280    
1281        // An message explaining why processing should stop.
1282        private final Message errorMessage;
1283    
1284        // The disconnect reason that provides the generic cause for the
1285        // disconnect.
1286        private final DisconnectReason disconnectReason;
1287    
1288        // Whether to send a disconnect notification to the client.
1289        private final boolean sendDisconnectNotification;
1290    
1291        private static PostConnect DEFAULT_RESULT =
1292            new PostConnect(true, true, null, null, false);
1293    
1294        /**
1295         * Construct a new post connect plugin result.
1296         *
1297         * @param continueProcessing Whether to continue startup.
1298         * @param continuePluginProcessing Whether to invoke the rest
1299         * of the plugins.
1300         * @param errorMessage An message explaining why processing
1301         * should stop.
1302         * @param disconnectReason The generic cause for the disconnect.
1303         * @param sendDisconnectNotification Whether to send a disconnect
1304         * notification to the client.
1305         */
1306        private PostConnect(boolean continueProcessing,
1307                            boolean continuePluginProcessing,
1308                            Message errorMessage,
1309                            DisconnectReason disconnectReason,
1310                            boolean sendDisconnectNotification)
1311        {
1312          this.continueProcessing = continueProcessing;
1313          this.errorMessage = errorMessage;
1314          this.continuePluginProcessing = continuePluginProcessing;
1315          this.disconnectReason = disconnectReason;
1316          this.sendDisconnectNotification = sendDisconnectNotification;
1317        }
1318    
1319        /**
1320         * Defines a continue processing post connect plugin result.
1321         *
1322         * @return a continue processing post connect plugin result.
1323         */
1324        public static PostConnect continueConnectProcessing()
1325        {
1326          return DEFAULT_RESULT;
1327        }
1328    
1329        /**
1330         * Defines a skip further plugin processing post connect plugin
1331         * result.
1332         *
1333         * @return  a skip further plugin processing post connect plugin
1334         * result.
1335         */
1336        public static PostConnect skipFurtherPluginProcesssing()
1337        {
1338          return new PostConnect(true, false, null, null, false);
1339        }
1340    
1341        /**
1342         * Defines a new stop processing post connect plugin result.
1343         *
1344         * @param disconnectReason The generic cause for the disconnect.
1345         * @param sendDisconnectNotification Whether to send a disconnect
1346         * notification to the client.
1347         * @param errorMessage An message explaining why processing
1348         * should stop for the given entry.
1349         *
1350         * @return a new stop processing post connect plugin result.
1351         */
1352        public static PostConnect disconnectClient(
1353            DisconnectReason disconnectReason,
1354            boolean sendDisconnectNotification, Message errorMessage)
1355        {
1356          return new PostConnect(false, false, errorMessage,
1357              disconnectReason, sendDisconnectNotification);
1358        }
1359    
1360        /**
1361         * Whether to continue operation processing.
1362         *
1363         * @return <code>true</code> if processing should continue
1364         * or <code>false</code> otherwise.
1365         */
1366        public boolean continueProcessing()
1367        {
1368          return continueProcessing;
1369        }
1370    
1371        /**
1372         * Whether to invoke the rest of the plugins.
1373         *
1374         * @return <code>true</code> if the rest of the plugins should
1375         * be invoked for <code>false</code> to skip the rest of the
1376         * plugins.
1377         */
1378        public boolean continuePluginProcessing()
1379        {
1380          return continuePluginProcessing;
1381        }
1382    
1383        /**
1384         * Retrieves the error message if <code>continueProcessing</code>
1385         * returned <code>false</code>.
1386         *
1387         * @return An error message explaining why processing should
1388         * stop or <code>null</code> if none is provided.
1389         */
1390        public Message getErrorMessage()
1391        {
1392          return errorMessage;
1393        }
1394    
1395        /**
1396         * The disconnect reason that provides the generic cause for the
1397         * disconnect.
1398         *
1399         * @return the generic cause for the disconnect.
1400         */
1401        public DisconnectReason getDisconnectReason()
1402        {
1403          return disconnectReason;
1404        }
1405    
1406        /**
1407         * Indicates whether to try to provide notification to the client
1408         * that the connection will be closed.
1409         *
1410         * @return <code>true</code> if notification should be provided or
1411         * <code>false</code> otherwise.
1412         */
1413        public boolean sendDisconnectNotification()
1414        {
1415          return sendDisconnectNotification;
1416        }
1417      }
1418    
1419      /**
1420       * Defines a post disconnect plugin result for client connection
1421       * processing consisting of either continue or skip further
1422       * plugins.
1423       */
1424      public static final class PostDisconnect
1425      {
1426        // Whether to invoke the rest of the plugins.
1427        private final boolean continuePluginProcessing;
1428    
1429        private static PostDisconnect DEFAULT_RESULT =
1430            new PostDisconnect(true);
1431    
1432        /**
1433         * Construct a new post disconnect plugin result.
1434         *
1435         * @param continuePluginProcessing Whether to invoke the rest
1436         * of the plugins.
1437         */
1438        private PostDisconnect(boolean continuePluginProcessing)
1439        {
1440          this.continuePluginProcessing = continuePluginProcessing;
1441        }
1442    
1443        /**
1444         * Defines a continue processing post disconnect plugin result.
1445         *
1446         * @return a continue processing post disconnect plugin result.
1447         */
1448        public static PostDisconnect continueDisconnectProcessing()
1449        {
1450          return DEFAULT_RESULT;
1451        }
1452    
1453        /**
1454         * Defines a skip further plugin processing post disconnect
1455         * plugin result.
1456         *
1457         * @return  a skip further plugin processing post disconnect
1458         * plugin result.
1459         */
1460        public static PostDisconnect skipFurtherPluginProcesssing()
1461        {
1462          return new PostDisconnect(false);
1463        }
1464    
1465        /**
1466         * Whether to invoke the rest of the plugins.
1467         *
1468         * @return <code>true</code> if the rest of the plugins should
1469         * be invoked for <code>false</code> to skip the rest of the
1470         * plugins.
1471         */
1472        public boolean continuePluginProcessing()
1473        {
1474          return continuePluginProcessing;
1475        }
1476      }
1477    }