source: trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java@ 13947

Last change on this file since 13947 was 13947, checked in by kjdon, 17 years ago

allow specification of full package name for serviceRacks in buildConfig.xml - custom ones may not be in org.greenstone.gsdl3.service package

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