001    /*
002     * Copyright 2008-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2015 UnboundID Corp.
007     *
008     * This program is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (GPLv2 only)
010     * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011     * as published by the Free Software Foundation.
012     *
013     * This program is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program; if not, see <http://www.gnu.org/licenses>.
020     */
021    package com.unboundid.ldap.sdk.unboundidds.extensions;
022    
023    
024    
025    import com.unboundid.ldap.sdk.Control;
026    import com.unboundid.ldap.sdk.ExtendedResult;
027    import com.unboundid.ldap.sdk.ResultCode;
028    import com.unboundid.util.NotMutable;
029    import com.unboundid.util.ThreadSafety;
030    import com.unboundid.util.ThreadSafetyLevel;
031    
032    import static com.unboundid.ldap.sdk.unboundidds.extensions.ExtOpMessages.*;
033    
034    
035    
036    /**
037     * <BLOCKQUOTE>
038     *   <B>NOTE:</B>  This class is part of the Commercial Edition of the UnboundID
039     *   LDAP SDK for Java.  It is not available for use in applications that
040     *   include only the Standard Edition of the LDAP SDK, and is not supported for
041     *   use in conjunction with non-UnboundID products.
042     * </BLOCKQUOTE>
043     * This class provides an implementation of the interactive transaction aborted
044     * extended result, which is used as an unsolicited notification to indicate
045     * that the server has aborted an interactive transaction without the client's
046     * explicit request.
047     */
048    @NotMutable()
049    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
050    public final class InteractiveTransactionAbortedExtendedResult
051           extends ExtendedResult
052    {
053      /**
054       * The OID (1.3.6.1.4.1.30221.2.6.5) for the interactive transaction aborted
055       * extended result.
056       */
057      public static final String INTERACTIVE_TRANSACTION_ABORTED_RESULT_OID =
058           "1.3.6.1.4.1.30221.2.6.5";
059    
060    
061    
062      /**
063       * The serial version UID for this serializable class.
064       */
065      private static final long serialVersionUID = 296814913448182605L;
066    
067    
068    
069      /**
070       * Creates a new instance of this interactive transaction aborted extended
071       * result from the provided generic extended result.
072       *
073       * @param  extendedResult  The extended result to use to create this
074       *                         interactive transaction aborted extended result.
075       */
076      public InteractiveTransactionAbortedExtendedResult(
077                  final ExtendedResult extendedResult)
078      {
079        super(extendedResult);
080      }
081    
082    
083    
084      /**
085       * Creates a new instance of this interactive transaction aborted extended
086       * result from the provided information.
087       *
088       * @param  messageID          The message ID for the LDAP message that is
089       *                            associated with this LDAP result.
090       * @param  resultCode         The result code from the response.
091       * @param  diagnosticMessage  The diagnostic message from the response, if
092       *                            available.
093       * @param  matchedDN          The matched DN from the response, if available.
094       * @param  referralURLs       The set of referral URLs from the response, if
095       *                            available.
096       * @param  responseControls   The set of controls from the response, if
097       *                            available.
098       */
099      public InteractiveTransactionAbortedExtendedResult(
100                  final int messageID, final ResultCode resultCode,
101                  final String diagnosticMessage, final String matchedDN,
102                  final String[] referralURLs, final Control[] responseControls)
103      {
104        super(messageID, resultCode, diagnosticMessage, matchedDN, referralURLs,
105              INTERACTIVE_TRANSACTION_ABORTED_RESULT_OID, null, responseControls);
106      }
107    
108    
109    
110      /**
111       * {@inheritDoc}
112       */
113      @Override()
114      public String getExtendedResultName()
115      {
116        return INFO_EXTENDED_RESULT_NAME_INTERACTIVE_TXN_ABORTED.get();
117      }
118    
119    
120    
121      /**
122       * Appends a string representation of this extended result to the provided
123       * buffer.
124       *
125       * @param  buffer  The buffer to which a string representation of this
126       *                 extended result will be appended.
127       */
128      @Override()
129      public void toString(final StringBuilder buffer)
130      {
131        buffer.append("InteractiveTransactionAbortedExtendedResult(resultCode=");
132        buffer.append(getResultCode());
133    
134        final int messageID = getMessageID();
135        if (messageID >= 0)
136        {
137          buffer.append(", messageID=");
138          buffer.append(messageID);
139        }
140    
141        final String diagnosticMessage = getDiagnosticMessage();
142        if (diagnosticMessage != null)
143        {
144          buffer.append(", diagnosticMessage='");
145          buffer.append(diagnosticMessage);
146          buffer.append('\'');
147        }
148    
149        final String matchedDN = getMatchedDN();
150        if (matchedDN != null)
151        {
152          buffer.append(", matchedDN='");
153          buffer.append(matchedDN);
154          buffer.append('\'');
155        }
156    
157        final String[] referralURLs = getReferralURLs();
158        if (referralURLs.length > 0)
159        {
160          buffer.append(", referralURLs={");
161          for (int i=0; i < referralURLs.length; i++)
162          {
163            if (i > 0)
164            {
165              buffer.append(", ");
166            }
167    
168            buffer.append('\'');
169            buffer.append(referralURLs[i]);
170            buffer.append('\'');
171          }
172          buffer.append('}');
173        }
174    
175        buffer.append(", oid=");
176        buffer.append(INTERACTIVE_TRANSACTION_ABORTED_RESULT_OID);
177    
178        final Control[] responseControls = getResponseControls();
179        if (responseControls.length > 0)
180        {
181          buffer.append(", responseControls={");
182          for (int i=0; i < responseControls.length; i++)
183          {
184            if (i > 0)
185            {
186              buffer.append(", ");
187            }
188    
189            buffer.append(responseControls[i]);
190          }
191          buffer.append('}');
192        }
193    
194        buffer.append(')');
195      }
196    }