Changeset 4950


Ignore:
Timestamp:
2003-07-16T15:15:53+12:00 (21 years ago)
Author:
kjdon
Message:

now about action gets the service descriptions for each service, so it can display the service name rather than internal id

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/PageAction.java

    r4943 r4950  
    120120    Element coll_about_response = (Element)mr_.process(coll_about_message);
    121121
    122     // get the response element and return it
     122    if (coll_about_response == null) {
     123        return null;
     124    }
     125   
     126    // second, get the info for each service - we only want display items
     127    // but for now, we'll just get it all
     128    NodeList services = coll_about_response.getElementsByTagName(GSXML.SERVICE_ELEM);
     129    // we will send all the requests in a single message
     130    Element info_message = doc_.createElement(GSXML.MESSAGE_ELEM);
     131    for (int i=0; i<services.getLength(); i++) {
     132        Element c = (Element)services.item(i);
     133        String name = c.getAttribute(GSXML.NAME_ATT);
     134        String address = GSPath.appendLink(coll_name, name);
     135        Element info_request = GSXML.createBasicRequest(doc_,  GSXML.REQUEST_TYPE_DESCRIBE, address, lang);
     136        info_message.appendChild(info_request);
     137    }
     138
     139    Element info_response = (Element)mr_.process(info_message);
     140
     141    NodeList service_responses = info_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
     142    // check that have same number of responses as collections
     143    if (services.getLength() != service_responses.getLength()) {
     144        System.err.println("PageAction Error: didn't get a response for each service - somethings gone wrong!");
     145        // for now, dont use the metadata
     146    } else {
     147        for (int i=0; i<services.getLength(); i++) {
     148        Element c1 = (Element)services.item(i);
     149        Element c2 = (Element)GSXML.getChildByTagName((Element)service_responses.item(i), GSXML.SERVICE_ELEM);
     150        if (c1.getAttribute(GSXML.NAME_ATT).equals(c2.getAttribute(GSXML.NAME_ATT))) {
     151            //add the service data into the original response
     152            GSXML.mergeElements(c1, c2);
     153        } else {
     154            System.err.println("PageAction Error: response does not correspond to request!");
     155        }
     156       
     157        }
     158    }
     159   
     160    //now the full response message is in coll_list_response
     161    // return the response element
    123162    Element response = (Element) GSXML.getChildByTagName(coll_about_response, GSXML.RESPONSE_ELEM);
    124163    return response;
    125    
    126164    }
     165
    127166
    128167    /** if we dont know the page type, use this method */
Note: See TracChangeset for help on using the changeset viewer.