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       * Retrieves the extended result that was returned by the server.
068       *
069       * @return  The extended result that was returned by the server.
070       */
071      public ExtendedResult getExtendedResult()
072      {
073        return extendedResult;
074      }
075    
076    
077    
078      /**
079       * Retrieves the response OID from the extended result, if any.
080       *
081       * @return  The response OID from the extended result, or {@code null} if the
082       *          result did not include an OID.
083       */
084      public String getResponseOID()
085      {
086        return extendedResult.getOID();
087      }
088    
089    
090    
091      /**
092       * Retrieves the response value from the extended result, if any.
093       *
094       * @return  The response value from the extended result, or {@code null} if
095       *          the result did not include a value.
096       */
097      public ASN1OctetString getResponseValue()
098      {
099        return extendedResult.getValue();
100      }
101    }