Changeset 9433
- Timestamp:
- 2005-03-15T16:18:37+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java
r6900 r9433 65 65 */ 66 66 protected HashMap service_map=null; 67 67 /** maps pseudo service names to real service names - needed if we have two services with the same name for one collection */ 68 protected HashMap service_name_map=null; 69 68 70 /** XML converter for String to DOM and vice versa */ 69 71 protected XMLConverter converter=null; … … 100 102 public ServiceCluster() { 101 103 this.service_map = new HashMap(); 104 this.service_name_map = new HashMap(); 102 105 this.converter = new XMLConverter(); 103 106 this.doc = this.converter.newDOM(); … … 270 273 271 274 for (int j=0; j<typenodes.getLength();j++) { 272 String service = ((Element) typenodes.item(j)).getAttribute(GSXML.NAME_ATT); 275 String service = ((Element) typenodes.item(j)).getAttribute(GSXML.NAME_ATT); 276 if (service_map.get(service)!=null) { 277 char extra = '0'; 278 String new_service = service+extra; 279 280 while (service_map.get(new_service)!=null) { 281 extra++; 282 new_service = service+extra; 283 } 284 this.service_name_map.put(new_service, service); 285 service=new_service; 286 ((Element) typenodes.item(j)).setAttribute(GSXML.NAME_ATT, service); 287 } 273 288 this.service_map.put(service, s); 274 275 289 // also add info to the ServiceInfo XML element 276 290 this.service_list.appendChild(this.doc.importNode(typenodes.item(j), true)); … … 345 359 continue; 346 360 } 361 String real_service = service; 362 if (this.service_name_map.containsKey(service)) { 363 real_service = (String)this.service_name_map.get(service); 364 // need to change the to att in the request - give the real service name 365 to = request.getAttribute(GSXML.TO_ATT); 366 String old_to = to; 367 to = GSPath.replaceFirstLink(to, real_service); 368 request.setAttribute(GSXML.TO_ATT, to); 369 } 347 370 // have to pass the request to the service 348 371 Element single_message = mess_doc.createElement(GSXML.MESSAGE_ELEM); … … 352 375 Element response = (Element) GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM); 353 376 String from = response.getAttribute(GSXML.FROM_ATT); 377 if (!real_service.equals(service)) { 378 // replace the real service name with the pseudo service name 379 from = GSPath.replaceFirstLink(from, service); 380 // also need to do it in the service itself 381 // shoudl this be done here?? 382 Element service_elem = (Element) GSXML.getChildByTagName(response, GSXML.SERVICE_ELEM); 383 if (service_elem!= null) { 384 service_elem.setAttribute(GSXML.NAME_ATT, service); 385 } 386 } 354 387 from = GSPath.prependLink(from, this.cluster_name); 355 388 response.setAttribute(GSXML.FROM_ATT, from);
Note:
See TracChangeset
for help on using the changeset viewer.