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.search;
21
22
23 import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
24 import org.apache.directory.shared.ldap.filter.ExprNode;
25 import org.apache.directory.shared.ldap.message.AliasDerefMode;
26 import org.apache.directory.shared.ldap.name.LdapDN;
27 import org.apache.directory.server.xdbm.IndexCursor;
28 import org.apache.directory.server.core.entry.ServerEntry;
29
30 import javax.naming.directory.SearchControls;
31
32
33 /**
34 * Given a search filter and a scope the search engine identifies valid
35 * candidate entries returning their ids.
36 *
37 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
38 * @version $Rev: 658798 $
39 */
40 public interface SearchEngine<E>
41 {
42 /**
43 * @todo put this in the right place
44 * The alias dereferencing mode key for JNDI providers
45 */
46 String ALIASMODE_KEY = JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES;
47 /**
48 * @todo put this in the right place
49 * The alias dereferencing mode value for JNDI providers
50 */
51 String ALWAYS = "always";
52 /**
53 * @todo put this in the right place
54 * The alias dereferencing mode value for JNDI providers
55 */
56 String NEVER = "never";
57 /**
58 * @todo put this in the right place
59 * The alias dereferencing mode value for JNDI providers
60 */
61 String FINDING = "finding";
62 /**
63 * @todo put this in the right place
64 * The alias dereferencing mode value for JNDI providers
65 */
66 String SEARCHING = "searching";
67
68
69 /**
70 * Gets the optimizer for this DefaultSearchEngine.
71 *
72 * @return the optimizer
73 */
74 Optimizer getOptimizer();
75
76
77 /**
78 * Conducts a search on a database.
79 *
80 * @param base the search base
81 * @param aliasDerefMode the alias dereferencing mode to use
82 * @param filter the search filter AST root
83 * @param searchCtls the JNDI search controls
84 * @return enumeration over SearchResults
85 * @throws Exception if the search fails
86 */
87 IndexCursor<Long,E> cursor( LdapDN base,
88 AliasDerefMode aliasDerefMode,
89 ExprNode filter,
90 SearchControls searchCtls ) throws Exception;
91
92
93 /**
94 * Builds an Evaluator for a filter expression.
95 *
96 * @param filter the filter root AST node
97 * @return true if the filter passes the entry, false otherwise
98 * @throws Exception if something goes wrong while accessing the db
99 */
100 Evaluator<? extends ExprNode, ServerEntry> evaluator( ExprNode filter ) throws Exception;
101 }