View Javadoc

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