001    package railo.runtime.search;
002    
003    import java.io.Serializable;
004    import java.net.MalformedURLException;
005    import java.net.URL;
006    
007    import railo.commons.io.log.Log;
008    import railo.commons.io.res.Resource;
009    import railo.runtime.PageContext;
010    import railo.runtime.exp.PageException;
011    import railo.runtime.type.Query;
012    import railo.runtime.type.QueryColumn;
013    import railo.runtime.type.dt.DateTime;
014    
015    /**
016     * a Search Collection
017     */
018    public interface SearchCollection extends Serializable {
019    
020        /**
021         * Field <code>SEARCH_TYPE_SIMPLE</code>
022         */
023        public static final short SEARCH_TYPE_SIMPLE = 0;
024    
025        /**
026         * Field <code>SEARCH_TYPE_EXPLICIT</code>
027         */
028        public static final short SEARCH_TYPE_EXPLICIT = 1;
029    
030        /**
031         * create a collection
032         * @throws SearchException
033         */
034        public abstract void create() throws SearchException;
035    
036        /**
037         * optimize a Collection
038         * @throws SearchException
039         */
040        public abstract void optimize() throws SearchException;
041    
042        /**
043         * map a Collection
044         * @param path
045         * @throws SearchException
046         */
047        public abstract void map(Resource path) throws SearchException;
048    
049        /**
050         * repair a Collection
051         * @throws SearchException
052         */
053        public abstract void repair() throws SearchException;
054    
055        /**
056         * updates a index of a collection
057         * @param pc
058         * @param key
059         * @param type
060         * @param urlpath
061         * @param title
062         * @param body
063         * @param language
064         * @param extensions
065         * @param query
066         * @param recurse
067         * @param categoryTree
068         * @param categories
069         * @param custom1
070         * @param custom2
071         * @param custom3
072         * @param custom4
073         * @throws PageException
074         * @throws MalformedURLException
075         * @throws SearchException
076         */
077        public abstract IndexResult index(PageContext pc, String key, short type,
078                String urlpath, String title, String body, String language,
079                String[] extensions, String query, boolean recurse, 
080                String categoryTree, String[] categories,
081                String custom1, String custom2, String custom3, String custom4)
082                throws PageException, MalformedURLException, SearchException;
083    
084        /**
085         * updates a collection with a file
086         * @param id
087         * @param title
088         * @param file
089         * @param language
090         * @throws SearchException
091         */
092        public abstract IndexResult indexFile(String id, String title, Resource file,String language) throws SearchException;
093    
094        /**
095         * updates a collection with a path
096         * @param id
097         * @param title
098         * @param dir
099         * @param recurse
100         * @param extensions
101         * @param language
102         * @throws SearchException
103         */
104        public abstract IndexResult indexPath(String id, String title, Resource dir,
105                String[] extensions, boolean recurse, String language)
106                throws SearchException;
107    
108        /**
109         * updates a collection with a url
110         * @param id
111         * @param title
112         * @param recurse
113         * @param extensions
114         * @param url
115         * @param language
116         * @throws SearchException
117         */
118        public abstract IndexResult indexURL(String id, String title, URL url,
119                String[] extensions, boolean recurse, String language)
120                throws SearchException;
121    
122        /**
123         * updates a collection with a custom
124         * @param id
125         * @param title Title for the Index
126         * @param keyColumn Key Column
127         * @param bodyColumns Body Column Array
128         * @param language Language for index
129         * @param custom1 
130         * @param custom2 
131         * @param custom3 
132         * @param custom4 
133         * @throws SearchException
134         */
135        public abstract IndexResult indexCustom(String id, QueryColumn title,
136                QueryColumn keyColumn, QueryColumn[] bodyColumns, String language,// FUTURE,QueryColumn urlpath, 
137                QueryColumn custom1, QueryColumn custom2, QueryColumn custom3,QueryColumn custom4) throws SearchException;
138    
139        /**
140         * @return Returns the language.
141         */
142        public abstract String getLanguage();
143    
144        /**
145         * purge a collection
146         * @throws SearchException
147         */
148        public abstract IndexResult purge() throws SearchException;
149    
150        /**
151         * delete the collection
152         * @throws SearchException
153         */
154        public abstract IndexResult delete() throws SearchException;
155    
156        /**
157         * delete a Index from collection
158         * @param pc
159         * @param key
160         * @param type
161         * @param queryName
162         * @throws SearchException
163         */
164        public abstract IndexResult deleteIndex(PageContext pc, String key, short type, String queryName) throws SearchException;
165    
166        /**
167         * @return Returns the path.
168         */
169        public abstract Resource getPath();
170    
171        /**
172         * @return returns when collection is created
173         */
174        public abstract DateTime getCreated();
175    
176        /**
177         * @return Returns the lastUpdate.
178         */
179        public abstract DateTime getLastUpdate();
180    
181        /**
182         * @return Returns the name.
183         */
184        public abstract String getName();
185    
186        /** 
187         * @return Returns the logFile.
188         */
189        public abstract Log getLogger();
190    
191        /**
192         * @return Returns the searchEngine.
193         */
194        public abstract SearchEngine getSearchEngine();
195    
196        /**
197         * return time when collection was created
198         * @return create time
199         */
200        public abstract Object created();
201    
202        /**
203         * search the collection
204         * @param data
205         * @param qry Query to append resuts
206         * @param criteria
207         * @param language
208         * @param type SEARCH_TYPE_EXPLICIT or SEARCH_TYPE_SIMPLE
209         * @param startrow
210         * @param maxrow
211         * @param categoryTree
212         * @param category
213         * @return new startrow
214         * @throws SearchException
215         * @throws PageException
216         */
217        public abstract int search(SearchData data, Query qry,
218                String criteria, String language, short type, int startrow,
219                int maxrow, String categoryTree, String[] category) throws SearchException, PageException;
220        
221        /**
222         * search the collection
223         * @param data
224         * @param criteria
225         * @param language
226         * @param type SEARCH_TYPE_EXPLICIT or SEARCH_TYPE_SIMPLE
227         * @param categoryTree
228         * @param category
229         * @return Result as SearchRecord Array
230         * @throws SearchException
231         */
232        public abstract SearchResulItem[] _search(SearchData data,
233                String criteria, String language, short type, String categoryTree, String[] category)
234                throws SearchException;
235    
236            /**
237             * @return the size of the collection in KB
238             */
239            public long getSize();
240    
241            /**
242             * @return the counts of the documents in the collection
243             */
244            public int getDocumentCount();
245            
246            public int getDocumentCount(String id);
247    
248            public abstract Object getCategoryInfo();
249    
250    }