source: main/trunk/greenstone3/web/sites/localsite/collect/gberg/java/BuildXMLColl.java@ 32485

Last change on this file since 32485 was 5956, checked in by kjdon, 20 years ago

new files for making a simple lucene collection from xml documents

  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1/**
2 *
3 * class for building a simple XML collection
4 * @author [email protected]
5 * @version
6 */
7
8
9import org.greenstone.gsdl3.util.GSFile;
10
11import java.io.File;
12
13public class BuildXMLColl {
14
15 public static void main (String args[]) throws Exception {
16 if (args.length != 2) {
17 System.out.println("Usage: java BuildXMLColl site-home coll-name");
18 return;
19 }
20
21 String site_home = args[0];
22 String coll_name = args[1];
23
24 File import_dir = new File(GSFile.collectionImportDir(site_home, coll_name));
25 File building_dir = new File(GSFile.collectionBuildDir(site_home, coll_name));
26
27 if (!import_dir.exists()) {
28 System.out.println("Couldn't find import dir for collection "+coll_name);
29 return;
30 }
31
32 if (building_dir.exists()) {
33 // get rid of it
34 GSFile.deleteFile(building_dir);
35 }
36 building_dir.mkdir();
37
38 File idx_dir = new File(building_dir.getPath()+File.separator+"idx"+File.separator+"temp.txt");
39 idx_dir = idx_dir.getParentFile();
40 File text_dir = new File(building_dir.getPath()+File.separator+"text"+File.separator+"temp.txt");
41 text_dir = text_dir.getParentFile();
42 idx_dir.mkdir();
43 text_dir.mkdir();
44
45 // first we import the coll
46 ImportXML importer = new ImportXML();
47 importer.setOutDir(text_dir);
48 importer.init();
49 importer.importFile(import_dir);
50 importer.finish();
51
52 // then we index it
53 IndexXML indexer = new IndexXML();
54 indexer.setOutDir(idx_dir);
55 indexer.init();
56 indexer.indexFile(text_dir);
57 indexer.finish();
58 }
59}
Note: See TracBrowser for help on using the repository browser.