001 /*
002 * Copyright 2015-2016 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2015-2016 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;
022
023
024
025 import com.unboundid.asn1.ASN1OctetString;
026 import com.unboundid.util.NotExtensible;
027 import com.unboundid.util.NotMutable;
028 import com.unboundid.util.ThreadSafety;
029 import com.unboundid.util.ThreadSafetyLevel;
030
031
032
033 /**
034 * This class defines an exception that can be thrown if the server returns an
035 * extended response that indicates that the operation did not complete
036 * successfully. This may be used to obtain access to any response OID and/or
037 * value that may have been included in the extended result.
038 */
039 @NotExtensible()
040 @NotMutable()
041 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
042 public class LDAPExtendedOperationException
043 extends LDAPException
044 {
045 /**
046 * The serial version UID for this serializable class.
047 */
048 private static final long serialVersionUID = -5674215690199642408L;
049
050
051
052 // The extended result for this exception.
053 private final ExtendedResult extendedResult;
054
055
056
057 /**
058 * Creates a new LDAP extended operation exception from the provided extended
059 * result.
060 *
061 * @param extendedResult The extended result to use to create this
062 * exception.
063 */
064 public LDAPExtendedOperationException(final ExtendedResult extendedResult)
065 {
066 super(extendedResult);
067
068 this.extendedResult = extendedResult;
069 }
070
071
072
073 /**
074 * {@inheritDoc}
075 */
076 @Override()
077 public LDAPResult toLDAPResult()
078 {
079 return extendedResult;
080 }
081
082
083
084 /**
085 * Retrieves the extended result that was returned by the server.
086 *
087 * @return The extended result that was returned by the server.
088 */
089 public ExtendedResult getExtendedResult()
090 {
091 return extendedResult;
092 }
093
094
095
096 /**
097 * Retrieves the response OID from the extended result, if any.
098 *
099 * @return The response OID from the extended result, or {@code null} if the
100 * result did not include an OID.
101 */
102 public String getResponseOID()
103 {
104 return extendedResult.getOID();
105 }
106
107
108
109 /**
110 * Retrieves the response value from the extended result, if any.
111 *
112 * @return The response value from the extended result, or {@code null} if
113 * the result did not include a value.
114 */
115 public ASN1OctetString getResponseValue()
116 {
117 return extendedResult.getValue();
118 }
119 }