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     */
020    package org.apache.directory.server.xdbm;
021    
022    
023    import javax.naming.NamingException;
024    
025    
026    /**
027     * NamingException for missing indicies if full table scans are disallowed.
028     * 
029     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
030     * @version $Rev: 640657 $
031     */
032    public class IndexNotFoundException extends NamingException
033    {
034        private static final long serialVersionUID = 3906088970608981815L;
035    
036        /** the name of the index that was not found */
037        private final String indexName;
038    
039    
040        /**
041         * Constructs an Exception with a detailed message.
042         * 
043         * @param indexName the name of the index that was not found 
044         */
045        public IndexNotFoundException(String indexName)
046        {
047            super( "Cannot efficiently search the DIB w/o an index on attribute " + indexName
048                + "\n. To allow such searches please contact the "
049                + "directory\nadministrator to create the index or to enable "
050                + "referrals on searches using these\nattributes to a replica with " + "the required set of indices." );
051            this.indexName = indexName;
052        }
053    
054    
055        /**
056         * Constructs an Exception with a detailed message.
057         * 
058         * @param message the message associated with the exception.
059         * @param indexName the name of the index that was not found 
060         */
061        public IndexNotFoundException(String message, String indexName)
062        {
063            super( message );
064            this.indexName = indexName;
065        }
066    
067    
068        /**
069         * Constructs an Exception with a detailed message and a root cause 
070         * exception.
071         * 
072         * @param message the message associated with the exception.
073         * @param indexName the name of the index that was not found 
074         * @param rootCause the root cause of this exception 
075         */
076        public IndexNotFoundException(String message, String indexName, Throwable rootCause)
077        {
078            this( message, indexName );
079            setRootCause( rootCause );
080        }
081    
082    
083        /**
084         * Gets the name of the attribute the index was missing for.
085         *
086         * @return the name of the attribute the index was missing for.
087         */
088        public String getIndexName()
089        {
090            return indexName;
091        }
092    }