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