View Javadoc

1   /*
2    * Copyright 2000-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.jetspeed.services.search;
18  
19  // Java Imports
20  import java.io.File;
21  import java.util.Collection;
22  
23  // Turbine imports
24  import org.apache.turbine.services.TurbineServices;
25  
26  
27  /***
28   * Static accessor for the SearchService
29   *
30   * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
31   * @version $Id: Search.java,v 1.5 2004/02/23 03:48:47 jford Exp $
32   */
33  public abstract class Search
34  {
35  
36      /***
37       * Utility method for accessing the service 
38       * implementation
39       *
40       * @return a SearchServiceimplementation instance
41       */
42      protected static SearchService getService()
43      {
44          return (SearchService) TurbineServices
45              .getInstance().getService(SearchService.SERVICE_NAME);
46      }
47  
48      /***
49       * Search the default index
50       *
51       * @param searchString to use
52       * @return Hits
53       */    
54      public static SearchResults search(String searchString)
55      {
56          return getService().search(searchString);
57      }
58  
59      /***
60       * 
61       * @param o
62       * @return 
63       */
64      public static boolean remove(Object o)
65      {
66          return getService().remove(o);
67      }
68  
69      /***
70       * 
71       * @param c
72       * @return 
73       */
74      public static boolean remove(Collection c)
75      {
76          return getService().remove(c);
77      }
78  
79      /***
80       * 
81       * @param o
82       * @return 
83       */
84      public static boolean add(Object o)
85      {
86          return getService().add(o);
87      }
88  
89      /***
90       * 
91       * @param c
92       * @return 
93       */
94      public static boolean add(Collection c)
95      {
96          return getService().add(c);
97      }
98      
99      /***
100      * @param o
101      * @return
102      */
103     public static boolean update(Object o)
104     {
105         return getService().update(o);
106     }
107     
108     /***
109      * @param c
110      * @return
111      */
112     public static boolean update(Collection c)
113     {
114         return getService().update(c);
115     }
116 
117     /***
118      * 
119      * @param path
120      * @param extension
121      * @return 
122      */
123     public boolean addDirectory(String path, String extension)
124     {
125         File directory = new File(path); 
126         File[] files = directory.listFiles();
127         for (int ix=0; ix < files.length; ix++)
128         {
129             if (files[ix].isDirectory())
130             {
131                 continue;
132             }
133 
134             // TODO: subdirectories
135         }
136         return true;                        
137     }
138 
139 }