KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > search > PopulateSampleIndices


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 package org.apache.jetspeed.services.search;
17
18 import java.io.BufferedReader JavaDoc;
19 import java.io.FileReader JavaDoc;
20 import java.net.URL JavaDoc;
21
22 import org.apache.turbine.util.TurbineConfig;
23
24 /**
25  * Populate sample data for Search Portlet
26  *
27  * @author <a HREF="mailto:taylor@apache.org">David Sean Taylor</a>
28  * @version $Id: PopulateSampleIndices.java,v 1.2 2004/02/23 03:48:47 jford Exp $
29  */

30 public class PopulateSampleIndices
31 {
32     static public final String JavaDoc SAMPLE_URLS = "./test/search-sample-urls.txt";
33     
34     public static void main(String JavaDoc args[])
35     {
36         try
37         {
38             TurbineConfig config = null;
39             
40             config = new TurbineConfig( "./webapp", "/WEB-INF/conf/TurbineResources.properties");
41             config.init();
42                     
43             FileReader JavaDoc reader = new FileReader JavaDoc(SAMPLE_URLS);
44             BufferedReader JavaDoc breader = new BufferedReader JavaDoc(reader);
45             String JavaDoc line = null;
46             System.out.println("================= Populate Sample Indices =================");
47             System.out.println("... creates Search sample portlet test data from URLs provided in file: " + SAMPLE_URLS);
48             System.out.println("...");
49             
50             while (null != (line = breader.readLine()))
51             {
52                 System.out.println("Creating index for: " + line);
53                 URL JavaDoc url = new URL JavaDoc(line);
54                 
55                 Search.add(url);
56             }
57             System.out.println("===========================================================");
58             
59             reader.close();
60         }
61         catch (Exception JavaDoc e)
62         {
63             System.out.println("Exception reading URLS" + e);
64         }
65     }
66     
67 }
68
Popular Tags