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