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     * docs/licenses/cddl.txt
011     * or http://www.opensource.org/licenses/cddl1.php.
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     * docs/licenses/cddl.txt.  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 2010-2012 UnboundID Corp.
026     */
027    package com.unboundid.directory.sdk.ds.types;
028    
029    
030    
031    import java.io.Serializable;
032    
033    import com.unboundid.util.NotMutable;
034    import com.unboundid.util.ThreadSafety;
035    import com.unboundid.util.ThreadSafetyLevel;
036    
037    
038    
039    /**
040     * This class defines a structure which may be used to provide information about
041     * the result of the processing performed by a pre-operation plugin.
042     */
043    @NotMutable()
044    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
045    public final class PreOperationPluginResult
046           implements Serializable
047    {
048      /**
049       * A predefined result instance that indicates all processing completed
050       * successfully.
051       */
052      public static final PreOperationPluginResult SUCCESS =
053           new PreOperationPluginResult(false, true, false, false);
054    
055    
056    
057      /**
058       * The serial version UID for this serializable class.
059       */
060      private static final long serialVersionUID = -255249379093850659L;
061    
062    
063    
064      // Indicates whether the client connection was terminated by the plugin.
065      private final boolean connectionTerminated;
066    
067      // Indicates whether the server should continue processing other
068      // pre-operation plugins.
069      private final boolean continuePluginProcessing;
070    
071      // Indicates whether to send the response to the client immediately without
072      // performing any of the core processing.
073      private final boolean sendResponseImmediately;
074    
075      // Indicates whether the server should skip the core processing for the
076      // associated operation.
077      private final boolean skipCoreProcessing;
078    
079    
080    
081      /**
082       * Creates a new pre-operation plugin result with the provided information.
083       *
084       * @param  connectionTerminated      Indicates whether the client connection
085       *                                   was terminated by the plugin.
086       * @param  continuePluginProcessing  Indicates whether to continue processing
087       *                                   other pre-operation plugins for the
088       *                                   operation.
089       * @param  sendResponseImmediately   Indicates whether to send the response
090       *                                   to the client immediately without
091       *                                   performing any of the core processing.
092       * @param  skipCoreProcessing        Indicates whether the server should skip
093       *                                   the core processing for the operation.
094       *                                   If this is {@code true} but
095       *                                   {@code sendResponseImmediately} is
096       *                                   {@code false}, then any post-operation
097       *                                   plugins will still be invoked.
098       */
099      public PreOperationPluginResult(final boolean connectionTerminated,
100                                      final boolean continuePluginProcessing,
101                                      final boolean sendResponseImmediately,
102                                      final boolean skipCoreProcessing)
103      {
104        this.connectionTerminated     = connectionTerminated;
105        this.continuePluginProcessing = continuePluginProcessing;
106        this.sendResponseImmediately  = sendResponseImmediately;
107        this.skipCoreProcessing       = skipCoreProcessing;
108      }
109    
110    
111    
112      /**
113       * Indicates whether the client connection was terminated by the plugin.
114       *
115       * @return  {@code true} if the client connection was terminated by the
116       *          plugin, or {@code false} if not.
117       */
118      public boolean connectionTerminated()
119      {
120        return connectionTerminated;
121      }
122    
123    
124    
125      /**
126       * Indicates whether to continue processing other pre-operation plugins for
127       * the connection.
128       *
129       * @return  {@code true} if the server should continue processing other
130       *          pre-operation plugins for the connection, or {@code false} if not.
131       */
132      public boolean continuePluginProcessing()
133      {
134        return continuePluginProcessing;
135      }
136    
137    
138    
139      /**
140       * Indicates whether the server should send a response to the client
141       * immediately without performing any core processing.
142       *
143       * @return  {@code true} if the server should send a response to the client
144       *          immediately without
145       */
146      public boolean sendResponseImmediately()
147      {
148        return sendResponseImmediately;
149      }
150    
151    
152    
153      /**
154       * Indicates whether the server should skip the core processing for the
155       * operation.
156       *
157       * @return  {@code true} if the server should skip the core processing for the
158       *          operation, or {@code false} if not.
159       */
160      public boolean skipCoreProcessing()
161      {
162        return skipCoreProcessing;
163      }
164    
165    
166    
167      /**
168       * Retrieves a string representation of this pre-operation plugin result.
169       *
170       * @return  A string representation of this pre-operation plugin result.
171       */
172      @Override()
173      public String toString()
174      {
175        final StringBuilder buffer = new StringBuilder();
176    
177        buffer.append("PreOperationPluginResult(connectionTerminated=");
178        buffer.append(connectionTerminated);
179        buffer.append(", continuePluginProcessing=");
180        buffer.append(continuePluginProcessing);
181        buffer.append(", sendResponseImmediately=");
182        buffer.append(sendResponseImmediately);
183        buffer.append(", skipCoreProcessing=");
184        buffer.append(skipCoreProcessing);
185        buffer.append(')');
186    
187        return buffer.toString();
188      }
189    }