source: trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/XMLCollection.java@ 5266

Last change on this file since 5266 was 5266, checked in by kjdon, 21 years ago

for a collection that hasn't been built with greenstone build stuff. expects a documentList in the collectionConfig file, and it stores this. this is where doc level metadata comes from

  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1package org.greenstone.gsdl3.collection;
2
3import org.greenstone.gsdl3.util.*;
4import org.greenstone.gsdl3.core.*;
5import org.greenstone.gsdl3.service.*;
6
7
8// java XML classes we're using
9import org.w3c.dom.Document;
10import org.w3c.dom.Node;
11import org.w3c.dom.Element;
12import org.w3c.dom.NodeList;
13
14import java.io.File;
15import java.util.HashMap;
16
17/* for a collection that hasn't been built with greenstone build stuff. expects a documentList in the collectionConfig file, and it stores this. this is where doc level metadata comes from */
18public class XMLCollection
19 extends Collection {
20
21 protected Element document_list = null;
22 /** overwrite this to keep the document list
23 * find the metadata and display elems from the two config files and add it to the appropriate lists
24 */
25 protected boolean findAndLoadInfo(Element coll_config_xml,
26 Element build_config_xml){
27
28 // metadata
29 Element meta_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
30 addMetadata(meta_list);
31 meta_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
32 addMetadata(meta_list);
33
34 meta_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
35 GSXML.addMetadata(this.doc, meta_list, "httpPath", this.site_http_address+"/collect/"+this.cluster_name);
36 addMetadata(meta_list);
37
38 // display stuff
39 Element display_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER);
40 if (display_list != null) {
41 addDisplayItems(display_list);
42 }
43
44 Element config_doc_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
45 if (config_doc_list != null) {
46 document_list = (Element)this.doc.importNode(config_doc_list, true);
47 } else {
48 document_list = this.doc.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
49 }
50 return true;
51
52 }
53
54 /** handles requests made to the ServiceCluster itself
55 *
56 * @param req - the request Element- <request>
57 * @return the result Element - should be <response>
58 */
59 protected Element processMessage(Element request) {
60
61 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
62 response.setAttribute(GSXML.FROM_ATT, this.cluster_name);
63 String type = request.getAttribute(GSXML.TYPE_ATT);
64 String lang = request.getAttribute(GSXML.LANG_ATT);
65 response.setAttribute(GSXML.TYPE_ATT, type);
66
67 if (type.equals(GSXML.REQUEST_TYPE_DESCRIBE)) {
68 // create the collection element
69 Element description = (Element)this.description.cloneNode(false);
70 response.appendChild(description);
71 // check the param list
72 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
73 if (param_list == null) {
74 addAllDisplayInfo(description, lang);
75 description.appendChild(this.service_list);
76 description.appendChild(this.metadata_list);
77 description.appendChild(this.document_list);
78 return response;
79 }
80
81 // go through the param list and see what components are wanted
82 NodeList params = param_list.getElementsByTagName(GSXML.PARAM_ELEM);
83 for (int i=0; i<params.getLength(); i++) {
84
85 Element param = (Element)params.item(i);
86 // Identify the structure information desired
87 if (param.getAttribute(GSXML.NAME_ATT) == GSXML.SUBSET_PARAM ) {
88 String info = param.getAttribute(GSXML.VALUE_ATT);
89 if (info.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) {
90 description.appendChild(this.service_list);
91 } else if (info.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) {
92 description.appendChild(metadata_list);
93 } else if (info.equals(GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER)) {
94 addAllDisplayInfo(description, lang);
95
96 } else if (info.equals(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER)) {
97 description.appendChild(this.document_list);
98 }
99
100 }
101 }
102 return response;
103 }
104
105 if (type.equals(GSXML.REQUEST_TYPE_SYSTEM)) {
106 response = processSystemRequest(request);
107 } else { // unknown type
108 System.err.println("ServiceCluster Error: cant handle request of type "+ type);
109
110 }
111 return response;
112 }
113
114}
Note: See TracBrowser for help on using the repository browser.