- Timestamp:
- 2003-07-11T16:29:16+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/ServiceRack.java
r4142 r4903 79 79 protected Document doc_ = null; 80 80 81 /** XML element for describe requests - list of supported services */ 81 /** XML element for describe requests - list of supported services 82 - this is static */ 82 83 protected Element short_service_info_ = null; 83 84 84 /** XML element for describe requests - map of service name to full85 description */86 protected HashMap service_info_map_ = null;87 85 /** XML element for stylesheet requests - map of service name to format 88 86 elem */ … … 117 115 doc_ = converter_.newDOM(); 118 116 short_service_info_ = doc_.createElement(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER); 119 service_info_map_ = new HashMap();120 117 format_info_map_ = new HashMap(); 121 118 } … … 191 188 String to = GSPath.getFirstLink(request.getAttribute(GSXML.TO_ATT)); 192 189 Element response = null; 193 if (service_info_map_.containsKey(to)) { 194 try { 190 try { 195 191 Class c = this.getClass(); 196 192 Class []params = {Class.forName("org.w3c.dom.Element")}; 197 193 198 194 String method_name = "process"+to; 199 195 Method m = null; … … 226 222 mainResult.appendChild(doc_.importNode(response, true)); 227 223 } 228 229 } catch (ClassNotFoundException e) { 230 System.err.println("ServiceRack error: Element class not found"); 231 return null; 232 } 233 } else { 234 // else error in to field 235 System.err.println("ServiceRack describe request: error in 'to' field, non-existant service "+to+" specified!"); 224 225 } catch (ClassNotFoundException e) { 226 System.err.println("ServiceRack error: Element class not found"); 236 227 return null; 237 228 } … … 242 233 243 234 } 235 236 244 237 245 238 /** process method for describe requests … … 258 251 259 252 // describe a particular service 260 if (service_info_map_.containsKey(to)) { 261 response.appendChild(getServiceDescription(to, lang)); 253 //if (service_info_map_.containsKey(to)) { 254 Element description = getServiceDescription(to, lang); 255 if (description != null) { // may be null if non-existant service 256 response.appendChild(description); 262 257 response.setAttribute(GSXML.FROM_ATT, to); 263 return response;264 258 } 265 // else error in to field 266 System.err.println("ServiceRack describe request: error in 'to' field, to='"+to+"'."); 267 return null; 259 return response; 268 260 269 261 } … … 288 280 return response; 289 281 } 290 // else error in to field282 // else no format info 291 283 System.err.println("ServiceRack describe request: no format info for "+to+"."); 292 284 return response; 293 285 } 294 286 295 // the following two should be overwritten for info with any language stuff in it296 287 /** returns the service list for the subclass */ 297 288 protected Element getServiceList(String lang) { 298 // for now, it is static and there is no langstuff299 return short_service_info_;289 // for now, it is static and has no language stuff 290 return (Element) short_service_info_.cloneNode(true); 300 291 } 301 292 302 293 /** returns a specific service description */ 303 protected Element getServiceDescription(String service, String lang) { 304 Element descript = (Element)((Element)service_info_map_.get(service)).cloneNode(true); 305 // for now, create the display element on the fly - look at caching it later 306 Element display = createServiceDisplay(service, lang); 307 addServiceDisplay(descript, display); 308 return descript; 309 } 310 311 312 /** adds the display element into the description - appends to the root for now, but may do something fancy later */ 313 protected boolean addServiceDisplay(Element descript, Element display) { 314 if (descript.getOwnerDocument() != display.getOwnerDocument()) { 315 display = (Element)descript.getOwnerDocument().importNode(display, true); 316 } 317 descript.appendChild(display); 318 return true; 319 } 294 abstract protected Element getServiceDescription(String service, String lang); 320 295 321 296 protected Element getServiceFormat(String service) { … … 323 298 return format; 324 299 } 325 /** creates a display element containing all the text strings needed to display the service page, in the language specified */326 abstract protected Element createServiceDisplay(String service, String lang);327 300 328 301 /** overloaded version for no args case */ … … 345 318 return result; 346 319 } 320 321 347 322 } 323
Note:
See TracChangeset
for help on using the changeset viewer.