Changeset 30839
- Timestamp:
- 2016-09-22T12:08:09+12:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java
r30670 r30839 30 30 import org.greenstone.gsdl3.service.ServiceRack; 31 31 import org.greenstone.gsdl3.util.Dictionary; 32 import org.greenstone.gsdl3.util.DisplayItemUtil; 32 33 import org.greenstone.gsdl3.util.GSFile; 33 34 import org.greenstone.gsdl3.util.GSPath; … … 89 90 /** list of services */ 90 91 protected Element service_list = null; 91 /** list of metadata - all metadata, regardless of language goes in here */92 /** list of metadata - all metadata, regardless of language goes in here . metadata should be language neutral. Language specific strings are displayItems*/ 92 93 protected Element metadata_list = null; 93 94 /** language specific display items */ … … 105 106 106 107 protected Element _globalFormat = null; 108 109 /** 110 * A class loader that knows where to find resources 111 * put properties files, dtds etc in here 112 */ 113 protected ClassLoader class_loader = null; 107 114 108 115 public void setSiteHome(String home) … … 225 232 //clearServices(); 226 233 Element service_rack_list = (Element) GSXML.getChildByTagName(service_cluster_info, GSXML.SERVICE_CLASS_ELEM + GSXML.LIST_MODIFIER); 227 logger.error("cluster service rack list =");228 logger.error(GSXML.xmlNodeToString(service_rack_list));229 234 if (service_rack_list == null) 230 235 { … … 263 268 { 264 269 resolveMacros(display_list); 265 if (!addDisplayItems(display_list))270 if (!DisplayItemUtil.storeDisplayItems(this.display_item_list, display_list)) 266 271 { 267 272 … … 316 321 </displayItem> 317 322 */ 318 protected boolean addDisplayItems (Element display_list)323 protected boolean addDisplayItemsOld(Element display_list) 319 324 { 320 325 … … 650 655 if (param_list == null) 651 656 { 652 addAllDisplayInfo(description, lang); 657 Element di_list = result_doc.createElement(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER); 658 description.appendChild(di_list); 659 DisplayItemUtil.addLanguageSpecificDisplayItems(di_list, this.display_item_list, lang, DEFAULT_LANG, this.class_loader); 653 660 description.appendChild(result_doc.importNode(this.service_list, true)); 654 661 description.appendChild(result_doc.importNode(this.metadata_list, true)); … … 679 686 else if (info.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER)) 680 687 { 681 addAllDisplayInfo(description, lang); 688 Element di_list = result_doc.createElement(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER); 689 description.appendChild(di_list); 690 DisplayItemUtil.addLanguageSpecificDisplayItems(di_list, this.display_item_list, lang, DEFAULT_LANG, this.class_loader); 691 682 692 } 683 693 else if (info.equals(GSXML.LIBRARY_PARAM_ELEM+GSXML.LIST_MODIFIER)) … … 932 942 933 943 } 934 // from our store of displayItems, (eg name, description etc) add one of each to response. PIck the best fit for request lang.935 936 protected boolean addAllDisplayInfo(Element description, String lang)937 {938 Document doc = description.getOwnerDocument();939 NodeList items = this.display_item_list.getChildNodes();940 for (int i = 0; i < items.getLength(); i++)941 { // for each key942 Element m = (Element) items.item(i);943 // is there one with the specified language?944 Element new_m = GSXML.getNamedElement(m, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, lang);945 if (new_m == null) {946 // if not, have we got one with a key?947 new_m = GSXML.getNamedElement(m, GSXML.DISPLAY_TEXT_ELEM, GSXML.KEY_ATT, null);948 if (new_m != null) {949 // look up the dictionary950 String value = getTextString(new_m.getAttribute(GSXML.KEY_ATT), lang, new_m.getAttribute(GSXML.DICTIONARY_ATT));951 if (value != null) {952 GSXML.setNodeText(new_m, value);953 }954 else {955 // haven't found the key in the dictionary, ignore this display item956 new_m = null;957 }958 }959 }960 if (new_m == null && lang != DEFAULT_LANG) {961 // still haven't got a value. can we use the defualt lang?962 new_m = GSXML.getNamedElement(m, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, DEFAULT_LANG);963 }964 if (new_m == null)965 {966 // STILL haven't found one, lets use the first one with a lang att (so we don't just get the key one back967 new_m = (Element) GSXML.getNamedElement(m, GSXML.DISPLAY_TEXT_ELEM, GSXML.LANG_ATT, null);968 }969 if (new_m != null) {970 description.appendChild(doc.importNode(new_m, true));971 }972 } // for each key973 return true;974 975 }976 977 978 protected String getTextString(String key, String lang, String dictionary) {979 return getTextString(key, lang, dictionary, null);980 }981 982 protected String getTextString(String key, String lang, String dictionary, String[] args)983 {984 Dictionary dict = new Dictionary(dictionary, lang);985 String result = dict.get(key, args);986 return result;987 }988 989 944 990 945 public HashMap<String, ServiceRack> getServiceMap()
Note:
See TracChangeset
for help on using the changeset viewer.