/tags/release/7020-RC3/aipo/jetspeed/src/main/java/org/apache/jetspeed/services/search/PopulateSampleIndices.java

http://aipo.googlecode.com/ · Java · 67 lines · 36 code · 10 blank · 21 comment · 2 complexity · 0e382a4411f22b860b87ce652d6877bd MD5 · raw file

  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. import java.io.BufferedReader;
  18. import java.io.FileReader;
  19. import java.net.URL;
  20. import org.apache.turbine.util.TurbineConfig;
  21. /**
  22. * Populate sample data for Search Portlet
  23. *
  24. * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  25. * @version $Id: PopulateSampleIndices.java,v 1.2 2004/02/23 03:48:47 jford Exp $
  26. */
  27. public class PopulateSampleIndices
  28. {
  29. static public final String SAMPLE_URLS = "./test/search-sample-urls.txt";
  30. public static void main(String args[])
  31. {
  32. try
  33. {
  34. TurbineConfig config = null;
  35. config = new TurbineConfig( "./webapp", "/WEB-INF/conf/TurbineResources.properties");
  36. config.init();
  37. FileReader reader = new FileReader(SAMPLE_URLS);
  38. BufferedReader breader = new BufferedReader(reader);
  39. String line = null;
  40. System.out.println("================= Populate Sample Indices =================");
  41. System.out.println("... creates Search sample portlet test data from URLs provided in file: " + SAMPLE_URLS);
  42. System.out.println("...");
  43. while (null != (line = breader.readLine()))
  44. {
  45. System.out.println("Creating index for: " + line);
  46. URL url = new URL(line);
  47. Search.add(url);
  48. }
  49. System.out.println("===========================================================");
  50. reader.close();
  51. }
  52. catch (Exception e)
  53. {
  54. System.out.println("Exception reading URLS" + e);
  55. }
  56. }
  57. }