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