001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *  
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *  
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License. 
018 *  
019 */
020package org.apache.directory.api.ldap.model.exception;
021
022
023import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
024import org.apache.directory.api.ldap.model.name.Dn;
025
026
027/**
028 * An class for LDAP operation exceptions which add LDAP specific information to
029 * Exceptions.
030 * 
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public class LdapOperationException extends LdapException
034{
035    /** The serial version UUID */
036    private static final long serialVersionUID = 1L;
037
038    /** The operation resultCode */
039    protected ResultCodeEnum resultCode;
040
041    /** The resolved Dn */
042    protected Dn resolvedDn;
043
044
045    /**
046     * Creates a new instance of LdapOperationException.
047     *
048     * @param resultCode The operation resultCode
049     * @param message The exception message
050     */
051    public LdapOperationException( ResultCodeEnum resultCode, String message )
052    {
053        super( message );
054        this.resultCode = resultCode;
055    }
056
057
058    /**
059     * Creates a new instance of LdapOperationException.
060     *
061     * @param resultCode The operation resultCode
062     * @param message The exception message
063     * @param cause The root cause for this exception
064     */
065    public LdapOperationException( ResultCodeEnum resultCode, String message, Throwable cause )
066    {
067        super( message, cause );
068        this.resultCode = resultCode;
069    }
070
071
072    /**
073     * Creates a new instance of LdapOperationException.
074     *
075     * @param message The exception message
076     */
077    public LdapOperationException( String message )
078    {
079        super( message );
080    }
081
082
083    /**
084     * Creates a new instance of LdapOperationException.
085     *
086     * @param message The exception message
087     * @param cause The root cause for this exception
088     */
089    public LdapOperationException( String message, Throwable cause )
090    {
091        super( message, cause );
092    }
093
094
095    /**
096     * @return the resolvedDn
097     */
098    public Dn getResolvedDn()
099    {
100        return resolvedDn;
101    }
102
103
104    /**
105     * @param resolvedDn the resolvedDn to set
106     */
107    public void setResolvedDn( Dn resolvedDn )
108    {
109        this.resolvedDn = resolvedDn;
110    }
111
112
113    /**
114     * Gets the LDAP result code that would be associated with this exception.
115     * 
116     * @return the LDAP result code corresponding to this exception type.
117     */
118    public ResultCodeEnum getResultCode()
119    {
120        return resultCode;
121    }
122}