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 *    https://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     * Creates a new instance of LdapOperationException.
046     *
047     * @param resultCode The operation resultCode
048     * @param message The exception message
049     */
050    public LdapOperationException( ResultCodeEnum resultCode, String message )
051    {
052        super( message );
053        this.resultCode = resultCode;
054    }
055
056
057    /**
058     * Creates a new instance of LdapOperationException.
059     *
060     * @param resultCode The operation resultCode
061     * @param message The exception message
062     * @param cause The root cause for this exception
063     */
064    public LdapOperationException( ResultCodeEnum resultCode, String message, Throwable cause )
065    {
066        super( message, cause );
067        this.resultCode = resultCode;
068    }
069
070
071    /**
072     * Creates a new instance of LdapOperationException.
073     *
074     * @param message The exception message
075     */
076    public LdapOperationException( String message )
077    {
078        super( message );
079    }
080
081
082    /**
083     * Creates a new instance of LdapOperationException.
084     *
085     * @param message The exception message
086     * @param cause The root cause for this exception
087     */
088    public LdapOperationException( String message, Throwable cause )
089    {
090        super( message, cause );
091    }
092
093
094    /**
095     * Gets the LDAP result code that would be associated with this exception.
096     * 
097     * @return the LDAP result code corresponding to this exception type.
098     */
099    public ResultCodeEnum getResultCode()
100    {
101        return resultCode;
102    }
103
104
105    /**
106     * @return the resolvedDn
107     */
108    public Dn getResolvedDn()
109    {
110        return resolvedDn;
111    }
112
113
114    /**
115     * @param resolvedDn the resolvedDn to set
116     */
117    public void setResolvedDn( Dn resolvedDn )
118    {
119        this.resolvedDn = resolvedDn;
120    }
121}