source: branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java@ 9824

Last change on this file since 9824 was 9824, checked in by kjdon, 19 years ago

when a collection (using gdbm) is opened by tomcat, windows holds a lock on the gdbm file, so you can't rebuild it. modified ModuleInterface to have a cleanUp method, so all modules need to implement this. for mg/mgpp and gdbm modules, they now unload the index data or close the connection to the database. so cleanUp should be called whenever you deactivate a module

  • Property svn:keywords set to Author Date Id Revision
File size: 22.5 KB
Line 
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?
21package org.greenstone.gsdl3.collection;
22
23
24import org.greenstone.gsdl3.util.*;
25import org.greenstone.gsdl3.core.*;
26import org.greenstone.gsdl3.service.*;
27
28// java XML classes we're using
29import org.w3c.dom.Document;
30import org.w3c.dom.Node;
31import org.w3c.dom.Element;
32import org.w3c.dom.NodeList;
33
34import java.io.File;
35import java.util.HashMap;
36import java.util.Iterator;
37
38/* ServiceCluster - a groups of services that are related in some way
39 * Implements ModuleInterface. Contains a list of services provided by the cluster, along with metadata about the cluster itself.
40 * a collection is a special type of cluster
41 * @author <a href="mailto:[email protected]">Katherine Don</a>
42 * @version $Revision: 9824 $
43 * @see ModuleInterface
44 */
45public class ServiceCluster
46 implements ModuleInterface {
47
48 protected static final String CONFIG_ENCODING = "utf-8";
49
50 protected static final String DEFAULT_LANG = "en"; // hack for now, should be read from the coll cfg file? or site cfg file for cluster
51
52 /** base directory for the site that this cluster belongs to*/
53 protected String site_home = null;
54 /** http address of the site that this cluster belongs to */
55 protected String site_http_address = null;
56 /** The name of the cluster - for a collection, this is the collection name*/
57 protected String cluster_name = null;
58
59 /** a reference to the message router */
60 protected MessageRouter router = null;
61 /** The map of services.
62 *
63 * Maps Services to ServiceRack objects
64 * @see ServiceRack
65 *
66 */
67 protected HashMap service_map=null;
68 /** maps pseudo service names to real service names - needed if we have two services with the same name for one collection */
69 protected HashMap service_name_map=null;
70
71 /** XML converter for String to DOM and vice versa */
72 protected XMLConverter converter=null;
73
74 /** container doc for description elements */
75 protected Document doc = null;
76 /** list of services */
77 protected Element service_list = null;
78 /** list of metadata - all metadata, regardless of language goes in here */
79 protected Element metadata_list = null;
80 /** language specific stuff */
81 //protected Element lang_specific_metadata_list = null;
82 protected Element display_item_list = null;
83 /** the element that will have any descriptions passed back in */
84 protected Element description = null;
85
86 public void setSiteHome(String home) {
87 this.site_home = home;
88 }
89
90 public void setSiteAddress(String address) {
91 this.site_http_address = address;
92 }
93
94 public void cleanUp() {
95 Iterator i = this.service_map.values().iterator();
96 while (i.hasNext()) {
97 ServiceRack s = (ServiceRack)i.next();
98 s.cleanUp();
99 }
100 }
101 public void setClusterName(String name) {
102 this.cluster_name = name;
103 this.description.setAttribute(GSXML.NAME_ATT, name);
104 }
105
106 public void setMessageRouter(MessageRouter m) {
107 this.router = m;
108 }
109
110 public ServiceCluster() {
111 this.service_map = new HashMap();
112 this.service_name_map = new HashMap();
113 this.converter = new XMLConverter();
114 this.doc = this.converter.newDOM();
115 this.description = this.doc.createElement(GSXML.CLUSTER_ELEM);
116 this.display_item_list = this.doc.createElement(GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER);
117 this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
118 }
119
120 /**
121 * Configures the cluster.
122 *
123 * gsdlHome and clusterName must be set before configure is called.
124 *
125 * reads the site configuration file, and configures itself
126 * this calls configure(Element) with the XML element node from the config
127 * file.
128 * configure(Element) should be used if the config file has already been
129 * parsed. This method will work with any subclass.
130 *
131 * @return true if configure successful, false otherwise.
132 */
133 public boolean configure() {
134
135 if (this.site_home == null || this.cluster_name== null) {
136 System.err.println("ServiceCluster: site_home and cluster_name must be set before configure called!");
137 return false;
138 }
139 System.out.println("configuring service cluster");
140 // read the site configuration file
141 File config_file = new File(GSFile.siteConfigFile(this.site_home));
142
143 if (!config_file.exists()) {
144 System.err.println("ServiceCluster: couldn't configure cluster: "+this.cluster_name +", "+config_file+" does not exist");
145 return false;
146 }
147
148 Document doc = this.converter.getDOM(config_file, CONFIG_ENCODING);
149 if (doc == null) {
150 System.err.println("ServiceCluster: couldn't parse config file "+config_file.getPath());
151 return false;
152 }
153
154 // get the appropriate service cluster element
155 Element cluster_list = (Element)GSXML.getChildByTagName(doc.getDocumentElement(), GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);
156 Element sc = GSXML.getNamedElement(cluster_list, GSXML.CLUSTER_ELEM,
157 GSXML.NAME_ATT, this.cluster_name);
158
159 return this.configure(sc);
160 }
161
162
163 public boolean configure(Element service_cluster_info) {
164
165 // get the metadata - for now just add it to the list
166 Element meta_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
167 if (meta_list !=null) {
168 if (!addMetadata(meta_list)) {
169
170 System.err.println("ServiceCluster: couldn't configure the metadata");
171 }
172 }
173
174 // get the display info
175 Element display_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER);
176 if (display_list !=null) {
177 if (!addDisplayItems(display_list)) {
178
179 System.err.println("ServiceCluster: couldn't configure the display items");
180 }
181 }
182
183
184 // do the service racks
185 Element service_rack_list = (Element)GSXML.getChildByTagName(service_cluster_info, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER);
186 if (service_rack_list == null) {
187 // is this an error? could you ever have a service cluster
188 // without service racks???
189 System.err.println("ServiceCluster: cluster has no service racks!!");
190 } else {
191
192 if (!configureServiceRack(service_rack_list, null)) {
193 System.err.println("ServiceCluster: couldn't configure the service racks!!");
194 return false;
195 }
196 }
197
198 return true;
199 }
200
201 /** adds metadata from a metadataList into the metadata_list xml
202 */
203 protected boolean addMetadata(Element metadata_list) {
204 if (metadata_list == null) return false;
205 NodeList metanodes = metadata_list.getElementsByTagName(GSXML.METADATA_ELEM);
206 if (metanodes.getLength()>0) {
207 for(int k=0; k<metanodes.getLength(); k++) {
208 this.metadata_list.appendChild(this.doc.importNode(metanodes.item(k), true));
209 }
210 }
211
212 return true;
213 }
214
215 protected boolean addDisplayItems(Element display_list) {
216
217 if (display_list==null) return false;
218 NodeList displaynodes = display_list.getElementsByTagName(GSXML.DISPLAY_TEXT_ELEM);
219 if (displaynodes.getLength()>0) {
220 for(int k=0; k<displaynodes.getLength(); k++) {
221 Element d = (Element) displaynodes.item(k);
222 String lang = d.getAttribute(GSXML.LANG_ATT);
223 if (lang==null||lang.equals("")) {
224 //set the lang to teh default
225 d.setAttribute(GSXML.LANG_ATT, DEFAULT_LANG);
226 }
227 String name = d.getAttribute(GSXML.NAME_ATT);
228 Element this_item = GSXML.getNamedElement(this.display_item_list, GSXML.DISPLAY_TEXT_ELEM, GSXML.NAME_ATT, name);
229 if (this_item==null) {
230 this_item = this.doc.createElement(GSXML.DISPLAY_TEXT_ELEM);
231 this_item.setAttribute(GSXML.NAME_ATT, name);
232 this.display_item_list.appendChild(this_item);
233 }
234
235 this_item.appendChild(this.doc.importNode(d, true));
236
237
238 }
239 }
240
241 return true;
242 }
243
244 /** creates and configures all the services - extra_info is some more xml
245that is passed to teh service - eg used for coll config files for Collection
246 */
247 protected boolean configureServiceRack(Element service_rack_list,
248 Element extra_info) {
249
250 // empty the service map in case this is a reconfigure
251 service_map.clear();
252 this.service_list = this.doc.createElement(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
253
254 // create all the services
255 NodeList nodes = service_rack_list.getElementsByTagName(GSXML.SERVICE_CLASS_ELEM);
256 if (nodes.getLength()==0) {
257 System.err.println("ServiceCluster configuration error: cluster "+this.cluster_name+" has no service modules!");
258 return false;
259 }
260
261 for(int i=0; i<nodes.getLength(); i++) {
262
263 // the xml request to send to the serviceRack to query what
264 // services it provides
265 Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
266 Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", "", "");
267 message.appendChild(request);
268
269 Element n = (Element)nodes.item(i);
270 String servicetype = n.getAttribute(GSXML.NAME_ATT);
271
272 try {
273 ServiceRack s = (ServiceRack)Class.forName("org.greenstone.gsdl3.service."+servicetype).newInstance();
274
275 s.setSiteHome(this.site_home);
276 s.setSiteAddress(this.site_http_address);
277 s.setClusterName(this.cluster_name);
278 s.setMessageRouter(this.router);
279 // pass the xml node to the service for configuration
280 if (s.configure(n, extra_info)) {
281
282 // find out the supported service types for this service module
283 Node types = s.process(message);
284 NodeList typenodes = ((Element)types).getElementsByTagName(GSXML.SERVICE_ELEM);
285
286 for (int j=0; j<typenodes.getLength();j++) {
287 String service = ((Element) typenodes.item(j)).getAttribute(GSXML.NAME_ATT);
288 if (service_map.get(service)!=null) {
289 char extra = '0';
290 String new_service = service+extra;
291
292 while (service_map.get(new_service)!=null) {
293 extra++;
294 new_service = service+extra;
295 }
296 this.service_name_map.put(new_service, service);
297 service=new_service;
298 ((Element) typenodes.item(j)).setAttribute(GSXML.NAME_ATT, service);
299 }
300 this.service_map.put(service, s);
301 // also add info to the ServiceInfo XML element
302 this.service_list.appendChild(this.doc.importNode(typenodes.item(j), true));
303 }
304 }
305 } catch (Exception e) {
306 System.err.println("ServiceCluster Error: configure exception: couldn't create service module:org.greenstone.gsdl3.service."+servicetype+"\n"+e.getMessage() + e.getClass() );
307 e.printStackTrace();
308 //return false;
309 }
310
311 }
312 return true;
313
314
315 }
316
317
318 /**
319 * Process an XML document - uses Strings
320 * just calls process(Node).
321 *
322 * @param in the Document to process - a string
323 * @return the resultant document as a string - contains any error messages
324 * @see String
325 */
326 public String process(String in) {
327
328 Document doc = this.converter.getDOM(in);
329 Element e = doc.getDocumentElement();
330
331 Element res = process(e);
332 return this.converter.getString(res);
333
334 }
335
336 /** process XML as Node
337 *
338 */
339 public Element process(Element message) {
340
341 NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM);
342 Document mess_doc = message.getOwnerDocument();
343 Element mainResult = this.doc.createElement(GSXML.MESSAGE_ELEM);
344 if (requests.getLength()==0) {
345 System.err.println("ServiceCluster.process: no requests for cluster:"+this.cluster_name);
346 // no requests
347 return mainResult; // for now
348 }
349 for (int i=0; i<requests.getLength(); i++) {
350 Element request = (Element)requests.item(i);
351 String to = request.getAttribute(GSXML.TO_ATT);
352
353 // the cluster name should be first, check, then remove
354 String clustername = GSPath.getFirstLink(to);
355 if (!clustername.equals(this.cluster_name)){
356 System.err.println("ServiceCluster Error: cluster name wrong! was "+clustername+" should have been "+this.cluster_name);
357 continue; // ignore this request
358 }
359 to = GSPath.removeFirstLink(to);
360 request.setAttribute(GSXML.TO_ATT, to);
361
362 if (to.equals("")) { // this command is for me
363 Element response = processMessage(request);
364 mainResult.appendChild(response);
365
366 } else { // the request is for one of my services
367 String service = GSPath.getFirstLink(to);
368
369 if (!this.service_map.containsKey(service)) {
370 System.err.println("ServiceCluster Error: non-existant service, "+service+", specified!");
371 continue;
372 }
373 String real_service = service;
374 if (this.service_name_map.containsKey(service)) {
375 real_service = (String)this.service_name_map.get(service);
376 // need to change the to att in the request - give the real service name
377 to = request.getAttribute(GSXML.TO_ATT);
378 String old_to = to;
379 to = GSPath.replaceFirstLink(to, real_service);
380 request.setAttribute(GSXML.TO_ATT, to);
381 }
382 // have to pass the request to the service
383 Element single_message = mess_doc.createElement(GSXML.MESSAGE_ELEM);
384 single_message.appendChild(request);
385 Element response_message = ((ModuleInterface)this.service_map.get(service)).process(single_message);
386 if (response_message != null) {
387 Element response = (Element) GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM);
388 String from = response.getAttribute(GSXML.FROM_ATT);
389 if (!real_service.equals(service)) {
390 // replace the real service name with the pseudo service name
391 from = GSPath.replaceFirstLink(from, service);
392 // also need to do it in the service itself
393 // shoudl this be done here??
394 Element service_elem = (Element) GSXML.getChildByTagName(response, GSXML.SERVICE_ELEM);
395 if (service_elem!= null) {
396 service_elem.setAttribute(GSXML.NAME_ATT, service);
397 }
398 }
399 from = GSPath.prependLink(from, this.cluster_name);
400 response.setAttribute(GSXML.FROM_ATT, from);
401 mainResult.appendChild(this.doc.importNode(response, true));
402 }
403
404 } // else
405
406
407 } // for each request
408 return mainResult;
409 }
410
411 /** handles requests made to the ServiceCluster itself
412 *
413 * @param req - the request Element- <request>
414 * @return the result Element - should be <response>
415 */
416 protected Element processMessage(Element request) {
417
418 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
419 response.setAttribute(GSXML.FROM_ATT, this.cluster_name);
420 String type = request.getAttribute(GSXML.TYPE_ATT);
421 String lang = request.getAttribute(GSXML.LANG_ATT);
422 response.setAttribute(GSXML.TYPE_ATT, type);
423
424 if (type.equals(GSXML.REQUEST_TYPE_DESCRIBE)) {
425 // create the collection element
426 Element description = (Element)this.description.cloneNode(false);
427 response.appendChild(description);
428 // check the param list
429 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
430 if (param_list == null) {
431 addAllDisplayInfo(description, lang);
432 description.appendChild(this.service_list);
433 description.appendChild(this.metadata_list);
434 return response;
435 }
436
437 // go through the param list and see what components are wanted
438 NodeList params = param_list.getElementsByTagName(GSXML.PARAM_ELEM);
439 for (int i=0; i<params.getLength(); i++) {
440
441 Element param = (Element)params.item(i);
442 // Identify the structure information desired
443 if (param.getAttribute(GSXML.NAME_ATT).equals(GSXML.SUBSET_PARAM)) {
444 String info = param.getAttribute(GSXML.VALUE_ATT);
445 if (info.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) {
446 description.appendChild(this.service_list);
447 } else if (info.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) {
448 description.appendChild(metadata_list);
449 } else if (info.equals(GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER)) {
450 addAllDisplayInfo(description, lang);
451
452 }
453 }
454 }
455 return response;
456 }
457
458 if (type.equals(GSXML.REQUEST_TYPE_SYSTEM)) {
459 response = processSystemRequest(request);
460 } else { // unknown type
461 System.err.println("ServiceCluster Error: cant handle request of type "+ type);
462
463 }
464 return response;
465 }
466
467 protected Element processSystemRequest(Element request) {
468
469 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
470 response.setAttribute(GSXML.FROM_ATT, this.cluster_name);
471 response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_SYSTEM);
472
473 // a list of system requests - should put any error messages
474 // or success messages into response
475 NodeList commands = request.getElementsByTagName(GSXML.SYSTEM_ELEM);
476 String message=null;
477 for (int i=0; i<commands.getLength(); i++) {
478 // all the commands should be Elements
479 Element elem = (Element)commands.item(i);
480 String action = elem.getAttribute(GSXML.TYPE_ATT);
481 if (action.equals(GSXML.SYSTEM_TYPE_CONFIGURE)) {
482 String subset = elem.getAttribute(GSXML.SYSTEM_SUBSET_ATT);
483 if (subset.equals("")) {
484 // need to reconfigure the service cluster
485
486 if (this.configure()) {
487 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " reconfigured");
488 response.appendChild(s);
489
490 } else {
491 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " could not be reconfigured");
492 response.appendChild(s);
493 }
494 } else if (this.configureSubset(subset)) {
495 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " "+subset+" reconfigured");
496 response.appendChild(s);
497 } else {
498 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " "+subset + " could not be reconfigured");
499 response.appendChild(s);
500 }
501 continue;
502 } // configure action
503
504 String module_name = elem.getAttribute(GSXML.SYSTEM_MODULE_NAME_ATT);
505 String module_type = elem.getAttribute(GSXML.SYSTEM_MODULE_TYPE_ATT);
506 if (action.equals(GSXML.SYSTEM_TYPE_ACTIVATE)) {
507 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, "activate action not yet implemented - does it even make sense in this context??");
508 response.appendChild(s);
509 } else if (action.equals(GSXML.SYSTEM_TYPE_DEACTIVATE)) {
510 if (module_type.equals(GSXML.SERVICE_ELEM)) {
511 // deactivate the service
512 // remove from service_map
513 this.service_map.remove(module_name);
514 Element service_elem = GSXML.getNamedElement(this.service_list, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, module_name);
515 service_list.removeChild(service_elem);
516 message = module_type+": "+module_name+" deactivated";
517 } else {
518 message = "can't deactivate "+module_type+" type modules!";}
519 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, message);
520 response.appendChild(s);
521 } else {
522 System.err.println("ServiceCluster: cant process system request, action "+action);
523 continue;
524 }
525 } // for each command
526 return response;
527 }
528
529 /**
530 * do a configure on only part of the collection
531 */
532 protected boolean configureSubset(String subset) {
533
534 File configFile = new File(GSFile.siteConfigFile(this.site_home));
535 if (!configFile.exists() ) {
536 System.err.println("ServiceCluster: site config file: "+configFile.getPath()+" not found!");
537 // wont be able to do any of the requests
538 return false;
539
540 }
541
542 Document site_config_doc = this.converter.getDOM(configFile);
543 if (site_config_doc == null) {
544 System.err.println("ServiceCluster: could not read in site config file: "+configFile.getPath());
545 return false;
546 }
547
548 Element site_config_elem = site_config_doc.getDocumentElement();
549 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);
550 if (cluster_config_elem == null) {
551 System.err.println("ServiceCluster: site config file: "+configFile.getPath()+" has no element for cluster "+this.cluster_name);
552 // wont be able to do any of teh requests
553 return false;
554
555 }
556 if (subset.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) {
557 Element service_rack_list = (Element)GSXML.getChildByTagName(cluster_config_elem, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER);
558
559 return configureServiceRack(service_rack_list, null);
560 } else if (subset.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) {
561 this.metadata_list = this.doc.createElement(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
562 Element metadata_list = (Element)GSXML.getChildByTagName(cluster_config_elem, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
563 return addMetadata(metadata_list);
564 } else {
565 System.err.println("ServiceCluster: cant process system request, configure "+subset);
566 return false;
567 }
568
569 }
570
571
572 protected boolean addAllDisplayInfo(Element description, String lang) {
573
574 NodeList items = this.display_item_list.getChildNodes();
575 for (int i=0; i<items.getLength(); i++) { // for each key
576 Element m = (Element) items.item(i);
577 // find the child with the correct language
578 Element new_m = GSXML.getNamedElement(m, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, lang);
579 if (new_m==null && lang != DEFAULT_LANG) {
580 // use the default lang
581 new_m = GSXML.getNamedElement(m, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, DEFAULT_LANG);
582 }
583 if (new_m==null) {
584 // just get the first one
585 new_m = (Element)GSXML.getChildByTagName(m, GSXML.DISPLAY_TEXT_ELEM);
586 }
587 description.appendChild(new_m.cloneNode(true));
588 }
589 return true;
590
591 }
592
593
594 protected Element getDisplayTextElement(String key, String lang) {
595
596 Element this_item = GSXML.getNamedElement(this.display_item_list, GSXML.DISPLAY_TEXT_ELEM, GSXML.NAME_ATT, key);
597 if (this_item == null) {
598 return null;
599 }
600
601 Element this_lang = GSXML.getNamedElement(this_item, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, lang);
602 if (this_lang == null && lang != DEFAULT_LANG) {
603 // try the default
604 this_lang = GSXML.getNamedElement(this_item, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, DEFAULT_LANG);
605 }
606 if (this_lang == null) {
607 // just return the first one
608 return (Element)this_item.getFirstChild().cloneNode(true);
609 }
610 return (Element)this_lang.cloneNode(true);
611
612 }
613}
614
615
616
617
618
619
Note: See TracBrowser for help on using the repository browser.