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.server.xdbm;
021
022
023import javax.naming.NamingException;
024
025import org.apache.directory.server.i18n.I18n;
026
027
028/**
029 * NamingException for missing indicies if full table scans are disallowed.
030 * 
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public class IndexNotFoundException extends NamingException
034{
035    private static final long serialVersionUID = 3906088970608981815L;
036
037    /** the name of the index that was not found */
038    private final String indexName;
039
040
041    /**
042     * Constructs an Exception with a detailed message.
043     * 
044     * @param indexName the name of the index that was not found 
045     */
046    public IndexNotFoundException( String indexName )
047    {
048        super( I18n.err( I18n.ERR_704, indexName ) );
049        this.indexName = indexName;
050    }
051
052
053    /**
054     * Constructs an Exception with a detailed message.
055     * 
056     * @param message the message associated with the exception.
057     * @param indexName the name of the index that was not found 
058     */
059    public IndexNotFoundException( String message, String indexName )
060    {
061        super( message );
062        this.indexName = indexName;
063    }
064
065
066    /**
067     * Constructs an Exception with a detailed message and a root cause 
068     * exception.
069     * 
070     * @param message the message associated with the exception.
071     * @param indexName the name of the index that was not found 
072     * @param rootCause the root cause of this exception 
073     */
074    public IndexNotFoundException( String message, String indexName, Throwable rootCause )
075    {
076        this( message, indexName );
077        setRootCause( rootCause );
078    }
079
080
081    /**
082     * Gets the name of the attribute the index was missing for.
083     *
084     * @return the name of the attribute the index was missing for.
085     */
086    public String getIndexName()
087    {
088        return indexName;
089    }
090}