Changeset 5127


Ignore:
Timestamp:
2003-08-13T09:56:54+12:00 (21 years ago)
Author:
kjdon
Message:

made this a bit smarter about whether it gets teh coll description or not - wont get it if already there. it also gets teh service displayItem elements as well, so all teh services can be presented to the user on teh navigation bar.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java

    r5113 r5127  
    2525   
    2626    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));
    2828    // is a collection defined?
    2929    Element param_list = (Element)GSXML.getChildByTagName(page_request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     
    3737        return;
    3838    }
    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);
    4351    }
    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;
    5774    }
    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
    6677   
    6778    // 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);
    6980    if (service_list == null) {
    7081        System.out.println("DefaultReceptionist: no service list, returning");
     
    7485
    7586    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       
    76108    // we will send all the requests in a single message
    77109    Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     
    79111        Element c = (Element)services.item(i);
    80112        String name = c.getAttribute(GSXML.NAME_ATT);
    81         String address = GSPath.appendLink(collection, name);
     113        String address = GSPath.appendLink(coll_name, name);
    82114        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);
    83118        info_message.appendChild(info_request);
     119       
    84120    }
    85121
Note: See TracChangeset for help on using the changeset viewer.