1 | /*
|
---|
2 | * ServiceCluster.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 | */
|
---|
19 | // leave the package name as is for now - should be changed to something better
|
---|
20 | // cluster? groups?
|
---|
21 | package org.greenstone.gsdl3.collection;
|
---|
22 |
|
---|
23 | import java.io.File;
|
---|
24 | import java.util.HashMap;
|
---|
25 | import java.util.Iterator;
|
---|
26 |
|
---|
27 | import org.apache.log4j.Logger;
|
---|
28 | import org.greenstone.gsdl3.core.MessageRouter;
|
---|
29 | import org.greenstone.gsdl3.core.ModuleInterface;
|
---|
30 | import org.greenstone.gsdl3.service.ServiceRack;
|
---|
31 | import org.greenstone.gsdl3.util.GSFile;
|
---|
32 | import org.greenstone.gsdl3.util.GSPath;
|
---|
33 | import org.greenstone.gsdl3.util.GSXML;
|
---|
34 | import org.greenstone.gsdl3.util.SimpleMacroResolver;
|
---|
35 | import org.greenstone.gsdl3.util.UserContext;
|
---|
36 | import org.greenstone.gsdl3.util.XMLConverter;
|
---|
37 | import org.w3c.dom.Document;
|
---|
38 | import org.w3c.dom.Element;
|
---|
39 | import org.w3c.dom.Node;
|
---|
40 | import org.w3c.dom.NodeList;
|
---|
41 |
|
---|
42 | /* ServiceCluster - a groups of services that are related in some way
|
---|
43 | * Implements ModuleInterface. Contains a list of services provided by the cluster, along with metadata about the cluster itself.
|
---|
44 | * a collection is a special type of cluster
|
---|
45 | * @see ModuleInterface
|
---|
46 | */
|
---|
47 | public class ServiceCluster implements ModuleInterface
|
---|
48 | {
|
---|
49 |
|
---|
50 | static Logger logger = Logger.getLogger(org.greenstone.gsdl3.collection.ServiceCluster.class.getName());
|
---|
51 |
|
---|
52 | protected static final String CONFIG_ENCODING = "utf-8";
|
---|
53 |
|
---|
54 | protected static final String DEFAULT_LANG = "en"; // hack for now, should be read from the coll cfg file? or site cfg file for cluster
|
---|
55 |
|
---|
56 | /** base directory for the site that this cluster belongs to */
|
---|
57 | protected String site_home = null;
|
---|
58 | /** http address of the site that this cluster belongs to */
|
---|
59 | protected String site_http_address = null;
|
---|
60 | /** The name of the cluster - for a collection, this is the collection name */
|
---|
61 | protected String cluster_name = null;
|
---|
62 |
|
---|
63 | /** a reference to the message router */
|
---|
64 | protected MessageRouter router = null;
|
---|
65 | /**
|
---|
66 | * The map of services.
|
---|
67 | *
|
---|
68 | * Maps Services to ServiceRack objects
|
---|
69 | *
|
---|
70 | * @see ServiceRack
|
---|
71 | *
|
---|
72 | */
|
---|
73 | protected HashMap<String, ServiceRack> service_map = null;
|
---|
74 | /**
|
---|
75 | * maps pseudo service names to real service names - needed if we have two
|
---|
76 | * services with the same name for one collection
|
---|
77 | */
|
---|
78 | protected HashMap<String, String> service_name_map = null;
|
---|
79 |
|
---|
80 | /** XML converter for String to DOM and vice versa */
|
---|
81 | protected XMLConverter converter = null;
|
---|
82 | /** a MacroResolver for resolving macros in displayItems */
|
---|
83 | protected SimpleMacroResolver macro_resolver = null;
|
---|
84 |
|
---|
85 | /** container doc for description elements */
|
---|
86 | protected Document doc = null;
|
---|
87 | /** list of services */
|
---|
88 | protected Element service_list = null;
|
---|
89 | /** list of metadata - all metadata, regardless of language goes in here */
|
---|
90 | protected Element metadata_list = null;
|
---|
91 | /** language specific display items */
|
---|
92 |
|
---|
93 | protected Element display_item_list = null;
|
---|
94 | /** default values for servlet params */
|
---|
95 | protected Element library_param_list = null;
|
---|
96 | /** the element that will have any descriptions passed back in */
|
---|
97 | protected Element description = null;
|
---|
98 |
|
---|
99 | /** list of plugin */
|
---|
100 | //protected Element plugin_item_list = null;
|
---|
101 |
|
---|
102 | protected Element _globalFormat = null;
|
---|
103 |
|
---|
104 | public void setSiteHome(String home)
|
---|
105 | {
|
---|
106 | this.site_home = home;
|
---|
107 | }
|
---|
108 |
|
---|
109 | public void setSiteAddress(String address)
|
---|
110 | {
|
---|
111 | this.site_http_address = address;
|
---|
112 | }
|
---|
113 |
|
---|
114 | public void cleanUp()
|
---|
115 | {
|
---|
116 | Iterator<ServiceRack> i = this.service_map.values().iterator();
|
---|
117 | while (i.hasNext())
|
---|
118 | {
|
---|
119 | ServiceRack s = i.next();
|
---|
120 | s.cleanUp();
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | public void setClusterName(String name)
|
---|
125 | {
|
---|
126 | this.cluster_name = name;
|
---|
127 | this.description.setAttribute(GSXML.NAME_ATT, name);
|
---|
128 | }
|
---|
129 |
|
---|
130 | public void setMessageRouter(MessageRouter m)
|
---|
131 | {
|
---|
132 | this.router = m;
|
---|
133 | }
|
---|
134 |
|
---|
135 | public ServiceCluster()
|
---|
136 | {
|
---|
137 | this.service_map = new HashMap<String, ServiceRack>();
|
---|
138 | this.service_name_map = new HashMap<String, String>();
|
---|
139 | this.converter = new XMLConverter();
|
---|
140 | this.macro_resolver = new SimpleMacroResolver();
|
---|
141 | this.doc = this.converter.newDOM();
|
---|
142 | this.description = this.doc.createElement(GSXML.CLUSTER_ELEM);
|
---|
143 | this.display_item_list = this.doc.createElement(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER);
|
---|
144 | this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
|
---|
145 | this.library_param_list = this.doc.createElement("libraryParamList");
|
---|
146 | this.service_list = this.doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER);
|
---|
147 | //this.plugin_item_list = this.doc.createElement(GSXML.PLUGIN_ELEM + GSXML.LIST_MODIFIER);
|
---|
148 | }
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Configures the cluster.
|
---|
152 | *
|
---|
153 | * gsdlHome and clusterName must be set before configure is called.
|
---|
154 | *
|
---|
155 | * reads the site configuration file, and configures itself this calls
|
---|
156 | * configure(Element) with the XML element node from the config file.
|
---|
157 | * configure(Element) should be used if the config file has already been
|
---|
158 | * parsed. This method will work with any subclass.
|
---|
159 | *
|
---|
160 | * This is called by ServiceCluster itself when asked to do a reconfigure
|
---|
161 | * @return true if configure successful, false otherwise.
|
---|
162 | */
|
---|
163 | public boolean configure()
|
---|
164 | {
|
---|
165 |
|
---|
166 | if (this.site_home == null || this.cluster_name == null)
|
---|
167 | {
|
---|
168 | logger.error("site_home and cluster_name must be set before configure called!");
|
---|
169 | return false;
|
---|
170 | }
|
---|
171 | logger.info("configuring service cluster");
|
---|
172 | macro_resolver.addMacro("_httpsite_", this.site_http_address);
|
---|
173 | // read the site configuration file
|
---|
174 | File config_file = new File(GSFile.siteConfigFile(this.site_home));
|
---|
175 |
|
---|
176 | if (!config_file.exists())
|
---|
177 | {
|
---|
178 | logger.error("couldn't configure cluster: " + this.cluster_name + ", " + config_file + " does not exist");
|
---|
179 | return false;
|
---|
180 | }
|
---|
181 |
|
---|
182 | Document doc = this.converter.getDOM(config_file, CONFIG_ENCODING);
|
---|
183 | if (doc == null)
|
---|
184 | {
|
---|
185 | logger.error("couldn't parse config file " + config_file.getPath());
|
---|
186 | return false;
|
---|
187 | }
|
---|
188 |
|
---|
189 | // get the appropriate service cluster element
|
---|
190 | Element cluster_list = (Element) GSXML.getChildByTagName(doc.getDocumentElement(), GSXML.CLUSTER_ELEM + GSXML.LIST_MODIFIER);
|
---|
191 | Element sc = GSXML.getNamedElement(cluster_list, GSXML.CLUSTER_ELEM, GSXML.NAME_ATT, this.cluster_name);
|
---|
192 |
|
---|
193 | // this is probably a reconfigure, so clear all previous info
|
---|
194 | clearServices();
|
---|
195 | clearLocalData();
|
---|
196 | return this.configure(sc);
|
---|
197 | }
|
---|
198 |
|
---|
199 | /** this is called by configure(), but also by MR when it is loading up all the service clusters */
|
---|
200 | public boolean configure(Element service_cluster_info)
|
---|
201 | {
|
---|
202 | configureLocalData(service_cluster_info);
|
---|
203 | // //get the plugin info
|
---|
204 | // Element import_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.IMPORT_ELEM);
|
---|
205 | // if (import_list != null)
|
---|
206 | // {
|
---|
207 | // Element plugin_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.PLUGIN_ELEM + GSXML.LIST_MODIFIER);
|
---|
208 | // if (plugin_list != null)
|
---|
209 | // {
|
---|
210 | // if (!addPlugins(plugin_list))
|
---|
211 | // {
|
---|
212 |
|
---|
213 | // logger.error("couldn't configure the plugins");
|
---|
214 | // }
|
---|
215 | // }
|
---|
216 | // }
|
---|
217 |
|
---|
218 | // do the service racks
|
---|
219 | // empty the service map in case this is a reconfigure
|
---|
220 | //clearServices();
|
---|
221 | Element service_rack_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.SERVICE_CLASS_ELEM + GSXML.LIST_MODIFIER);
|
---|
222 | logger.error("cluster service rack list =");
|
---|
223 | logger.error(GSXML.xmlNodeToString(service_rack_list));
|
---|
224 | if (service_rack_list == null)
|
---|
225 | {
|
---|
226 | // is this an error? could you ever have a service cluster
|
---|
227 | // without service racks???
|
---|
228 | logger.error(cluster_name+" has no service racks!!");
|
---|
229 | }
|
---|
230 | else
|
---|
231 | {
|
---|
232 |
|
---|
233 | if (!configureServiceRackList(service_rack_list, null))
|
---|
234 | {
|
---|
235 | logger.error("couldn't configure "+cluster_name+" service racks!!");
|
---|
236 | return false;
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 | return true;
|
---|
241 | }
|
---|
242 |
|
---|
243 | protected void configureLocalData(Element service_cluster_info) {
|
---|
244 | // get the metadata - for now just add it to the list
|
---|
245 | Element meta_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
|
---|
246 | if (meta_list != null)
|
---|
247 | {
|
---|
248 | if (!addMetadata(meta_list))
|
---|
249 | {
|
---|
250 |
|
---|
251 | logger.error(" couldn't configure the metadata");
|
---|
252 | }
|
---|
253 | }
|
---|
254 |
|
---|
255 | // get the display info
|
---|
256 | Element display_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER);
|
---|
257 | if (display_list != null)
|
---|
258 | {
|
---|
259 | resolveMacros(display_list);
|
---|
260 | if (!addDisplayItems(display_list))
|
---|
261 | {
|
---|
262 |
|
---|
263 | logger.error("couldn't configure the display items");
|
---|
264 | }
|
---|
265 | }
|
---|
266 |
|
---|
267 | // get the servlet params
|
---|
268 | Element param_list = (Element) GSXML.getChildByTagName(service_cluster_info, "libraryParamList");
|
---|
269 | if (param_list != null) {
|
---|
270 | if (!addLibraryParams(param_list)) {
|
---|
271 | logger.error("couldn't configure the library param list");
|
---|
272 | }
|
---|
273 | }
|
---|
274 |
|
---|
275 | }
|
---|
276 | /**
|
---|
277 | * adds metadata from a metadataList into the metadata_list xml
|
---|
278 | */
|
---|
279 | protected boolean addMetadata(Element metadata_list)
|
---|
280 | {
|
---|
281 | if (metadata_list == null)
|
---|
282 | return false;
|
---|
283 | NodeList metanodes = metadata_list.getElementsByTagName(GSXML.METADATA_ELEM);
|
---|
284 | if (metanodes.getLength() > 0)
|
---|
285 | {
|
---|
286 | for (int k = 0; k < metanodes.getLength(); k++)
|
---|
287 | {
|
---|
288 | this.metadata_list.appendChild(this.doc.importNode(metanodes.item(k), true));
|
---|
289 | }
|
---|
290 | }
|
---|
291 |
|
---|
292 | return true;
|
---|
293 | }
|
---|
294 | /** adds an individual metadata element into the list */
|
---|
295 | protected boolean addMetadata(String name, String value) {
|
---|
296 | return GSXML.addMetadata(this.doc, this.metadata_list, name, value);
|
---|
297 | }
|
---|
298 |
|
---|
299 | /** in displayItemList, end up with the following for each named displayItem
|
---|
300 | <displayItem name="">
|
---|
301 | <displayItem name="" lang="">value</displayItem>
|
---|
302 | <displayItem name="" lang="">value</displayItem>
|
---|
303 | </displayItem>
|
---|
304 | */
|
---|
305 | protected boolean addDisplayItems(Element display_list)
|
---|
306 | {
|
---|
307 |
|
---|
308 | if (display_list == null)
|
---|
309 | return false;
|
---|
310 | NodeList displaynodes = display_list.getElementsByTagName(GSXML.DISPLAY_TEXT_ELEM);
|
---|
311 | if (displaynodes.getLength() > 0)
|
---|
312 | {
|
---|
313 | for (int k = 0; k < displaynodes.getLength(); k++)
|
---|
314 | {
|
---|
315 | Element d = (Element) displaynodes.item(k);
|
---|
316 | String lang = d.getAttribute(GSXML.LANG_ATT);
|
---|
317 | if (lang == null || lang.equals(""))
|
---|
318 | {
|
---|
319 | //set the lang to teh default
|
---|
320 | d.setAttribute(GSXML.LANG_ATT, DEFAULT_LANG);
|
---|
321 | }
|
---|
322 | String name = d.getAttribute(GSXML.NAME_ATT);
|
---|
323 | Element this_item = GSXML.getNamedElement(this.display_item_list, GSXML.DISPLAY_TEXT_ELEM, GSXML.NAME_ATT, name);
|
---|
324 | if (this_item == null)
|
---|
325 | {
|
---|
326 | this_item = this.doc.createElement(GSXML.DISPLAY_TEXT_ELEM);
|
---|
327 | this_item.setAttribute(GSXML.NAME_ATT, name);
|
---|
328 | this.display_item_list.appendChild(this_item);
|
---|
329 | }
|
---|
330 |
|
---|
331 | this_item.appendChild(this.doc.importNode(d, true));
|
---|
332 | }
|
---|
333 | }
|
---|
334 |
|
---|
335 | return true;
|
---|
336 | }
|
---|
337 |
|
---|
338 | // protected boolean addPlugins(Element plugin_list)
|
---|
339 | // {
|
---|
340 | // if (plugin_list == null)
|
---|
341 | // return false;
|
---|
342 | // NodeList pluginNodes = plugin_list.getElementsByTagName(GSXML.PLUGIN_ELEM);
|
---|
343 | // if (pluginNodes.getLength() > 0)
|
---|
344 | // {
|
---|
345 | // for (int k = 0; k < pluginNodes.getLength(); k++)
|
---|
346 | // {
|
---|
347 | // this.plugin_item_list.appendChild(this.doc.importNode(pluginNodes.item(k), true));
|
---|
348 | // }
|
---|
349 | // }
|
---|
350 |
|
---|
351 | // return true;
|
---|
352 | // }
|
---|
353 | protected boolean resolveMacros(Element display_list)
|
---|
354 | {
|
---|
355 | if (display_list == null)
|
---|
356 | return false;
|
---|
357 | NodeList displaynodes = display_list.getElementsByTagName(GSXML.DISPLAY_TEXT_ELEM);
|
---|
358 | if (displaynodes.getLength() > 0)
|
---|
359 | {
|
---|
360 | //String http_site = this.site_http_address;
|
---|
361 | //String http_collection = this.site_http_address + "/collect/" + this.cluster_name;
|
---|
362 | for (int k = 0; k < displaynodes.getLength(); k++)
|
---|
363 | {
|
---|
364 | Element d = (Element) displaynodes.item(k);
|
---|
365 | String text = GSXML.getNodeText(d);
|
---|
366 | text= macro_resolver.resolve(text);
|
---|
367 | //text = StringUtils.replace(text, "_httpsite_", http_site);
|
---|
368 | //text = StringUtils.replace(text, "_httpcollection_", http_collection);
|
---|
369 | GSXML.setNodeText(d, text);
|
---|
370 | }
|
---|
371 | }
|
---|
372 | return true;
|
---|
373 | }
|
---|
374 |
|
---|
375 | /**
|
---|
376 | * adds library params from libraryParamList into library_param_list xml
|
---|
377 | */
|
---|
378 | protected boolean addLibraryParams(Element param_list)
|
---|
379 | {
|
---|
380 | if (param_list == null)
|
---|
381 | return false;
|
---|
382 | NodeList paramnodes = param_list.getElementsByTagName(GSXML.PARAM_ELEM);
|
---|
383 | if (paramnodes.getLength() > 0)
|
---|
384 | {
|
---|
385 | for (int k = 0; k < paramnodes.getLength(); k++)
|
---|
386 | {
|
---|
387 | this.library_param_list.appendChild(this.doc.importNode(paramnodes.item(k), true));
|
---|
388 | }
|
---|
389 | }
|
---|
390 |
|
---|
391 | return true;
|
---|
392 | }
|
---|
393 | protected void clearServices()
|
---|
394 | {
|
---|
395 | cleanUp();
|
---|
396 | service_map.clear();
|
---|
397 | service_name_map.clear();
|
---|
398 | this.service_list = this.doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER);
|
---|
399 | }
|
---|
400 |
|
---|
401 | protected void clearLocalData() {
|
---|
402 | this.description = this.doc.createElement(GSXML.CLUSTER_ELEM);
|
---|
403 | this.display_item_list = this.doc.createElement(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER);
|
---|
404 | this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
|
---|
405 | this.library_param_list = this.doc.createElement("libraryParamList");
|
---|
406 |
|
---|
407 | }
|
---|
408 | /**
|
---|
409 | * creates and configures all the services - extra_info is some more xml
|
---|
410 | * that is passed to teh service - eg used for coll config files for
|
---|
411 | * Collection
|
---|
412 | */
|
---|
413 | protected boolean configureServiceRackList(Element service_rack_list, Element extra_info)
|
---|
414 | {
|
---|
415 |
|
---|
416 | // create all the services
|
---|
417 | NodeList nodes = service_rack_list.getElementsByTagName(GSXML.SERVICE_CLASS_ELEM);
|
---|
418 | if (nodes.getLength() == 0)
|
---|
419 | {
|
---|
420 | logger.error("ServiceCluster configuration error: cluster " + this.cluster_name + " has no service modules!");
|
---|
421 | return false;
|
---|
422 | }
|
---|
423 |
|
---|
424 | for (int i = 0; i < nodes.getLength(); i++)
|
---|
425 | {
|
---|
426 |
|
---|
427 | // the xml request to send to the serviceRack to query what
|
---|
428 | // services it provides
|
---|
429 | Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
|
---|
430 | Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext());
|
---|
431 | message.appendChild(request);
|
---|
432 |
|
---|
433 | Element n = (Element) nodes.item(i);
|
---|
434 | String servicetype = n.getAttribute(GSXML.NAME_ATT);
|
---|
435 |
|
---|
436 | ServiceRack s = null;
|
---|
437 |
|
---|
438 | try
|
---|
439 | {
|
---|
440 | // try for a default service in standard package
|
---|
441 | s = (ServiceRack) Class.forName("org.greenstone.gsdl3.service." + servicetype).newInstance();
|
---|
442 | }
|
---|
443 | catch (Exception e)
|
---|
444 | {
|
---|
445 | }
|
---|
446 | if (s == null)
|
---|
447 | {
|
---|
448 | try
|
---|
449 | {
|
---|
450 | // name as is, in case package is already specified
|
---|
451 | s = (ServiceRack) Class.forName(servicetype).newInstance();
|
---|
452 | }
|
---|
453 | catch (Exception e)
|
---|
454 | {
|
---|
455 | }
|
---|
456 | }
|
---|
457 |
|
---|
458 | if (s == null)
|
---|
459 | {
|
---|
460 | logger.error("Couldn't get an instance of class " + servicetype + ", or org.greenstone.gsdl3.service." + servicetype);
|
---|
461 | continue;
|
---|
462 | }
|
---|
463 |
|
---|
464 | if (_globalFormat != null)
|
---|
465 | {
|
---|
466 | s.setGlobalFormat(_globalFormat);
|
---|
467 | }
|
---|
468 |
|
---|
469 | s.setSiteHome(this.site_home);
|
---|
470 | s.setSiteAddress(this.site_http_address);
|
---|
471 | s.setClusterName(this.cluster_name);
|
---|
472 | s.setMessageRouter(this.router);
|
---|
473 | // pass the xml node to the service for configuration
|
---|
474 | if (s.configure(n, extra_info))
|
---|
475 | {
|
---|
476 | // find out the supported service types for this service module
|
---|
477 | Node types = s.process(message);
|
---|
478 | NodeList typenodes = ((Element) types).getElementsByTagName(GSXML.SERVICE_ELEM);
|
---|
479 |
|
---|
480 | for (int j = 0; j < typenodes.getLength(); j++)
|
---|
481 | {
|
---|
482 | String service = ((Element) typenodes.item(j)).getAttribute(GSXML.NAME_ATT);
|
---|
483 |
|
---|
484 | if (service_map.get(service) != null)
|
---|
485 | {
|
---|
486 | char extra = '0';
|
---|
487 | String new_service = service + extra;
|
---|
488 |
|
---|
489 | while (service_map.get(new_service) != null)
|
---|
490 | {
|
---|
491 | extra++;
|
---|
492 | new_service = service + extra;
|
---|
493 | }
|
---|
494 | this.service_name_map.put(new_service, service);
|
---|
495 | service = new_service;
|
---|
496 | ((Element) typenodes.item(j)).setAttribute(GSXML.NAME_ATT, service);
|
---|
497 | }
|
---|
498 | this.service_map.put(service, s);
|
---|
499 | // also add info to the ServiceInfo XML element
|
---|
500 | this.service_list.appendChild(this.doc.importNode(typenodes.item(j), true));
|
---|
501 | }
|
---|
502 | }
|
---|
503 | }
|
---|
504 |
|
---|
505 | return true;
|
---|
506 |
|
---|
507 | }
|
---|
508 |
|
---|
509 | /**
|
---|
510 | * Process an XML document - uses Strings just calls process(Node).
|
---|
511 | *
|
---|
512 | * @param in
|
---|
513 | * the Document to process - a string
|
---|
514 | * @return the resultant document as a string - contains any error messages
|
---|
515 | * @see String
|
---|
516 | */
|
---|
517 | public String process(String in)
|
---|
518 | {
|
---|
519 |
|
---|
520 | Document doc = this.converter.getDOM(in);
|
---|
521 |
|
---|
522 | Node res = process(doc);
|
---|
523 | return this.converter.getString(res);
|
---|
524 |
|
---|
525 | }
|
---|
526 |
|
---|
527 | /**
|
---|
528 | * process XML as Node
|
---|
529 | *
|
---|
530 | */
|
---|
531 | public Node process(Node message_node)
|
---|
532 | {
|
---|
533 | Element message = this.converter.nodeToElement(message_node);
|
---|
534 |
|
---|
535 | NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM);
|
---|
536 | Document mess_doc = message.getOwnerDocument();
|
---|
537 | Element mainResult = this.doc.createElement(GSXML.MESSAGE_ELEM);
|
---|
538 | if (requests.getLength() == 0)
|
---|
539 | {
|
---|
540 | logger.error("no requests for cluster:" + this.cluster_name);
|
---|
541 | // no requests
|
---|
542 | return mainResult; // for now
|
---|
543 | }
|
---|
544 | for (int i = 0; i < requests.getLength(); i++)
|
---|
545 | {
|
---|
546 | Element request = (Element) requests.item(i);
|
---|
547 | String to = request.getAttribute(GSXML.TO_ATT);
|
---|
548 |
|
---|
549 | // the cluster name should be first, check, then remove
|
---|
550 | String clustername = GSPath.getFirstLink(to);
|
---|
551 | if (!clustername.equals(this.cluster_name))
|
---|
552 | {
|
---|
553 | logger.error("cluster name wrong! was " + clustername + " should have been " + this.cluster_name);
|
---|
554 | continue; // ignore this request
|
---|
555 | }
|
---|
556 | to = GSPath.removeFirstLink(to);
|
---|
557 | request.setAttribute(GSXML.TO_ATT, to);
|
---|
558 |
|
---|
559 | if (to.equals(""))
|
---|
560 | { // this command is for me
|
---|
561 | Element response = processMessage(request);
|
---|
562 | mainResult.appendChild(response);
|
---|
563 |
|
---|
564 | }
|
---|
565 | else
|
---|
566 | { // the request is for one of my services
|
---|
567 | String service = GSPath.getFirstLink(to);
|
---|
568 |
|
---|
569 | if (!this.service_map.containsKey(service))
|
---|
570 | {
|
---|
571 | logger.error("non-existant service, " + service + ", specified!");
|
---|
572 | continue;
|
---|
573 | }
|
---|
574 | String real_service = service;
|
---|
575 | if (this.service_name_map.containsKey(service))
|
---|
576 | {
|
---|
577 | real_service = this.service_name_map.get(service);
|
---|
578 | // need to change the to att in the request - give the real service name
|
---|
579 | to = request.getAttribute(GSXML.TO_ATT);
|
---|
580 | String old_to = to;
|
---|
581 | to = GSPath.replaceFirstLink(to, real_service);
|
---|
582 | request.setAttribute(GSXML.TO_ATT, to);
|
---|
583 | }
|
---|
584 | // have to pass the request to the service
|
---|
585 | Element single_message = mess_doc.createElement(GSXML.MESSAGE_ELEM);
|
---|
586 | single_message.appendChild(request);
|
---|
587 |
|
---|
588 | Node response_message = this.service_map.get(service).process(single_message);
|
---|
589 | if (response_message != null)
|
---|
590 | {
|
---|
591 | Element response = (Element) GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM);
|
---|
592 | String from = response.getAttribute(GSXML.FROM_ATT);
|
---|
593 | if (!real_service.equals(service))
|
---|
594 | {
|
---|
595 | // replace the real service name with the pseudo service name
|
---|
596 | from = GSPath.replaceFirstLink(from, service);
|
---|
597 | // also need to do it in the service itself
|
---|
598 | // shoudl this be done here??
|
---|
599 | Element service_elem = (Element) GSXML.getChildByTagName(response, GSXML.SERVICE_ELEM);
|
---|
600 | if (service_elem != null)
|
---|
601 | {
|
---|
602 | service_elem.setAttribute(GSXML.NAME_ATT, service);
|
---|
603 | }
|
---|
604 | }
|
---|
605 | from = GSPath.prependLink(from, this.cluster_name);
|
---|
606 | response.setAttribute(GSXML.FROM_ATT, from);
|
---|
607 | mainResult.appendChild(this.doc.importNode(response, true));
|
---|
608 | }
|
---|
609 |
|
---|
610 | } // else
|
---|
611 |
|
---|
612 | } // for each request
|
---|
613 | return mainResult;
|
---|
614 | }
|
---|
615 |
|
---|
616 | /**
|
---|
617 | * handles requests made to the ServiceCluster itself
|
---|
618 | *
|
---|
619 | * @param req
|
---|
620 | * - the request Element- <request>
|
---|
621 | * @return the result Element - should be <response>
|
---|
622 | */
|
---|
623 | protected Element processMessage(Element request)
|
---|
624 | {
|
---|
625 | Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
|
---|
626 | response.setAttribute(GSXML.FROM_ATT, this.cluster_name);
|
---|
627 | String type = request.getAttribute(GSXML.TYPE_ATT);
|
---|
628 | String lang = request.getAttribute(GSXML.LANG_ATT);
|
---|
629 | response.setAttribute(GSXML.TYPE_ATT, type);
|
---|
630 |
|
---|
631 | if (type.equals(GSXML.REQUEST_TYPE_DESCRIBE))
|
---|
632 | {
|
---|
633 | // create the collection element
|
---|
634 | Element description = (Element) this.description.cloneNode(false);
|
---|
635 | // set collection type : mg, mgpp, lucene or solr
|
---|
636 | //description.setAttribute(GSXML.TYPE_ATT, col_type);
|
---|
637 | //description.setAttribute(GSXML.DB_TYPE_ATT, db_type);
|
---|
638 |
|
---|
639 | response.appendChild(description);
|
---|
640 | // check the param list
|
---|
641 | Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
|
---|
642 | if (param_list == null)
|
---|
643 | {
|
---|
644 | addAllDisplayInfo(description, lang);
|
---|
645 | description.appendChild(this.service_list);
|
---|
646 | description.appendChild(this.metadata_list);
|
---|
647 | description.appendChild(this.library_param_list);
|
---|
648 | //description.appendChild(this.plugin_item_list);
|
---|
649 | return response;
|
---|
650 | }
|
---|
651 |
|
---|
652 | // go through the param list and see what components are wanted
|
---|
653 | NodeList params = param_list.getElementsByTagName(GSXML.PARAM_ELEM);
|
---|
654 | for (int i = 0; i < params.getLength(); i++)
|
---|
655 | {
|
---|
656 |
|
---|
657 | Element param = (Element) params.item(i);
|
---|
658 | // Identify the structure information desired
|
---|
659 | if (param.getAttribute(GSXML.NAME_ATT).equals(GSXML.SUBSET_PARAM))
|
---|
660 | {
|
---|
661 | String info = param.getAttribute(GSXML.VALUE_ATT);
|
---|
662 | if (info.equals(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER))
|
---|
663 | {
|
---|
664 | description.appendChild(this.service_list);
|
---|
665 | }
|
---|
666 | else if (info.equals(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER))
|
---|
667 | {
|
---|
668 | description.appendChild(this.metadata_list);
|
---|
669 | }
|
---|
670 | else if (info.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER))
|
---|
671 | {
|
---|
672 | addAllDisplayInfo(description, lang);
|
---|
673 | }
|
---|
674 | else if (info.equals("libraryParamlist"))
|
---|
675 | {
|
---|
676 | description.appendChild(this.library_param_list);
|
---|
677 | }
|
---|
678 | }
|
---|
679 | }
|
---|
680 | return response;
|
---|
681 | }
|
---|
682 | /*
|
---|
683 | * if (type.equals(GSXML.REQUEST_TYPE_FORMAT_STRING)) {
|
---|
684 | * logger.error("Received format string request"); String service =
|
---|
685 | * request.getAttribute("service"); logger.error("Service is " +
|
---|
686 | * service); String classifier = null;
|
---|
687 | * if(service.equals("ClassifierBrowse")) { classifier =
|
---|
688 | * request.getAttribute("classifier"); logger.error("Classifier is " +
|
---|
689 | * classifier); } Element format_element = (Element)
|
---|
690 | * GSXML.getChildByTagName(request, GSXML.FORMAT_STRING_ELEM); String
|
---|
691 | * format_string = GSXML.getNodeText(format_element);
|
---|
692 | * logger.error("Format string: " + format_string);
|
---|
693 | * logger.error("Config file location = " +
|
---|
694 | * GSFile.collectionConfigFile(this.site_home, this.cluster_name));
|
---|
695 | *
|
---|
696 | * // check for version file
|
---|
697 | *
|
---|
698 | * String directory = new
|
---|
699 | * File(GSFile.collectionConfigFile(this.site_home,
|
---|
700 | * this.cluster_name)).getParent() + File.pathSeparator;
|
---|
701 | * logger.error("Directory is " + directory);
|
---|
702 | *
|
---|
703 | * String version_filename = "";
|
---|
704 | *
|
---|
705 | * if(service.equals("ClassifierBrowse")) version_filename = directory +
|
---|
706 | * "browse_"+classifier+"_format_statement_version.txt"; else
|
---|
707 | * version_filename = directory + "query_format_statement_version.txt";
|
---|
708 | *
|
---|
709 | * File version_file = new File(version_filename);
|
---|
710 | * logger.error("Version filename is " + version_filename);
|
---|
711 | *
|
---|
712 | * String version_number = "1"; BufferedWriter writer; // = new
|
---|
713 | * BufferedWriter(new FileWriter(version_filename)); //RandomAccessFile
|
---|
714 | * version_file_random_access;
|
---|
715 | *
|
---|
716 | * try{
|
---|
717 | *
|
---|
718 | * if(version_file.exists()) { // Read version BufferedReader reader =
|
---|
719 | * new BufferedReader(new FileReader(version_filename));
|
---|
720 | * //version_file_random_access = new RandomAccessFile(version_file,
|
---|
721 | * "r"); //logger.error(" //version_number =
|
---|
722 | * version_file_random_access.readInt(); version_number =
|
---|
723 | * reader.readLine(); int aInt = Integer.parseInt(version_number) + 1;
|
---|
724 | * version_number = Integer.toString(aInt); reader.close();
|
---|
725 | * //version_file_random_access.close(); } else{ // Create
|
---|
726 | * version_file.createNewFile(); // write 1 to file writer = new
|
---|
727 | * BufferedWriter(new FileWriter(version_filename));
|
---|
728 | * //version_file_random_access = new RandomAccessFile(version_file,
|
---|
729 | * "w"); //version_file_random_access.writeInt(version_number);
|
---|
730 | * writer.write(version_number); writer.close();
|
---|
731 | * //version_file_random_access.close(); }
|
---|
732 | *
|
---|
733 | * // Write version file String format_statement_filename = "";
|
---|
734 | *
|
---|
735 | * if(service.equals("ClassifierBrowse")) format_statement_filename =
|
---|
736 | * directory + "browse_"+classifier+"_format_statement_v" +
|
---|
737 | * version_number + ".txt"; else format_statement_filename = directory +
|
---|
738 | * "query_format_statement_v" + version_number + ".txt";
|
---|
739 | *
|
---|
740 | * logger.error("Format statement filename is " +
|
---|
741 | * format_statement_filename);
|
---|
742 | *
|
---|
743 | * writer = new BufferedWriter(new
|
---|
744 | * FileWriter(format_statement_filename)); writer.write(format_string);
|
---|
745 | * writer.close();
|
---|
746 | *
|
---|
747 | * // Update version number //version_file_random_access = new
|
---|
748 | * RandomAccessFile(version_file, "w");
|
---|
749 | * //version_file_random_access.writeInt(version_number);
|
---|
750 | * //version_file_random_access.close();
|
---|
751 | *
|
---|
752 | * writer = new BufferedWriter(new FileWriter(version_filename));
|
---|
753 | * //version_file_random_access = new RandomAccessFile(version_file,
|
---|
754 | * "w"); //version_file_random_access.writeInt(version_number);
|
---|
755 | * writer.write(version_number); writer.close();
|
---|
756 | *
|
---|
757 | *
|
---|
758 | *
|
---|
759 | * } catch (IOException e) { logger.error("IO Exception "+e);
|
---|
760 | * //System.exit(1); }
|
---|
761 | *
|
---|
762 | *
|
---|
763 | * }
|
---|
764 | */
|
---|
765 | if (type.equals(GSXML.REQUEST_TYPE_SYSTEM))
|
---|
766 | {
|
---|
767 | response = processSystemRequest(request);
|
---|
768 | }
|
---|
769 | else
|
---|
770 | { // unknown type
|
---|
771 | logger.error("cant handle request of type " + type);
|
---|
772 |
|
---|
773 | }
|
---|
774 | return response;
|
---|
775 | }
|
---|
776 |
|
---|
777 | protected Element processSystemRequest(Element request)
|
---|
778 | {
|
---|
779 |
|
---|
780 | Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
|
---|
781 | response.setAttribute(GSXML.FROM_ATT, this.cluster_name);
|
---|
782 | response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_SYSTEM);
|
---|
783 |
|
---|
784 | // a list of system requests - should put any error messages
|
---|
785 | // or success messages into response
|
---|
786 | NodeList commands = request.getElementsByTagName(GSXML.SYSTEM_ELEM);
|
---|
787 | String message = null;
|
---|
788 | for (int i = 0; i < commands.getLength(); i++)
|
---|
789 | {
|
---|
790 | // all the commands should be Elements
|
---|
791 | Element elem = (Element) commands.item(i);
|
---|
792 | String action = elem.getAttribute(GSXML.TYPE_ATT);
|
---|
793 | if (action.equals(GSXML.SYSTEM_TYPE_CONFIGURE))
|
---|
794 | {
|
---|
795 | String subset = elem.getAttribute(GSXML.SYSTEM_SUBSET_ATT);
|
---|
796 | if (subset.equals(""))
|
---|
797 | {
|
---|
798 | // need to reconfigure the service cluster
|
---|
799 |
|
---|
800 | if (this.configure())
|
---|
801 | {
|
---|
802 | Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " reconfigured");
|
---|
803 | response.appendChild(s);
|
---|
804 |
|
---|
805 | }
|
---|
806 | else
|
---|
807 | {
|
---|
808 | Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " could not be reconfigured");
|
---|
809 | response.appendChild(s);
|
---|
810 | }
|
---|
811 | }
|
---|
812 | else if (this.configureSubset(subset))
|
---|
813 | {
|
---|
814 | Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " " + subset + " reconfigured");
|
---|
815 | response.appendChild(s);
|
---|
816 | }
|
---|
817 | else
|
---|
818 | {
|
---|
819 | Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " " + subset + " could not be reconfigured");
|
---|
820 | response.appendChild(s);
|
---|
821 | }
|
---|
822 | continue;
|
---|
823 | } // configure action
|
---|
824 |
|
---|
825 | String module_name = elem.getAttribute(GSXML.SYSTEM_MODULE_NAME_ATT);
|
---|
826 | String module_type = elem.getAttribute(GSXML.SYSTEM_MODULE_TYPE_ATT);
|
---|
827 | if (action.equals(GSXML.SYSTEM_TYPE_ACTIVATE))
|
---|
828 | {
|
---|
829 | Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, "activate action not yet implemented - does it even make sense in this context??");
|
---|
830 | response.appendChild(s);
|
---|
831 | }
|
---|
832 | else if (action.equals(GSXML.SYSTEM_TYPE_DEACTIVATE))
|
---|
833 | {
|
---|
834 | if (module_type.equals(GSXML.SERVICE_ELEM))
|
---|
835 | {
|
---|
836 | // deactivate the service
|
---|
837 | // remove from service_map
|
---|
838 | this.service_map.remove(module_name);
|
---|
839 | Element service_elem = GSXML.getNamedElement(this.service_list, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, module_name);
|
---|
840 | service_list.removeChild(service_elem);
|
---|
841 | message = module_type + ": " + module_name + " deactivated";
|
---|
842 | }
|
---|
843 | else
|
---|
844 | {
|
---|
845 | message = "can't deactivate " + module_type + " type modules!";
|
---|
846 | }
|
---|
847 | Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, message);
|
---|
848 | response.appendChild(s);
|
---|
849 | }
|
---|
850 | else
|
---|
851 | {
|
---|
852 | logger.error("cant process system request, action " + action);
|
---|
853 | continue;
|
---|
854 | }
|
---|
855 | } // for each command
|
---|
856 | return response;
|
---|
857 | }
|
---|
858 |
|
---|
859 | /**
|
---|
860 | * do a configure on only part of the collection
|
---|
861 | */
|
---|
862 | protected boolean configureSubset(String subset)
|
---|
863 | {
|
---|
864 |
|
---|
865 | File configFile = new File(GSFile.siteConfigFile(this.site_home));
|
---|
866 | if (!configFile.exists())
|
---|
867 | {
|
---|
868 | logger.error("site config file: " + configFile.getPath() + " not found!");
|
---|
869 | // wont be able to do any of the requests
|
---|
870 | return false;
|
---|
871 |
|
---|
872 | }
|
---|
873 |
|
---|
874 | Document site_config_doc = this.converter.getDOM(configFile);
|
---|
875 | if (site_config_doc == null)
|
---|
876 | {
|
---|
877 | logger.error("could not read in site config file: " + configFile.getPath());
|
---|
878 | return false;
|
---|
879 | }
|
---|
880 |
|
---|
881 | Element site_config_elem = site_config_doc.getDocumentElement();
|
---|
882 | Element cluster_config_elem = GSXML.getNamedElement((Element) GSXML.getChildByTagName(site_config_elem, GSXML.CLUSTER_ELEM + GSXML.LIST_MODIFIER), GSXML.CLUSTER_ELEM, GSXML.NAME_ATT, this.cluster_name);
|
---|
883 | if (cluster_config_elem == null)
|
---|
884 | {
|
---|
885 | logger.error("site config file: " + configFile.getPath() + " has no element for cluster " + this.cluster_name);
|
---|
886 | // wont be able to do any of teh requests
|
---|
887 | return false;
|
---|
888 |
|
---|
889 | }
|
---|
890 | if (subset.equals(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER))
|
---|
891 | {
|
---|
892 | Element service_rack_list = (Element) GSXML.getChildByTagName(cluster_config_elem, GSXML.SERVICE_CLASS_ELEM + GSXML.LIST_MODIFIER);
|
---|
893 | clearServices();
|
---|
894 | return configureServiceRackList(service_rack_list, null);
|
---|
895 | }
|
---|
896 | else if (subset.equals(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER))
|
---|
897 | {
|
---|
898 | this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
|
---|
899 | Element metadata_list = (Element) GSXML.getChildByTagName(cluster_config_elem, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
|
---|
900 | return addMetadata(metadata_list);
|
---|
901 | }
|
---|
902 | // else if (subset.equals(GSXML.PLUGIN_ELEM + GSXML.LIST_MODIFIER))
|
---|
903 | // {
|
---|
904 | // this.plugin_item_list = this.doc.createElement(GSXML.PLUGIN_ELEM + GSXML.LIST_MODIFIER);
|
---|
905 | // Element import_list = (Element) GSXML.getChildByTagName(cluster_config_elem, GSXML.IMPORT_ELEM);
|
---|
906 | // if (import_list != null)
|
---|
907 | // {
|
---|
908 | // Element plugin_item_list = (Element) GSXML.getChildByTagName(cluster_config_elem, GSXML.PLUGIN_ELEM + GSXML.LIST_MODIFIER);
|
---|
909 | // return addPlugins(plugin_item_list);
|
---|
910 | // }
|
---|
911 | // else
|
---|
912 | // return false;
|
---|
913 | // }
|
---|
914 | else
|
---|
915 | {
|
---|
916 | logger.error("cannot process system request, configure " + subset);
|
---|
917 | return false;
|
---|
918 | }
|
---|
919 |
|
---|
920 | }
|
---|
921 |
|
---|
922 | protected boolean addAllDisplayInfo(Element description, String lang)
|
---|
923 | {
|
---|
924 |
|
---|
925 | NodeList items = this.display_item_list.getChildNodes();
|
---|
926 | for (int i = 0; i < items.getLength(); i++)
|
---|
927 | { // for each key
|
---|
928 | Element m = (Element) items.item(i);
|
---|
929 | // findthe child with the correct language
|
---|
930 | Element new_m = GSXML.getNamedElement(m, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, lang);
|
---|
931 | if (new_m == null && lang != DEFAULT_LANG)
|
---|
932 | {
|
---|
933 | // use the default lang
|
---|
934 | new_m = GSXML.getNamedElement(m, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, DEFAULT_LANG);
|
---|
935 | }
|
---|
936 | if (new_m == null)
|
---|
937 | {
|
---|
938 | // just get the first one
|
---|
939 | new_m = (Element) GSXML.getChildByTagName(m, GSXML.DISPLAY_TEXT_ELEM);
|
---|
940 | }
|
---|
941 | description.appendChild(new_m.cloneNode(true));
|
---|
942 | }
|
---|
943 | return true;
|
---|
944 |
|
---|
945 | }
|
---|
946 |
|
---|
947 | protected Element getDisplayTextElement(String key, String lang)
|
---|
948 | {
|
---|
949 |
|
---|
950 | Element this_item = GSXML.getNamedElement(this.display_item_list, GSXML.DISPLAY_TEXT_ELEM, GSXML.NAME_ATT, key);
|
---|
951 | if (this_item == null)
|
---|
952 | {
|
---|
953 | return null;
|
---|
954 | }
|
---|
955 |
|
---|
956 | Element this_lang = GSXML.getNamedElement(this_item, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, lang);
|
---|
957 | if (this_lang == null && lang != DEFAULT_LANG)
|
---|
958 | {
|
---|
959 | // try the default
|
---|
960 | this_lang = GSXML.getNamedElement(this_item, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, DEFAULT_LANG);
|
---|
961 | }
|
---|
962 | if (this_lang == null)
|
---|
963 | {
|
---|
964 | // just return the first one
|
---|
965 | return GSXML.getFirstElementChild(this_item);//(Element)this_item.getFirstChild().cloneNode(true);
|
---|
966 | }
|
---|
967 | return (Element) this_lang.cloneNode(true);
|
---|
968 |
|
---|
969 | }
|
---|
970 |
|
---|
971 | public HashMap<String, ServiceRack> getServiceMap()
|
---|
972 | {
|
---|
973 | return service_map;
|
---|
974 | }
|
---|
975 | }
|
---|