source: trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/Collection.java@ 3468

Last change on this file since 3468 was 3468, checked in by kjdon, 22 years ago

new class - ServiceCluster - a group of related services. Collection now extends this.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/*
2 * Collection.java
3 * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19package org.greenstone.gsdl3.collection;
20
21import org.greenstone.gsdl3.util.*;
22import org.greenstone.gsdl3.core.*;
23import org.greenstone.gsdl3.service.*;
24
25
26// java XML classes we're using
27import org.w3c.dom.Document;
28import org.w3c.dom.Node;
29import org.w3c.dom.Element;
30import org.w3c.dom.NodeList;
31
32import java.io.File;
33import java.util.HashMap;
34
35/**
36 * Represents a collection in Greenstone. A collection is an extension of
37 * a ServiceCluster - it has local data that the services use.
38 *
39 * @author <a href="mailto:[email protected]">Katherine Don</a>
40 * @version $Revision: 3468 $
41 * @see ModuleInterface
42 */
43public class Collection
44 extends ServiceCluster {
45
46 /** same as setClusterName */
47 public void setCollectionName(String name) {
48 setClusterName(name);
49 }
50
51 public Collection() {
52 service_map_ = new HashMap();
53 converter_ = new XMLConverter();
54 doc_ = converter_.newDOM();
55 description_ = doc_.createElement("collection");
56 service_info_ = doc_.createElement("serviceList");
57 meta_info_ = doc_.createElement("metadataList");
58
59 }
60
61 /**
62 * Configures the collection.
63 *
64 * gsdlHome and collectionName must be set before configure is called.
65 *
66 * the file buildcfg.xml is located in gsdlHome/collect/collectionName
67 * collection metadata is obtained, and services loaded.
68 *
69 * @return true/false on success/fail
70 */
71 public boolean configure() {
72
73 if (site_home_ == null || cluster_name_== null) {
74 System.err.println("site_home and collection_name must be set before configure called!");
75 return false;
76 }
77 // read the collection build configuration file
78 File config_file_ = new File(GSFile.collectionBuildConfigFile(site_home_, cluster_name_));
79
80 if (!config_file_.exists()) {
81 System.err.println(config_file_+" does not exist");
82 System.err.println("couldn't configure collection: "+cluster_name_);
83 return false;
84 }
85
86 Document doc = converter_.getDOM(config_file_);
87 Element e = doc.getDocumentElement();
88
89 return configure(e);
90
91 }
92
93
94}
95
96
97
98
Note: See TracBrowser for help on using the repository browser.