1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.server.xdbm; 21 22 23 import javax.naming.NamingException; 24 25 26 /** 27 * NamingException for missing indicies if full table scans are disallowed. 28 * 29 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 30 * @version $Rev: 640657 $ 31 */ 32 public class IndexNotFoundException extends NamingException 33 { 34 private static final long serialVersionUID = 3906088970608981815L; 35 36 /** the name of the index that was not found */ 37 private final String indexName; 38 39 40 /** 41 * Constructs an Exception with a detailed message. 42 * 43 * @param indexName the name of the index that was not found 44 */ 45 public IndexNotFoundException(String indexName) 46 { 47 super( "Cannot efficiently search the DIB w/o an index on attribute " + indexName 48 + "\n. To allow such searches please contact the " 49 + "directory\nadministrator to create the index or to enable " 50 + "referrals on searches using these\nattributes to a replica with " + "the required set of indices." ); 51 this.indexName = indexName; 52 } 53 54 55 /** 56 * Constructs an Exception with a detailed message. 57 * 58 * @param message the message associated with the exception. 59 * @param indexName the name of the index that was not found 60 */ 61 public IndexNotFoundException(String message, String indexName) 62 { 63 super( message ); 64 this.indexName = indexName; 65 } 66 67 68 /** 69 * Constructs an Exception with a detailed message and a root cause 70 * exception. 71 * 72 * @param message the message associated with the exception. 73 * @param indexName the name of the index that was not found 74 * @param rootCause the root cause of this exception 75 */ 76 public IndexNotFoundException(String message, String indexName, Throwable rootCause) 77 { 78 this( message, indexName ); 79 setRootCause( rootCause ); 80 } 81 82 83 /** 84 * Gets the name of the attribute the index was missing for. 85 * 86 * @return the name of the attribute the index was missing for. 87 */ 88 public String getIndexName() 89 { 90 return indexName; 91 } 92 }