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

Last change on this file since 13994 was 13994, checked in by lh92, 17 years ago

Added code to read the pluginList from the collectConfig.xml. If tidy_html option is set then the tidy_option metadata is true

  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 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
17import org.apache.log4j.*;
18
19/* 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 */
20public class XMLCollection
21 extends Collection {
22
23 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.collection.XMLCollection.class.getName());
24
25 protected Element document_list = null;
26 /** overwrite this to keep the document list
27 * find the metadata and display elems from the two config files and add it to the appropriate lists
28 */
29 protected boolean findAndLoadInfo(Element coll_config_xml,
30 Element build_config_xml){
31
32 // metadata
33 Element meta_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
34 addMetadata(meta_list);
35 meta_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
36 addMetadata(meta_list);
37
38 meta_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
39 GSXML.addMetadata(this.doc, meta_list, "httpPath", this.site_http_address+"/collect/"+this.cluster_name);
40 addMetadata(meta_list);
41
42 // display stuff
43 Element display_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER);
44 if (display_list != null) {
45 addDisplayItems(display_list);
46 }
47
48 //plugin stuff
49 Element import_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.IMPORT_ELEM);
50 if (import_list != null)
51 {
52 Element plugin_list = (Element)GSXML.getChildByTagName(import_list, GSXML.PLUGIN_ELEM+GSXML.LIST_MODIFIER);
53 addPlugins(plugin_list);
54 }
55
56 Element config_doc_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
57 if (config_doc_list != null) {
58 document_list = (Element)this.doc.importNode(config_doc_list, true);
59 } else {
60 document_list = this.doc.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
61 }
62 return true;
63
64 }
65
66 /** handles requests made to the ServiceCluster itself
67 *
68 * @param req - the request Element- <request>
69 * @return the result Element - should be <response>
70 */
71 protected Element processMessage(Element request) {
72
73 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
74 response.setAttribute(GSXML.FROM_ATT, this.cluster_name);
75 String type = request.getAttribute(GSXML.TYPE_ATT);
76 String lang = request.getAttribute(GSXML.LANG_ATT);
77 response.setAttribute(GSXML.TYPE_ATT, type);
78
79 if (type.equals(GSXML.REQUEST_TYPE_DESCRIBE)) {
80 // create the collection element
81 Element description = (Element)this.description.cloneNode(false);
82 response.appendChild(description);
83 // check the param list
84 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
85 if (param_list == null) {
86 addAllDisplayInfo(description, lang);
87 description.appendChild(this.service_list);
88 description.appendChild(this.metadata_list);
89 description.appendChild(this.plugin_item_list);
90 description.appendChild(this.document_list);
91 return response;
92 }
93
94 // go through the param list and see what components are wanted
95 NodeList params = param_list.getElementsByTagName(GSXML.PARAM_ELEM);
96 for (int i=0; i<params.getLength(); i++) {
97
98 Element param = (Element)params.item(i);
99 // Identify the structure information desired
100 if (param.getAttribute(GSXML.NAME_ATT) == GSXML.SUBSET_PARAM ) {
101 String info = param.getAttribute(GSXML.VALUE_ATT);
102 if (info.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) {
103 description.appendChild(this.service_list);
104 } else if (info.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) {
105 description.appendChild(metadata_list);
106 } else if (info.equals(GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER)) {
107 addAllDisplayInfo(description, lang);
108
109 } else if (info.equals(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER)) {
110 description.appendChild(this.document_list);
111 } else if (info.equals(GSXML.PLUGIN_ELEM+GSXML.LIST_MODIFIER)) {
112 description.appendChild(this.plugin_item_list);
113 }
114
115 }
116 }
117 return response;
118 }
119
120 if (type.equals(GSXML.REQUEST_TYPE_SYSTEM)) {
121 response = processSystemRequest(request);
122 } else { // unknown type
123 logger.error("cant handle request of type "+ type);
124
125 }
126 return response;
127 }
128
129}
Note: See TracBrowser for help on using the repository browser.