- Timestamp:
- 2003-04-08T14:41:46+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/collection/Collection.java
r4097 r4105 92 92 93 93 } 94 95 94 /** 96 * overwrite the serviceCluster one cos we use diff config files 97 */ 98 protected Element processSystemRequest(Element request) { 99 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM); 100 response.setAttribute(GSXML.FROM_ATT, this.cluster_name); 101 response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_SYSTEM); 102 103 // a list of system requests - should put any error messages 104 // or success messages into response 105 NodeList commands = request.getElementsByTagName(GSXML.SYSTEM_ELEM); 106 Element coll_config_elem = null; 107 Element build_config_elem = null; 108 for (int i=0; i<commands.getLength(); i++) { 109 // all the commands should be Elements 110 Element elem = (Element)commands.item(i); 111 String action = elem.getAttribute(GSXML.TYPE_ATT); 112 if (action.equals("configure")) { 113 String subset = elem.getAttribute("subset"); 114 if (subset.equals("")) { 115 // need to reconfigure the collection 116 if (this.configure()) { 117 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " collection reconfigured"); 118 response.appendChild(s); 119 continue; 120 } 121 122 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, this.cluster_name + " collection could not be reconfigured"); 123 response.appendChild(s); 124 return response; // wont be able to process any more if we cant do this one 125 126 } 127 // else its a specific request 128 129 // need the coll config files 130 if (coll_config_elem==null) { 131 coll_config_elem = loadCollConfigFile(); 132 build_config_elem = loadBuildConfigFile(); 133 if (coll_config_elem == null||build_config_elem == null) { 134 // wont be able to do any of teh requests 135 return response; 136 } 137 } 138 139 boolean success = false; 140 if (subset.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) { 141 Element service_rack_list = (Element)GSXML.getChildByTagName(build_config_elem, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER); 142 143 success = configureServiceRack(service_rack_list, coll_config_elem); 144 } else if (subset.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) { 145 success = findAndLoadMetadata(coll_config_elem, build_config_elem); 146 147 } else { 148 System.err.println("ServiceCluster: cant process system request, configure "+subset); 149 } 150 151 String message=null; 152 if (success) { 153 message = "ServiceCluster: "+ subset + " reconfigured successfully"; 154 } else { 155 message = "ServiceCluster: Error in reconfiguring "+subset; 156 } 157 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, message); 158 response.appendChild(s); 159 } else { 160 String module_name = elem.getAttribute(GSXML.SYSTEM_MODULE_NAME_ATT); 161 String module_type = elem.getAttribute(GSXML.SYSTEM_MODULE_TYPE_ATT); 162 if (action.equals("activate")) { 163 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" activated -- not yet implemented"); 164 response.appendChild(s); 165 } else if (action.equals("deactivate")) { 166 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" deactivated -- not yet implemented"); 167 response.appendChild(s); 168 } else { 169 System.err.println("Collection: cant process system request, action "+action); 170 continue; 171 } 172 173 } 174 } // for each command 175 return response; 176 } 177 95 * load in the collection config file into a DOM Element 96 */ 178 97 protected Element loadCollConfigFile() { 179 98 … … 191 110 } 192 111 193 112 /** 113 * load in the collection build config file into a DOM Element 114 */ 194 115 protected Element loadBuildConfigFile() { 195 116 … … 205 126 } 206 127 207 128 /** 129 * find the metadata from the two config files and add it to a new 130 * metadata list 131 */ 208 132 protected boolean findAndLoadMetadata(Element coll_config_xml, 209 133 Element build_config_xml){ … … 221 145 222 146 } 147 /** 148 * do a configure on only part of the collection 149 */ 150 protected boolean configureSubset(String subset) { 151 152 // need the coll config files 153 Element coll_config_elem = loadCollConfigFile(); 154 Element build_config_elem = loadBuildConfigFile(); 155 if (coll_config_elem == null||build_config_elem == null) { 156 // wont be able to do any of teh requests 157 return false; 158 } 159 160 if (subset.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) { 161 Element service_rack_list = (Element)GSXML.getChildByTagName(build_config_elem, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER); 162 163 return configureServiceRack(service_rack_list, coll_config_elem); 164 } 165 166 if (subset.equals(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER)) { 167 return findAndLoadMetadata(coll_config_elem, build_config_elem); 168 169 } 170 171 System.err.println("ServiceCluster: cant process system request, configure "+subset); 172 return false; 173 } 223 174 224 175 }
Note:
See TracChangeset
for help on using the changeset viewer.