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: /**
26: *
27: * @author Rida Benjelloun (rida.benjelloun@bibl.ulaval.ca)
28: *
29: */
30:
31: import java.io.File;
32: import java.io.IOException;
33: import java.util.StringTokenizer;
34:
35: import ca.ulaval.bibl.lius.LiusLogger;
36: import ca.ulaval.bibl.lius.Exception.LiusException;
37: import ca.ulaval.bibl.lius.Lucene.LuceneActions;
38:
39: public class MixteIndexing {
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: "liusMixteConfig.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 + "dc" + sep + "1";
64:
65: LiusLogger.setLoggerConfigFile(log4j);
66:
67: try {
68:
69: LuceneActions.getSingletonInstance().deleteAllDocuments(
70: indexDir);
71:
72: /*
73: * La méthode index permet d'indexer aussi bien
74: *
75: * des fichiers que des repertoires contenant différents fichiers
76: */
77:
78: LuceneActions.getSingletonInstance().index(toIndex,
79: indexDir,
80:
81: liusConfig);
82:
83: }
84:
85: catch (IOException ex) {
86:
87: ex.printStackTrace();
88:
89: }
90:
91: catch (LiusException ex) {
92:
93: ex.printStackTrace();
94:
95: }
96:
97: }
98:
99: }
|