001 package railo.runtime.search; 002 003 import java.io.IOException; 004 005 import org.w3c.dom.Element; 006 import org.xml.sax.SAXException; 007 008 import railo.commons.io.log.LogAndSource; 009 import railo.commons.io.res.Resource; 010 import railo.runtime.config.Config; 011 import railo.runtime.type.Query; 012 013 /** 014 * interface for a Search Engine 015 */ 016 public interface SearchEngine { 017 018 /** 019 * overwrite allowed 020 */ 021 public static final boolean ALLOW_OVERWRITE = true; 022 023 /** 024 * overwrite denied 025 */ 026 public static final boolean DENY_OVERWRITE = false; 027 028 /** 029 * constructor of the class 030 * @param config 031 * @param searchDir directory where the railo xml file is 032 * @param log 033 * @throws IOException 034 * @throws SAXException 035 * @throws SearchException 036 */ 037 public abstract void init(Config config, Resource searchDir, LogAndSource log) 038 throws SAXException, IOException, SearchException; 039 040 /** 041 * returns a collection by name 042 * @param name name of the desired collection (case insensitive) 043 * @return returns lucene collection object matching name 044 * @throws SearchException if no matching Collection exist 045 */ 046 public abstract SearchCollection getCollectionByName(String name) 047 throws SearchException; 048 049 /** 050 * @return returns all collections as a query object 051 */ 052 public abstract Query getCollectionsAsQuery(); 053 054 /** 055 * Creates a new Collection and Store it (creating always a spellindex) 056 * @param name The Name of the Collection 057 * @param path the path to store 058 * @param language The language of the collection 059 * @param allowOverwrite 060 * @return New SearchCollection 061 * @throws SearchException 062 */ 063 public abstract SearchCollection createCollection(String name, Resource path, 064 String language, boolean allowOverwrite) throws SearchException; 065 066 067 /** 068 * @return returns the directory of the search storage 069 */ 070 public abstract Resource getDirectory(); 071 072 /** 073 * @return returns the logfile of the search storage 074 */ 075 public abstract LogAndSource getLogger(); 076 077 /** 078 * return XML Element Matching index id 079 * @param collElement XML Collection Element 080 * @param id 081 * @return XML Element 082 */ 083 public abstract Element getIndexElement(Element collElement, String id); 084 085 /** 086 * @return returns the Name of the search engine to display in admin 087 */ 088 public abstract String getDisplayName(); 089 090 }