Changeset 5127
- Timestamp:
- 2003-08-13T09:56:54+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java
r5113 r5127 25 25 26 26 Element page_request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM); 27 System.out.println("add extra info, page request="+this.converter.getString(page_request));27 ///ystem.out.println("add extra info, page request="+this.converter.getString(page_request)); 28 28 // is a collection defined? 29 29 Element param_list = (Element)GSXML.getChildByTagName(page_request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); … … 37 37 return; 38 38 } 39 String action = page_request.getAttribute(GSXML.ACTION_ATT); 40 if (action.equals("p")) { 41 System.out.println("DefaultReceptionist: page action, so returning"); 42 return; 39 40 // see if the collection/cluster element is already there 41 String coll_name = coll_param.getAttribute(GSXML.VALUE_ATT); 42 String lang = page_request.getAttribute(GSXML.LANG_ATT); 43 44 boolean get_service_description = false; 45 Element page_response = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM); 46 47 Element coll_description = (Element)GSXML.getChildByTagName(page_response, GSXML.COLLECTION_ELEM); 48 if (coll_description == null) { 49 // try cluster 50 coll_description = (Element)GSXML.getChildByTagName(page_response, GSXML.CLUSTER_ELEM); 43 51 } 44 // we have a collection, and we are not page action. get the coll description 45 46 String collection = coll_param.getAttribute(GSXML.VALUE_ATT); 47 String lang = page_request.getAttribute(GSXML.LANG_ATT); 48 Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 49 Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, collection, lang); 50 coll_about_message.appendChild(coll_about_request); 51 52 Element coll_about_response_message = this.mr.process(coll_about_message); 53 Element coll_about_response = (Element)GSXML.getChildByTagName(coll_about_response_message, GSXML.RESPONSE_ELEM); 54 Element coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.COLLECTION_ELEM); 55 if (coll_description==null) { // may be a cluster 56 coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.CLUSTER_ELEM); 52 if (coll_description == null) { 53 System.out.println("getting a coll description"); 54 // we dont have one yet - get it 55 Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM); 56 Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, lang); 57 coll_about_message.appendChild(coll_about_request); 58 59 Element coll_about_response_message = this.mr.process(coll_about_message); 60 Element coll_about_response = (Element)GSXML.getChildByTagName(coll_about_response_message, GSXML.RESPONSE_ELEM); 61 coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.COLLECTION_ELEM); 62 if (coll_description==null) { // may be a cluster 63 coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.CLUSTER_ELEM); 64 } 65 66 if (coll_description == null) { 67 System.out.println("DefaultReceptionist: no collection description, returning"); 68 return; 69 } 70 // have found one, append it to the page response 71 coll_description = (Element)this.doc.importNode(coll_description, true); 72 page_response.appendChild(coll_description); 73 get_service_description = true; 57 74 } 58 if (coll_description == null) { 59 System.out.println("DefaultReceptionist: no collection description, returning"); 60 return; 61 } 62 63 Element page_response = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM); 64 Element new_coll_description = (Element)this.doc.importNode(coll_description, true); 65 page_response.appendChild(new_coll_description); 75 76 // have got a coll description 66 77 67 78 // now get the dispay info for the services 68 Element service_list = (Element)GSXML.getChildByTagName( new_coll_description, GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);79 Element service_list = (Element)GSXML.getChildByTagName(coll_description, GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER); 69 80 if (service_list == null) { 70 81 System.out.println("DefaultReceptionist: no service list, returning"); … … 74 85 75 86 NodeList services = service_list.getElementsByTagName(GSXML.SERVICE_ELEM); 87 // check one service for display items 88 if (!get_service_description) { 89 // we dont know yet if we need to get these 90 int i=1; 91 Element test_s = (Element)services.item(0); 92 while (i<services.getLength() && test_s.getAttribute(GSXML.TYPE_ATT).equals(GSXML.SERVICE_TYPE_RETRIEVE)) { 93 test_s = (Element)services.item(i); i++; 94 } 95 if (i==services.getLength()) { 96 // we have only found retrieve services, so dont need descripitons anyway 97 return; 98 } 99 if (GSXML.getChildByTagName(test_s, GSXML.DISPLAY_TEXT_ELEM) !=null) { 100 // have got descriptions already, 101 return; 102 } 103 } 104 105 // if get here, we need to get the service descriptions 106 ///ystem.out.println("getting services description"); 107 76 108 // we will send all the requests in a single message 77 109 Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM); … … 79 111 Element c = (Element)services.item(i); 80 112 String name = c.getAttribute(GSXML.NAME_ATT); 81 String address = GSPath.appendLink(coll ection, name);113 String address = GSPath.appendLink(coll_name, name); 82 114 Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, address, lang); 115 Element req_param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 116 req_param_list.appendChild(GSXML.createParameter(this.doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM)); 117 info_request.appendChild(req_param_list); 83 118 info_message.appendChild(info_request); 119 84 120 } 85 121
Note:
See TracChangeset
for help on using the changeset viewer.