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.search;
021
022
023 import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
024 import org.apache.directory.shared.ldap.entry.ServerEntry;
025 import org.apache.directory.shared.ldap.filter.ExprNode;
026 import org.apache.directory.shared.ldap.message.AliasDerefMode;
027 import org.apache.directory.shared.ldap.name.DN;
028 import org.apache.directory.server.xdbm.IndexCursor;
029
030 import javax.naming.directory.SearchControls;
031
032
033 /**
034 * Given a search filter and a scope the search engine identifies valid
035 * candidate entries returning their ids.
036 *
037 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
038 * @version $Rev: 927146 $
039 */
040 public interface SearchEngine<E, ID>
041 {
042 /**
043 * @todo put this in the right place
044 * The alias dereferencing mode key for JNDI providers
045 */
046 String ALIASMODE_KEY = JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES;
047 /**
048 * @todo put this in the right place
049 * The alias dereferencing mode value for JNDI providers
050 */
051 String ALWAYS = "always";
052 /**
053 * @todo put this in the right place
054 * The alias dereferencing mode value for JNDI providers
055 */
056 String NEVER = "never";
057 /**
058 * @todo put this in the right place
059 * The alias dereferencing mode value for JNDI providers
060 */
061 String FINDING = "finding";
062 /**
063 * @todo put this in the right place
064 * The alias dereferencing mode value for JNDI providers
065 */
066 String SEARCHING = "searching";
067
068
069 /**
070 * Gets the optimizer for this DefaultSearchEngine.
071 *
072 * @return the optimizer
073 */
074 Optimizer getOptimizer();
075
076
077 /**
078 * Conducts a search on a database.
079 *
080 * @param base the search base
081 * @param aliasDerefMode the alias dereferencing mode to use
082 * @param filter the search filter AST root
083 * @param searchCtls the JNDI search controls
084 * @return enumeration over SearchResults
085 * @throws Exception if the search fails
086 */
087 IndexCursor<ID, E, ID> cursor( DN base, AliasDerefMode aliasDerefMode, ExprNode filter,
088 SearchControls searchCtls ) throws Exception;
089
090
091 /**
092 * Builds an Evaluator for a filter expression.
093 *
094 * @param filter the filter root AST node
095 * @return true if the filter passes the entry, false otherwise
096 * @throws Exception if something goes wrong while accessing the db
097 */
098 Evaluator<? extends ExprNode, ServerEntry, ID> evaluator( ExprNode filter ) throws Exception;
099 }