- Timestamp:
- 2017-01-13T03:46:43+13:00 (7 years ago)
- Location:
- main/trunk/greenstone3
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/CollectionGroups.java
r31265 r31285 65 65 Document doc = XMLConverter.newDOM(); 66 66 UserContext userContext = new UserContext(request); 67 67 68 NodeList collList; 69 NodeList groupList; 70 int collIndex = 0; 71 int grpIndex = 0; 72 boolean hierarchy = true; 73 68 74 // Prepare basic response 69 75 Element result = GSXML.createBasicResponse(doc, GSXML.SERVICE_TYPE_GROUPINFO); 70 76 Element result_collection_list = doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER); 77 result.appendChild(result_collection_list); 78 Element result_group_list = doc.createElement(GSXML.GROUP_ELEM + GSXML.LIST_MODIFIER); 79 result.appendChild(result_group_list); 71 80 72 81 // Get param list from request … … 81 90 groupPath = paramGroup.getAttribute(GSXML.VALUE_ATT); 82 91 } 92 Element paramHierarchy = GSXML.getNamedElement(paramList, GSXML.PARAM_ELEM, GSXML.NAME_ATT, GSXML.HIERARCHY_ELEM); 93 if (paramHierarchy != null){ 94 hierarchy = true; 95 } 83 96 } 84 97 //Remove leading, ending / and dupliclated / … … 88 101 Element mrCollectionList = getMRCollectionList(userContext); 89 102 if (mrCollectionList == null){ 90 result.appendChild(doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER));91 103 return result; 92 104 } 93 105 //Get current groups and collections 94 Element groupContent = getCurrentContent(groupPath); 106 Element currentContent = getCurrentContent(groupPath); 107 if (currentContent != null){ 108 currentContent = (Element) doc.importNode(currentContent, true); 109 } 95 110 96 111 //Get ungrouped collection list 97 Element ungroupedCollections = getUngroupedCollections(mrCollectionList); 98 99 // If groupContent is empty return empty collection list 100 if (groupContent == null) { 101 // If config file is broken 102 if (hierarchy == null || groupDesc == null) { 103 //Get ungrouped collection list 104 result.appendChild(doc.importNode(ungroupedCollections, true)); 112 Element ungroupedCollectionsList = getUngroupedCollections(mrCollectionList); 113 114 if (currentContent != null){ 115 if (hierarchy){ 116 collList = currentContent.getElementsByTagName(GSXML.COLLECTION_ELEM); 117 groupList = currentContent.getElementsByTagName(GSXML.GROUP_ELEM); 105 118 } else { 106 //If config is ok, but in this group no any collection or group 107 result.appendChild(doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER)); 108 } 109 return result; 110 } 111 NodeList currentContent = groupContent.getChildNodes(); 112 if (currentContent != null && currentContent.getLength() > 0) { 113 // Create CollectionList element in response 114 Element result_collection_list = doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER); 115 result.appendChild(result_collection_list); 116 Element result_group_list = doc.createElement(GSXML.GROUP_ELEM + GSXML.LIST_MODIFIER); 117 result.appendChild(result_group_list); 118 // Iterate over collections from current view 119 // i represents current position in groupConfig.xml 120 int i; 121 for (i=0; i < currentContent.getLength(); i++) { 122 //logger.warn("NODE CuR Content" + GSXML.xmlNodeToString(currentContent.item(i))); 123 124 if (currentContent.item(i).getNodeName() == GSXML.COLLECTION_ELEM) { 125 126 Element collection = (Element) currentContent.item(i); 127 String collection_name = collection.getAttribute(GSXML.NAME_ATT); 128 // Check whether collection from current view exists in message router response 129 Element checkedCollection = GSXML.getNamedElement(mrCollectionList, GSXML.COLLECTION_ELEM,GSXML.NAME_ATT, collection_name); 130 if (checkedCollection != null) { 131 //Set position value 132 checkedCollection.setAttribute(GSXML.POSITION_ATT, String.valueOf(i)); 133 // Add collection to response 134 result_collection_list.appendChild(doc.importNode(checkedCollection, true)); 119 collList = GSXML.getChildrenByTagName(currentContent, GSXML.COLLECTION_ELEM); 120 groupList = GSXML.getChildrenByTagName(currentContent, GSXML.GROUP_ELEM); 121 } 122 //Check collection list for existence 123 int collListLenght = collList.getLength(); 124 for (collIndex = 0; collIndex < collListLenght; collIndex++) { 125 Element currentCollection = (Element) collList.item(collIndex); 126 String collection_name = currentCollection.getAttribute(GSXML.NAME_ATT); 127 Element checkedCollection = GSXML.getNamedElement(mrCollectionList, GSXML.COLLECTION_ELEM,GSXML.NAME_ATT, collection_name); 128 if (checkedCollection != null) { 129 //Set position value 130 if (!hierarchy){ 131 int position = GSXML.getNodeIndex(currentCollection); 132 checkedCollection.setAttribute(GSXML.POSITION_ATT, Integer.toString(position)); 135 133 } 136 137 //Iterate over groups in current view 138 } else if (currentContent.item(i).getNodeName() == GSXML.GROUP_ELEM) { 139 Element currentGroup = (Element) currentContent.item(i); 140 String currentGroupName = currentGroup.getAttribute(GSXML.NAME_ATT); 141 //Get group description 142 Element group = getGroupDescription(currentGroupName); 134 // Add collection to response 135 result_collection_list.appendChild(doc.importNode(checkedCollection, true)); 136 } else { 137 //remove collection from currentContent 138 currentCollection.getParentNode().removeChild(currentCollection); 139 collIndex--; 140 collListLenght--; 141 } 142 } 143 //check group 144 int groupListLenght = groupList.getLength(); 145 for (grpIndex = 0; grpIndex < groupListLenght; grpIndex++) { 146 Element currentGroup = (Element) groupList.item(grpIndex); 147 String currentGroupName = currentGroup.getAttribute(GSXML.NAME_ATT); 148 Element groupDescription = getGroupDescription(currentGroupName); 149 if (groupDescription != null) { 143 150 //Set position value 144 if ( group != null){145 group.setAttribute(GSXML.POSITION_ATT, String.valueOf(i));146 result_group_list.appendChild(doc.importNode(group, true));151 if (!hierarchy){ 152 int position = GSXML.getNodeIndex(currentGroup); 153 groupDescription.setAttribute(GSXML.POSITION_ATT, Integer.toString(position)); 147 154 } 148 149 } 150 151 } 155 result_group_list.appendChild(doc.importNode(groupDescription, true)); 156 } else { 157 //remove group from currentContent 158 currentGroup.getParentNode().removeChild(currentGroup); 159 grpIndex--; 160 groupListLenght--; 161 } 162 } 163 logger.error("Group list lenght " + groupListLenght+ " result_group_list is " + GSXML.elementToString(result_group_list, true)); 164 165 } 152 166 //Add ungrouped collections if groupPath /+ or "" or null 153 167 if (groupPath.isEmpty()) { 154 168 155 156 169 //Add each ungrouped collection to the collection list in loop 157 NodeList ungroupedCollectionNodes = GSXML.getChildrenByTagName(ungroupedCollections , GSXML.COLLECTION_ATT);170 NodeList ungroupedCollectionNodes = GSXML.getChildrenByTagName(ungroupedCollectionsList, GSXML.COLLECTION_ATT); 158 171 if (ungroupedCollectionNodes != null) { 159 for (int j = 0; j < ungroupedCollectionNodes.getLength(); j++) { 160 //logger.warn("UNGROUPED COLL ELEM" + GSXML.xmlNodeToString(ungroupedCollections).intern()); 161 Element ungroupedCollection = (Element) doc.importNode(ungroupedCollectionNodes.item(j), true); 162 ungroupedCollection.setAttribute(GSXML.POSITION_ATT, String.valueOf(i++)); 172 for (int k = 0; k < ungroupedCollectionNodes.getLength(); k++) { 173 Element ungroupedCollection = (Element) doc.importNode(ungroupedCollectionNodes.item(k), true); 174 if (!hierarchy){ 175 ungroupedCollection.setAttribute(GSXML.POSITION_ATT, String.valueOf(grpIndex + collIndex++)); 176 } 163 177 result_collection_list.appendChild(ungroupedCollection); 178 if (hierarchy){ 179 180 currentContent.appendChild(doc.importNode(ungroupedCollectionNodes.item(k), true)); 181 } 164 182 } 165 183 } 166 184 167 185 } else { 168 Element groupDescription = getPathInfo(groupPath); 169 if (groupContent != null){ 170 result.appendChild(doc.importNode(groupDescription, true)); 171 } 172 } 173 } 174 186 Element pathInfo = getPathInfo(groupPath); 187 if (currentContent != null){ 188 result.appendChild(doc.importNode(pathInfo, true)); 189 } 190 } 191 if (hierarchy){ 192 result.appendChild(currentContent); 193 } 194 logger.error("currentContent is " + GSXML.elementToString(currentContent, true)); 175 195 return result; 176 196 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java
r30476 r31285 11 11 import org.greenstone.gsdl3.util.GSXSLT; 12 12 import org.greenstone.gsdl3.util.UserContext; 13 import org.greenstone.gsdl3.util.XMLConverter; 13 14 import org.w3c.dom.Document; 14 15 import org.w3c.dom.Element; … … 100 101 if (request_type.indexOf("d") != -1) { 101 102 page_response.appendChild(service_description); 103 addCollectionsHierarchy(page_response,userContext); 102 104 } 103 105 //} … … 284 286 addInterfaceOptions(page_response); 285 287 return page_response; 288 } 289 290 private void addCollectionsHierarchy(Element page_response, UserContext userContext) { 291 Document doc = page_response.getOwnerDocument(); 292 String collectionsHierarchy = "CollectionsHierarchy"; 293 if (checkServiceAvailable(userContext, collectionsHierarchy)){ 294 Element groupQueryMessage = doc.createElement(GSXML.MESSAGE_ELEM); 295 Element groupQueryRequest = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, collectionsHierarchy, userContext); 296 groupQueryMessage.appendChild(groupQueryRequest); 297 Element groupQueryResult = (Element) this.mr.process(groupQueryMessage); 298 if (groupQueryResult == null){ 299 return; 300 } 301 Element groupQueryResponse = (Element) GSXML.getChildByTagName(groupQueryResult, GSXML.RESPONSE_ELEM); 302 if (groupQueryResponse == null){ 303 return; 304 } 305 Element hierarchy = (Element) GSXML.getChildByTagName(groupQueryResponse, GSXML.HIERARCHY_ELEM); 306 page_response.appendChild(doc.importNode(hierarchy, true)); 307 } 308 309 310 } 311 312 private boolean checkServiceAvailable(UserContext userContext, String collectionsHierarchy) { 313 314 Document doc = XMLConverter.newDOM(); 315 Element infoMessage = doc.createElement(GSXML.MESSAGE_ELEM); 316 Element infoRequest = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext); 317 Element paramList = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 318 infoRequest.appendChild(paramList); 319 GSXML.addParameterToList(paramList, GSXML.SUBSET_PARAM, GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 320 infoMessage.appendChild(infoRequest); 321 Element responseMessage = (Element) this.mr.process(infoMessage); 322 if (responseMessage == null) 323 { 324 logger.error("couldn't query the message router!"); 325 return false; 326 } 327 NodeList serviceLists = responseMessage.getElementsByTagName(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 328 if (serviceLists == null || serviceLists.getLength() == 0){ 329 logger.error("No service List in response message from message router!"); 330 return false; 331 } 332 Element serviceList = (Element) serviceLists.item(0); 333 Element groupInfoService = GSXML.getNamedElement(serviceList, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, collectionsHierarchy); 334 if (groupInfoService == null){ 335 logger.error("service " + collectionsHierarchy + " unavailable"); 336 return false; 337 } 338 return true; 286 339 } 287 340 … … 375 428 return true; 376 429 } 430 377 431 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CollectionGroups.java
r31181 r31285 30 30 private static final String GROUP_CONTENT = "GroupCurrentContent"; 31 31 private static final String UNIQUE_COLLECTIONS = "UniqueCollections"; 32 private static final String COLLECTIONS_HIERARCHY = "CollectionsHierarchy"; 32 33 33 34 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.BerryBasket.class.getName()); … … 39 40 } 40 41 41 String[] _services = { GROUP_CONTENT, UNIQUE_COLLECTIONS };42 String[] _services = { GROUP_CONTENT, UNIQUE_COLLECTIONS, COLLECTIONS_HIERARCHY }; 42 43 43 44 public boolean configure(Element info, Element extra_info) { … … 56 57 } 57 58 // Load group configuration from file 58 readGroupConfiguration(); 59 60 return true; 59 return readGroupConfiguration(); 61 60 } 62 61 … … 86 85 groupPath = groupPath.replaceAll("(^/+)|(/+$)", ""); 87 86 88 Element mrCollectionList = get MRCollectionList(userContext);87 Element mrCollectionList = getAvailableCollectionList(userContext); 89 88 if (mrCollectionList == null){ 90 89 result.appendChild(doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER)); … … 92 91 } 93 92 //Get current groups and collections 94 Element groupContent = get CurrentContent(groupPath);93 Element groupContent = getRawCurrentContent(groupPath); 95 94 96 95 //Get ungrouped collection list … … 99 98 // If groupContent is empty return empty collection list 100 99 if (groupContent == null) { 101 // If config file is broken 102 if (hierarchy == null || groupDesc == null) { 103 //Get ungrouped collection list 104 result.appendChild(doc.importNode(ungroupedCollections, true)); 105 } else { 106 //If config is ok, but in this group no any collection or group 107 result.appendChild(doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER)); 108 } 100 result.appendChild(doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER)); 109 101 return result; 110 102 } … … 139 131 Element currentGroup = (Element) currentContent.item(i); 140 132 String currentGroupName = currentGroup.getAttribute(GSXML.NAME_ATT); 141 //Get group description 142 Element group = getGroupDescription(currentGroupName); 143 //Set position value 144 if (group != null) { 145 group.setAttribute(GSXML.POSITION_ATT, String.valueOf(i)); 146 result_group_list.appendChild(doc.importNode(group, true)); 147 } 148 133 Element groupDescription = getGroupDescription(currentGroupName); 134 135 groupDescription.setAttribute(GSXML.POSITION_ATT, String.valueOf(i)); 136 result_group_list.appendChild(doc.importNode(groupDescription, true)); 149 137 } 150 138 … … 152 140 //Add ungrouped collections if groupPath /+ or "" or null 153 141 if (groupPath.isEmpty()) { 154 155 142 156 143 //Add each ungrouped collection to the collection list in loop … … 183 170 Element resultCollections = doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER); 184 171 result.appendChild(resultCollections); 185 Element mrCollectionList = get MRCollectionList(userContext);172 Element mrCollectionList = getAvailableCollectionList(userContext); 186 173 //Collections from message router check 187 174 if (mrCollectionList == null){ … … 218 205 groups = GSXML.getValue(groupParam).split(","); 219 206 for (int i = 0; i < groups.length; i++) { 220 Element groupContent = get CurrentContent(groups[i]);207 Element groupContent = getRawCurrentContent(groups[i]); 221 208 //If group exists 222 209 if (groupContent != null) { … … 241 228 } 242 229 243 private Element getCurrentContent(String path) { 244 245 if (hierarchy == null || groupDesc == null) { 246 return null; 247 } 248 249 Document doc = XMLConverter.newDOM(); 250 230 protected Element processCollectionsHierarchy(Element request){ 231 232 Document doc = XMLConverter.newDOM(); 233 UserContext userContext = new UserContext(request); 234 // Prepare basic response 235 Element result = GSXML.createBasicResponse(doc, GSXML.SERVICE_TYPE_GROUPINFO); 236 String currentPath = ""; 237 Element currentContent = getRawCurrentContent(currentPath); 238 if (currentContent == null){ 239 return result; 240 } 241 Element searchableCollectionList = getSearchableCollectionList(userContext); 242 if (searchableCollectionList == null){ 243 return result; 244 } 245 246 //Get ungrouped collection list 247 sanitizeCurrentContent(currentContent, searchableCollectionList); 248 addGroupInfo(currentContent, currentPath); 249 addUngroupedCollections(currentContent, searchableCollectionList); 250 result.appendChild(doc.importNode(currentContent, true)); 251 return result; 252 } 253 254 private void addGroupInfo(Element currentContent, String groupPath) { 255 NodeList groups = GSXML.getChildrenByTagName(currentContent,GSXML.GROUP_ELEM); 256 for (int i=0;i<groups.getLength();i++){ 257 Element group = (Element) groups.item(i); 258 String name = group.getAttribute(GSXML.NAME_ATT); 259 String newPath = groupPath + "/" + name; 260 group.setAttribute(GSXML.PATH_ATT, newPath); 261 Element groupDescription = getGroupDescription(name); 262 Element titleEl = (Element) GSXML.getChildByTagName(groupDescription, GSXML.TITLE_ELEM); 263 String title = titleEl.getTextContent(); 264 group.setAttribute(GSXML.TITLE_ELEM, title ); 265 addGroupInfo(group, newPath); 266 } 267 268 } 269 270 private Element getRawCurrentContent(String path) { 271 251 272 if (path == null) { 252 273 path = ""; 253 274 } 254 275 276 Document doc = XMLConverter.newDOM(); 255 277 path = path.replaceAll("(/+)", "/"); 256 278 path = path.replaceAll("(^/+)|(/+$)", ""); … … 259 281 260 282 261 Element current View= (Element) hierarchy.cloneNode(true);283 Element currentContent = (Element) hierarchy.cloneNode(true); 262 284 // Get the current view 263 285 for (int i = 0; i < pathSteps.length; i++) { 264 286 if (!pathSteps[i].isEmpty()) { 265 current View = GSXML.getNamedElement(currentView, GSXML.GROUP_ELEM, GSXML.NAME_ATT, pathSteps[i]);266 if (current View== null){287 currentContent = GSXML.getNamedElement(currentContent, GSXML.GROUP_ELEM, GSXML.NAME_ATT, pathSteps[i]); 288 if (currentContent == null){ 267 289 break; 268 290 } 269 291 } 270 292 } 271 if (current View == null || !currentView.hasChildNodes()) {293 if (currentContent == null || !currentContent.hasChildNodes()) { 272 294 // Return to the main page 273 295 return null; 274 296 } 275 return currentView; 276 } 277 278 private void readGroupConfiguration() { 297 return currentContent; 298 } 299 300 private void sanitizeCurrentContent(Element currentContent, Element checkedCollectionList){ 301 if (currentContent == null){ 302 return; 303 } 304 NodeList nodes = currentContent.getElementsByTagName(GSXML.COLLECTION_ELEM); 305 for (int i = 0; i < nodes.getLength(); i++) { 306 Element element = (Element) nodes.item(i); 307 String name = element.getAttribute(GSXML.NAME_ATT); 308 Element checkedCollection = GSXML.getNamedElement(checkedCollectionList, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 309 if (checkedCollection == null) { 310 element.getParentNode().removeChild(element); 311 i--; 312 } 313 } 314 } 315 316 private void addUngroupedCollections(Element currentContent, Element availableCollections){ 317 if (currentContent == null){ 318 return; 319 } 320 Document doc = currentContent.getOwnerDocument(); 321 NodeList collectionList = availableCollections.getElementsByTagName(GSXML.COLLECTION_ELEM); 322 for (int i = 0; i < collectionList.getLength();i++){ 323 Element collection = (Element) collectionList.item(i); 324 String name = collection.getAttribute(GSXML.NAME_ATT); 325 NodeList foundCollection = GSXML.getNamedElements(currentContent, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 326 if (foundCollection.getLength() == 0){ 327 Element ungroupedCollection = doc.createElement(GSXML.COLLECTION_ELEM); 328 ungroupedCollection.setAttribute(GSXML.NAME_ATT, name); 329 currentContent.appendChild(ungroupedCollection); 330 } 331 } 332 333 } 334 335 private boolean readGroupConfiguration() { 279 336 280 337 File configFile = new File(GSFile.groupConfigFile(site_home)); … … 282 339 if (!configFile.exists()) { 283 340 logger.info("Groups config file " + configFile.getPath() + " does not exist."); 284 return ;341 return false; 285 342 } 286 343 // Try to read and catch exception if it fails … … 301 358 logger.error("Error occurred while trying to remove emtpy nodes from groupConfig.xml"); 302 359 e.printStackTrace(); 360 return false; 303 361 } 304 362 305 363 hierarchy = (Element) GSXML.getChildByTagName(content, GSXML.HIERARCHY_ELEM); 306 364 groupDesc = (Element) GSXML.getChildByTagName(content, GSXML.GROUP_DESC_ELEM); 365 if (hierarchy == null || groupDesc == null){ 366 logger.error("Error processing groups configuration. Check groupConfig.xml"); 367 return false; 368 } 369 verifyGroupDescription(); 370 return true; 371 } 372 373 private void verifyGroupDescription() { 374 Document doc = groupDesc.getOwnerDocument(); 375 NodeList groups = hierarchy.getElementsByTagName(GSXML.GROUP_ELEM); 376 for (int i = 0; i < groups.getLength(); i++) { 377 Element group = (Element) groups.item(i); 378 String name = group.getAttribute(GSXML.NAME_ATT); 379 Element foundDescription = GSXML.getNamedElement(groupDesc, GSXML.GROUP_ELEM, GSXML.NAME_ATT, name); 380 if (foundDescription == null){ 381 Element defaultDescription = doc.createElement(GSXML.GROUP_ELEM); 382 defaultDescription.setAttribute(GSXML.NAME_ATT, name); 383 Element groupTitle = doc.createElement(GSXML.TITLE_ELEM); 384 groupTitle.setTextContent(name); 385 defaultDescription.appendChild(groupTitle); 386 groupDesc.appendChild(defaultDescription); 387 } 388 } 389 307 390 } 308 391 309 392 private Element getGroupDescription(String name) { 310 if (groupDesc != null) { 311 Element description = (Element) GSXML.getNamedElement(groupDesc, GSXML.GROUP_ELEM, GSXML.NAME_ATT, name); 312 if (description != null) { 313 return description; 314 } 393 Element description = (Element) GSXML.getNamedElement(groupDesc, GSXML.GROUP_ELEM, GSXML.NAME_ATT, name); 394 if (description == null) { 315 395 logger.error("GroupDescription is not defined. Check your groupConfig.xml"); 316 } 317 318 logger.error("No group descriptions found. Check your groupConfig.xml"); 319 return null; 396 } 397 return description; 320 398 } 321 399 322 400 private Element getUngroupedCollections(Element mr_collection_list) { 323 401 324 if (groupDesc == null || hierarchy == null) {325 logger.error("No group descriptions in groupConfig.xml. Check your groupConfig.xml");326 //return mr_collection_list327 return mr_collection_list;328 }329 402 Document doc = XMLConverter.newDOM(); 330 403 // Create Set … … 366 439 private Element getPathInfo(String path) { 367 440 368 if (hierarchy == null || groupDesc == null) {369 return null;370 }371 372 441 Document doc = XMLConverter.newDOM(); 373 442 … … 387 456 pathStepDescription.setAttribute(GSXML.POSITION_ATT, String.valueOf(i)); 388 457 pathStepDescription.setAttribute(GSXML.PATH_ATT, currentPath); 389 pathInfo.appendChild(doc.importNode(pathStepDescription, true));390 }458 } 459 pathInfo.appendChild(doc.importNode(pathStepDescription, true)); 391 460 } 392 461 } … … 394 463 return pathInfo; 395 464 } 396 private Element get MRCollectionList(UserContext userContext){465 private Element getAvailableCollectionList(UserContext userContext){ 397 466 Document doc = XMLConverter.newDOM(); 398 467 // Get the message router info … … 415 484 return mr_collection_list; 416 485 } 486 private Element getSearchableCollectionList(UserContext userContext){ 487 Document doc = XMLConverter.newDOM(); 488 Element collectionList = doc.createElement(GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER); 489 // Get the message router info 490 Element mr_info_message = doc.createElement(GSXML.MESSAGE_ELEM); 491 Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "TextQuery" , userContext); 492 mr_info_message.appendChild(mr_request); 493 Element mr_info_response_message = (Element) this.router.process(mr_info_message); 494 if (mr_info_response_message == null) { 495 logger.error(" couldn't query the message router!"); 496 return null; 497 } 498 NodeList options = mr_info_response_message.getElementsByTagName(GSXML.PARAM_OPTION_ELEM); 499 for (int i = 0; i < options.getLength(); i++) { 500 Element option = (Element) options.item(i); 501 String name = option.getAttribute(GSXML.NAME_ATT); 502 if (name.equals("all")){ 503 continue; 504 } 505 Element collection = doc.createElement(GSXML.COLLECTION_ELEM); 506 collection.setAttribute(GSXML.NAME_ATT, name); 507 collectionList.appendChild(collection); 508 } 509 return collectionList; 510 } 417 511 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java
r31262 r31285 533 533 groupParamList.appendChild(doc.importNode(GSXML.getNamedElement(paramList, GSXML.PARAM_ELEM, GSXML.NAME_ATT, GSXML.GROUP_ELEM), true)); 534 534 Element groupQueryResult = (Element) this.router.process(groupQueryMessage); 535 Element groupQueryRes onse = (Element) GSXML.getChildByTagName(groupQueryResult, GSXML.RESPONSE_ELEM);536 Element collList = (Element) GSXML.getChildByTagName(groupQueryRes onse, GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER);535 Element groupQueryResponse = (Element) GSXML.getChildByTagName(groupQueryResult, GSXML.RESPONSE_ELEM); 536 Element collList = (Element) GSXML.getChildByTagName(groupQueryResponse, GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER); 537 537 NodeList collections = GSXML.getChildrenByTagName(collList, GSXML.COLLECTION_ELEM); 538 538 collArray = new String[collections.getLength()];
Note:
See TracChangeset
for help on using the changeset viewer.