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 java.util.Map;
024
025import javax.naming.Context;
026import javax.naming.NamingException;
027
028import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
029import org.apache.directory.api.ldap.model.name.Dn;
030import org.apache.directory.api.util.exception.NotImplementedException;
031
032
033/**
034 * A {@link LdapOperationException} which associates a resultCode namely the
035 * {@link org.apache.directory.api.ldap.model.message.ResultCodeEnum#REFERRAL} resultCode with the exception.
036 * 
037 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
038 */
039public class AbstractLdapReferralException extends LdapOperationException
040{
041    /** The serial version UUID */
042    static final long serialVersionUID = 1L;
043
044    /** The remaining Dn */
045    private Dn remainingDn;
046
047    /** The entry the referal refers to */
048    private Object resolvedObject;
049
050
051    /**
052     * 
053     * Creates a new instance of AbstractLdapReferralException.
054     *
055     * @param explanation The associated message
056     */
057    public AbstractLdapReferralException( String explanation )
058    {
059        super( explanation );
060    }
061
062
063    /**
064     * Always returns {@link ResultCodeEnum#REFERRAL}
065     * 
066     * @return The interned ResultCode
067     */
068    @Override
069    public ResultCodeEnum getResultCode()
070    {
071        return ResultCodeEnum.REFERRAL;
072    }
073
074
075    /**
076     * Not yet implemented
077     * 
078     * @return The Referral Context
079     * @throws NamingException If the operation failed
080     */
081    public Context getReferralContext() throws NamingException
082    {
083        throw new NotImplementedException();
084    }
085
086
087    /**
088     * Not yet implemented
089     * 
090     * @param arg The arguments
091     * @return The referral context
092     * @throws NamingException If the operation failed
093     */
094    public Context getReferralContext( Map<?, ?> arg ) throws NamingException
095    {
096        throw new NotImplementedException();
097    }
098
099
100    /**
101     * Retry. Not yet implemented
102     */
103    public void retryReferral()
104    {
105        throw new NotImplementedException();
106    }
107
108
109    /**
110     * @return the remainingDn
111     */
112    public Dn getRemainingDn()
113    {
114        return remainingDn;
115    }
116
117
118    /**
119     * @param remainingDn the remainingName to set
120     */
121    public void setRemainingDn( Dn remainingDn )
122    {
123        this.remainingDn = remainingDn;
124    }
125
126
127    /**
128     * @return the resolvedObject
129     */
130    public Object getResolvedObject()
131    {
132        return resolvedObject;
133    }
134
135
136    /**
137     * @param resolvedObject the resolvedObject to set
138     */
139    public void setResolvedObject( Object resolvedObject )
140    {
141        this.resolvedObject = resolvedObject;
142    }
143}