01: /*
02:
03: * LIUS - Lucene Index Update and Search
04: * http://sourceforge.net/projects/lius/
05: *
06: * Copyright (c) 2005, Laval University Library. All rights reserved.
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Lesser General Public
10: * License as published by the Free Software Foundation; either
11: * version 2.1 of the License, or (at your option) any later version.
12: *
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Lesser General Public License for more details.
17: *
18: * You should have received a copy of the GNU Lesser General Public
19: * License along with this library; if not, write to the Free Software
20: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21: */
22:
23: package ca.ulaval.bibl.lius.main.samples;
24:
25: import java.io.File;
26: import java.io.IOException;
27: import java.util.StringTokenizer;
28:
29: import ca.ulaval.bibl.lius.LiusLogger;
30: import ca.ulaval.bibl.lius.Exception.LiusException;
31: import ca.ulaval.bibl.lius.Lucene.LuceneActions;
32:
33: /**
34: *
35: * @author Rida Benjelloun (rida.benjelloun@bibl.ulaval.ca)
36: *
37: */
38:
39: public class IndexingMultipleFiles {
40:
41: public static void main(String[] args) throws IOException,
42: LiusException {
43:
44: String sep = File.separator;
45:
46: StringTokenizer st = new StringTokenizer(System.getProperty(
47:
48: "java.class.path"), File.pathSeparator);
49:
50: File classDir = new File(st.nextToken());
51:
52: String indexDir = classDir.getParent() + sep + "luceneIndex";
53:
54: String liusConfig = classDir.getParent() + sep + "Config" + sep
55: +
56:
57: "liusFilesConfig.xml";
58:
59: String log4j = classDir.getParent() + sep + "Config" + sep
60: + "log4j" + sep + "log4j.properties";
61:
62: String toIndex = classDir.getParent() + sep + "ExempleFiles"
63: + sep + "meta";
64:
65: LiusLogger.setLoggerConfigFile(log4j);
66:
67: try {
68:
69: LuceneActions.getSingletonInstance().newIndex(indexDir);
70:
71: /*
72: * La méthode index permet d'indexer aussi bien
73: *
74: * des fichiers que des repertoires contenant différents fichiers
75: */
76:
77: LuceneActions.getSingletonInstance().index(toIndex,
78: indexDir,
79:
80: liusConfig);
81:
82: }
83:
84: catch (IOException ex) {
85:
86: ex.printStackTrace();
87:
88: }
89:
90: catch (LiusException ex) {
91:
92: ex.printStackTrace();
93:
94: }
95:
96: }
97:
98: }
|