Changeset 3909


Ignore:
Timestamp:
2003-03-19T14:20:52+12:00 (21 years ago)
Author:
kjdon
Message:

added methods to return format info for a service

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/ServiceRack.java

    r3900 r3909  
    8282    description */
    8383    protected HashMap service_info_map_ = null;
     84    /** XML element for stylesheet requests - map of service name to format
     85    elem */
     86    protected HashMap format_info_map_ = null;
    8487
    8588    /** sets the cluster name */
     
    108111    short_service_info_ = doc_.createElement(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
    109112    service_info_map_ = new HashMap();
     113    format_info_map_ = new HashMap();
    110114    }
    111115   
     
    165169        }
    166170       
     171        } else if (type.equals(GSXML.REQUEST_TYPE_FORMAT)) {
     172        Element response = processFormat(request);
     173            mainResult.appendChild(doc_.importNode(response, true));
     174       
     175           
    167176        } else {
    168177        // other type of request, must be processed by the subclass -
     
    257266    }
    258267
     268    /** process method for stylesheet requests
     269     */
     270    protected Element processFormat(Element request) {
     271    Element response = doc_.createElement(GSXML.RESPONSE_ELEM);
     272    response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_FORMAT);
     273   
     274    String to = GSPath.getFirstLink(request.getAttribute(GSXML.TO_ATT));
     275   
     276    if (to.equals("")) { // serviceRack query - is this appropriate??
     277        return response;
     278    }
     279   
     280   
     281    // describe a particular service   
     282    if (format_info_map_.containsKey(to)) {
     283        response.appendChild(getServiceFormat(to));
     284        response.setAttribute(GSXML.FROM_ATT, to);
     285        return response;
     286    }
     287    // else error in to field
     288    System.err.println("ServiceRack describe request: no format info for "+to+".");
     289    return response;
     290    }   
     291   
    259292    // the following two should be overwritten for info with any language stuff in it
    260293    /** returns the service list for the subclass */
     
    263296    return short_service_info_;
    264297    }
    265 
     298   
    266299    /** returns a specific service description */
    267300    protected Element getServiceDescription(String service, String lang) {
     
    273306    }
    274307   
     308   
    275309    /** adds the display element into the description - appends to the root for now, but may do something fancy later */
    276310    protected boolean addServiceDisplay(Element descript, Element display) {
     
    282316    }
    283317
     318    protected Element getServiceFormat(String service) {
     319    Element format = (Element)((Element)format_info_map_.get(service)).cloneNode(true);
     320    return format;
     321    }
    284322    /** creates a display element containing all the text strings needed to display the service page, in the language specified */
    285323    abstract protected Element createServiceDisplay(String service, String lang);
Note: See TracChangeset for help on using the changeset viewer.