Changeset 24203


Ignore:
Timestamp:
2011-06-27T11:08:35+12:00 (13 years ago)
Author:
sjb48
Message:

Working on document-level format editting

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java

    r24134 r24203  
    4040    public Node process (Node message_node) {
    4141   
    42     Element message = this.converter.nodeToElement(message_node);
     42        Element message = this.converter.nodeToElement(message_node);
    4343
    44     // assume only one request
    45     Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
     44        // assume only one request
     45        Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    4646   
    47     String subaction = request.getAttribute(GSXML.SUBACTION_ATT);
    48     String lang = request.getAttribute(GSXML.LANG_ATT);
    49     String uid = request.getAttribute(GSXML.USER_ID_ATT);
    50     // get the param list
    51     Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    52     HashMap params = GSXML.extractParams(cgi_param_list, false);
     47        String subaction = request.getAttribute(GSXML.SUBACTION_ATT);
     48        String lang = request.getAttribute(GSXML.LANG_ATT);
     49        String uid = request.getAttribute(GSXML.USER_ID_ATT);
     50        // get the param list
     51        Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     52        HashMap params = GSXML.extractParams(cgi_param_list, false);
    5353
    54     Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
     54        Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
    5555   
    56     String coll = (String)params.get(GSParams.COLLECTION); //SYSTEM_CLUSTER);
    57     //String subaction = (String)params.get(GSParams.SUBACTION);
    58     String service = (String)params.get(GSParams.SERVICE);
    59     String classifier = (String)params.get("cl");
     56        String coll = (String)params.get(GSParams.COLLECTION); //SYSTEM_CLUSTER);
     57        //String subaction = (String)params.get(GSParams.SUBACTION);
     58        String service = (String)params.get(GSParams.SERVICE);
     59        String classifier = (String)params.get("cl");
    6060
    6161
    62     logger.error("Collection="+coll);
    63     logger.error("Subaction="+subaction);
    64     logger.error("Service="+service);
    65     logger.error("Classifier="+classifier);
     62        logger.error("Collection="+coll);
     63        logger.error("Subaction="+subaction);
     64        logger.error("Service="+service);
     65        logger.error("Classifier="+classifier);
    6666
    6767
    68     String to = "";
    69     if (coll!=null && !coll.equals("")) {
    70         to = coll;
    71     }
     68        String to = "";
     69        if (coll!=null && !coll.equals("")) {
     70            to = coll;
     71        }
    7272
    73     Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    74     Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, lang, uid);
     73        Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     74        Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, lang, uid);
    7575
    76     mr_request.setAttribute("service", service);
    77     mr_request.setAttribute("subaction", subaction);
    78     //if(classifier != null)
    79     mr_request.setAttribute("classifier", classifier);
     76        mr_request.setAttribute("service", service);
     77        mr_request.setAttribute("subaction", subaction);
     78        //if(classifier != null)
     79        mr_request.setAttribute("classifier", classifier);
    8080
    81     mr_request_message.appendChild(mr_request);
     81        mr_request_message.appendChild(mr_request);
    8282   
    83     //Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
    84     //mr_request.appendChild(format);
     83        //Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
     84        //mr_request.appendChild(format);
    8585
    86     String format_string = (String)params.get("data");
    87     //logger.error("Original format string");
    88     //logger.error(format_string);
     86        String format_string = (String)params.get("data");
     87        //logger.error("Original format string");
     88        //logger.error(format_string);
    8989   
    90     Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     90        Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
    9191
    92     Iterator it = params.keySet().iterator();
    93     //while(it.hasNext())
    94     //{
    95     //    logger.error("Param: "+it.next());
    96     //}     
     92        Iterator it = params.keySet().iterator();
     93        //while(it.hasNext())
     94        //{
     95        //    logger.error("Param: "+it.next());
     96        //}     
    9797
    98     try {
     98        try {
    9999            //DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    100100            //DocumentBuilder builder = factory.newDocumentBuilder();
     
    122122            //String transformed = transformer.transformToString(style_doc, d);
    123123            logger.error("About to transform");
    124             Node transformed = (Node) transformer.transform(style_doc, d);  // Failing org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. ; SystemID: file:///home/sam/greenstone3/packages/tomcat/bin/dummy.xsl
     124            Node transformed = (Node) transformer.transform(style_doc, d); 
     125            // Failing org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. ; SystemID: file:///home/sam/greenstone3/packages/tomcat/bin/dummy.xsl
    125126
    126127            logger.error("Transform successful?");
     
    149150
    150151            //page_response.appendChild(this.doc.importNode(e, true));
    151     } catch( Exception ex ) {
     152        } catch( Exception ex ) {
    152153            logger.error("There was an exception "+ex);
    153154           
     
    158159            sw.flush();
    159160            logger.error(sw.toString());
    160     }
     161        }
    161162
    162163
    163     // Call XSLT to transform document to xml format string
    164     //XMLTransformer transformer = new XMLTransformer();
     164        // Call XSLT to transform document to xml format string
     165        //XMLTransformer transformer = new XMLTransformer();
    165166
    166     // not sure what to do here - some code from Transforming Receptionist
    167     //transformer.transformToString(Document stylesheet, Document source);
     167        // not sure what to do here - some code from Transforming Receptionist
     168        //transformer.transformToString(Document stylesheet, Document source);
    168169
    169     // create a mesage to send to the collection object via the message router
     170        // create a mesage to send to the collection object via the message router
    170171
    171     Node response_message = this.mr.process(mr_request_message);
     172        Node response_message = this.mr.process(mr_request_message);
    172173   
    173     result.appendChild(GSXML.duplicateWithNewName(this.doc, (Element)GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true));
    174     return result;
     174        result.appendChild(GSXML.duplicateWithNewName(this.doc, (Element)GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true));
     175        return result;
    175176   
    176177    }
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/Collection.java

    r24135 r24203  
    359359    response.setAttribute(GSXML.TYPE_ATT, type);
    360360
     361    logger.error("Collection received a message, attempting to process");
     362
    361363    if (type.equals(GSXML.REQUEST_TYPE_FORMAT_STRING)) {
    362364        logger.error("Received format string request");
     
    501503                        if(GSXML.getChildByTagName(current_node, "format") == null)
    502504                        {
    503                             logger.error("ERROR: classifier does not have a format child");
     505                            logger.error("ERROR: valid classifier but does not have a format child");
    504506                            // well then create a format tag
    505507                            Element format_tag = config.createElement("format");
     
    511513                            current_node = GSXML.getChildByTagName(current_node, "format");
    512514                        }
     515
    513516                    }
    514517                    else{
    515518                        logger.error("Classifier is null");
     519                        // To support all classifiers, set classifier to null?  There is the chance here that the format tag does not exist
     520                        if(GSXML.getChildByTagName(current_node, "format") == null)
     521                        {
     522                            logger.error("ERROR: classifier does not have a format child");
     523                            // well then create a format tag
     524                            Element format_tag = config.createElement("format");
     525                            current_node = (Node) current_node.appendChild(format_tag);
     526                            //current_node = (Node) format_tag;
     527                        }
     528                        else
     529                            current_node = GSXML.getChildByTagName(current_node, "format");
     530                    }
     531                }
     532                else if(service.equals("AllClassifierBrowse"))
     533                {
     534                    logger.error("Looking for browse");
     535                    current_node = GSXML.getChildByTagName(current_node, "browse");
     536                    if(GSXML.getChildByTagName(current_node, "format") == null)
     537                    {
     538                        logger.error("ERROR AllClassifierBrowse: all classifiers do not have a format child");
     539                        // well then create a format tag
     540                        Element format_tag = config.createElement("format");
     541                        current_node = (Node) current_node.appendChild(format_tag);
     542                        //current_node = (Node) format_tag;
     543                    }
     544                    else
    516545                        current_node = GSXML.getChildByTagName(current_node, "format");
    517                     }
    518546                }
    519547                else
     
    536564                elem = (Element) current_node;
    537565   
    538                 logger.error("Current_node = " + elem.getNodeName());
     566                logger.error("*Current_node = " + elem.getNodeName());
    539567
    540568                // seems we want to remove current child/ren and replace with format_statement's child/ren?
     
    542570                // remove existing
    543571                current_node_list = elem.getChildNodes();
     572                logger.error("About to remove old children");
    544573                for(k=0; k<current_node_list.getLength(); k++)
    545574                {
    546575                    current_node = elem.removeChild(current_node_list.item(k));
    547576                }
     577
     578                logger.error("old nodes removed");
    548579
    549580                // append new but we have a string!
     
    560591                        elem.appendChild(config.importNode(current_node_list.item(k),true));
    561592                }
     593                logger.error("new nodes added");
    562594
    563595                //String text = GSXML.getNodeText(elem);
     
    568600
    569601                // Now convert config document to string for writing to file
     602                logger.error("Convert config to string");
    570603                String new_config = this.converter.getString(config);
    571604
     
    578611                writer.write(new_config);
    579612                writer.close();
     613                logger.error("All is happy with collection");
    580614
    581615             } catch( Exception ex ) {
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java

    r23489 r24203  
    388388    public Node process(Node message_node) {
    389389
     390    logger.error("ServiceCluster is processing a message");
     391
    390392    Element message = this.converter.nodeToElement(message_node);
    391393
     
    417419        } else { // the request is for one of my services
    418420        String service = GSPath.getFirstLink(to);
     421        logger.error(service+" specified!");
    419422       
    420423        if (!this.service_map.containsKey(service)) {
     
    467470    protected Element processMessage(Element request) {
    468471
     472    logger.error("ServiceCluster is processing an element request");
    469473    Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
    470474    response.setAttribute(GSXML.FROM_ATT, this.cluster_name);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/FormatReceptionist.java

    r22676 r24203  
    2020public class FormatReceptionist extends TransformingReceptionist {
    2121
    22      static Logger logger = Logger.getLogger(org.greenstone.gsdl3.core.DefaultReceptionist.class.getName());
     22    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.core.DefaultReceptionist.class.getName());
    2323   
    24   /** add in the collection description to the page, then for each service, add in the service description */
     24    /** add in the collection description to the page, then for each service, add in the service description */
    2525    protected void addExtraInfo(Element page) {
    26       super.addExtraInfo(page);
     26        super.addExtraInfo(page);
    2727   
    28     Element page_request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM);
    29     // if it is a system request, then we don't bother with this.
    30     String action = page_request.getAttribute(GSXML.ACTION_ATT);
    31     if (action.equals("s")) {
    32         logger.error("HACK: don't ask for coll info if system action");
    33         return;
    34     }
    35     logger.debug("add extra info, page request="+this.converter.getString(page_request));
    36     // is a collection defined?
    37     Element param_list = (Element)GSXML.getChildByTagName(page_request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    38     if (param_list==null) { // must be the original home page
    39         logger.debug(" no param list, assuming home page");
    40         return;
    41     }
    42     Element coll_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, GSParams.COLLECTION);
    43     if (coll_param == null) {
    44         logger.debug(" coll param is null, returning");
    45         return;
    46     }
     28        Element page_request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM);
     29        // if it is a system request, then we don't bother with this.
     30        String action = page_request.getAttribute(GSXML.ACTION_ATT);
     31        if (action.equals("s")) {
     32            logger.error("HACK: don't ask for coll info if system action");
     33            return;
     34        }
     35        logger.debug("add extra info, page request="+this.converter.getString(page_request));
     36        // is a collection defined?
     37        Element param_list = (Element)GSXML.getChildByTagName(page_request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     38        if (param_list==null) { // must be the original home page
     39            logger.debug(" no param list, assuming home page");
     40            return;
     41        }
     42        Element coll_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, GSParams.COLLECTION);
     43        if (coll_param == null) {
     44            logger.debug(" coll param is null, returning");
     45            return;
     46        }
    4747
    48     // see if the collection/cluster element is already there
    49     String coll_name = coll_param.getAttribute(GSXML.VALUE_ATT);
    50     String lang = page_request.getAttribute(GSXML.LANG_ATT);
    51     String uid = page_request.getAttribute(GSXML.USER_ID_ATT);
    52    
    53     boolean get_service_description = false;
    54     Element page_response = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM);
    55     if (this.language_list != null) {
    56         page_response.appendChild(this.language_list);
    57     }
    58     Element coll_description = (Element)GSXML.getChildByTagName(page_response, GSXML.COLLECTION_ELEM);
    59     if (coll_description == null) {
    60         // try cluster
    61         coll_description = (Element)GSXML.getChildByTagName(page_response, GSXML.CLUSTER_ELEM);
    62     }
    63     if (coll_description == null) {
    64         // we dont have one yet - get it
    65         Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    66         Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE,  coll_name, lang, uid);
    67         coll_about_message.appendChild(coll_about_request);
    68        
    69         Node coll_about_response_message = this.mr.process(coll_about_message);
    70         Element coll_about_response = (Element)GSXML.getChildByTagName(coll_about_response_message, GSXML.RESPONSE_ELEM);
    71         if (coll_about_response == null) {
    72         return;
    73         }
    74         coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.COLLECTION_ELEM);
    75         if (coll_description==null) { // may be a cluster
    76         coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.CLUSTER_ELEM);
    77         }
    78        
    79         if (coll_description == null) {
    80         logger.error(" no collection description, returning");
    81         return;
    82         }
    83         // have found one, append it to the page response
    84         coll_description = (Element)this.doc.importNode(coll_description, true);
    85         page_response.appendChild(coll_description);
    86         get_service_description = true;
    87     }
     48        // see if the collection/cluster element is already there
     49        String coll_name = coll_param.getAttribute(GSXML.VALUE_ATT);
     50        String lang = page_request.getAttribute(GSXML.LANG_ATT);
     51        String uid = page_request.getAttribute(GSXML.USER_ID_ATT);
    8852
    89     // have got a coll description
    90    
    91     // now get the dispay info for the services
    92     Element service_list = (Element)GSXML.getChildByTagName(coll_description, GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
    93     if (service_list == null) {
    94         logger.error(" no service list, returning");
    95         // something weird has gone wrong
    96         return;
    97     }
     53        boolean get_service_description = false;
     54        Element page_response = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM);
     55        if (this.language_list != null) {
     56            page_response.appendChild(this.language_list);
     57        }
     58        Element coll_description = (Element)GSXML.getChildByTagName(page_response, GSXML.COLLECTION_ELEM);
     59        if (coll_description == null) {
     60            // try cluster
     61            coll_description = (Element)GSXML.getChildByTagName(page_response, GSXML.CLUSTER_ELEM);
     62        }
     63        if (coll_description == null) {
     64            // we dont have one yet - get it
     65            Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     66            Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE,  coll_name, lang, uid);
     67            coll_about_message.appendChild(coll_about_request);
    9868
    99     NodeList services = service_list.getElementsByTagName(GSXML.SERVICE_ELEM);
    100     if (services.getLength()==0) {
    101         logger.error("DefaultReceoptionist: no services found for colllection/cluster "+ coll_name);
    102         return;
    103     }
    104     // check one service for display items
    105     if (!get_service_description) {
    106         // we dont know yet if we need to get these
    107         int i=1;
    108         Element test_s = (Element)services.item(0);
    109         while (i<services.getLength() && (test_s.getAttribute(GSXML.TYPE_ATT).equals(GSXML.SERVICE_TYPE_RETRIEVE) || test_s.getAttribute(GSXML.TYPE_ATT).equals(GSXML.SERVICE_TYPE_OAI))) {
    110         test_s = (Element)services.item(i); i++;
    111         }
    112         if (i==services.getLength()) {
    113         // we have only found retrieve or oai services, so dont need descripitons anyway
    114         return;
    115         }
    116         if (GSXML.getChildByTagName(test_s, GSXML.DISPLAY_TEXT_ELEM) !=null) {
    117         // have got descriptions already,
    118         return;
    119         }
    120     }
     69            Node coll_about_response_message = this.mr.process(coll_about_message);
     70            Element coll_about_response = (Element)GSXML.getChildByTagName(coll_about_response_message, GSXML.RESPONSE_ELEM);
     71            if (coll_about_response == null) {
     72                return;
     73            }
     74            coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.COLLECTION_ELEM);
     75            if (coll_description==null) { // may be a cluster
     76                coll_description = (Element)GSXML.getChildByTagName(coll_about_response, GSXML.CLUSTER_ELEM);
     77            }
    12178
    122     // if get here, we need to get the service descriptions
    123        
    124     // we will send all the requests in a single message
    125     Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    126     for (int i=0; i<services.getLength(); i++) {
    127         Element c = (Element)services.item(i);
    128         String name = c.getAttribute(GSXML.NAME_ATT);
    129         String address = GSPath.appendLink(coll_name, name);
    130         Element info_request = GSXML.createBasicRequest(this.doc,  GSXML.REQUEST_TYPE_DESCRIBE, address, lang, uid);
    131         Element req_param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    132         req_param_list.appendChild(GSXML.createParameter(this.doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER));
    133         info_request.appendChild(req_param_list);
    134         info_message.appendChild(info_request);
    135        
    136     }
     79            if (coll_description == null) {
     80                logger.error(" no collection description, returning");
     81                return;
     82            }
     83            // have found one, append it to the page response
     84            coll_description = (Element)this.doc.importNode(coll_description, true);
     85            page_response.appendChild(coll_description);
     86            get_service_description = true;
     87        }
    13788
    138     Element info_response = (Element)this.mr.process(info_message);
     89        // have got a coll description
    13990
    140     NodeList service_responses = info_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
    141     // check that have same number of responses as collections
    142     if (services.getLength() != service_responses.getLength()) {
    143         logger.error(" didn't get a response for each service - somethings gone wrong!");
    144         // for now, dont use the metadata
    145     } else {
    146         for (int i=0; i<services.getLength(); i++) {
    147         Element c1 = (Element)services.item(i);
    148         Element c2 = (Element)GSXML.getChildByTagName((Element)service_responses.item(i), GSXML.SERVICE_ELEM);
    149         if (c1 !=null && c2 !=null && c1.getAttribute(GSXML.NAME_ATT).equals(c2.getAttribute(GSXML.NAME_ATT))) {
    150             //add the service data into the original response
    151             GSXML.mergeElements(c1, c2);
    152         } else {
    153             logger.debug(" response does not correspond to request!");
    154         }
    155        
    156         }
    157     }
     91        // now get the dispay info for the services
     92        Element service_list = (Element)GSXML.getChildByTagName(coll_description, GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
     93        if (service_list == null) {
     94            logger.error(" no service list, returning");
     95            // something weird has gone wrong
     96            return;
     97        }
    15898
    159     // Request collection metadata
    160     info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
    161     String address = GSPath.appendLink(coll_name, "CoverageMetadataRetrieve");
    162     Element info_request = GSXML.createBasicRequest(this.doc,  GSXML.REQUEST_TYPE_PROCESS, address, lang, uid);
    163     Element req_param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    164     req_param_list.appendChild(GSXML.createParameter(this.doc, "metadata", "All")); // GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER));
    165     info_request.appendChild(req_param_list);
    166     info_message.appendChild(info_request);
     99        NodeList services = service_list.getElementsByTagName(GSXML.SERVICE_ELEM);
     100        if (services.getLength()==0) {
     101            logger.error("DefaultReceoptionist: no services found for colllection/cluster "+ coll_name);
     102            return;
     103        }
     104        // check one service for display items
     105        if (!get_service_description) {
     106            // we dont know yet if we need to get these
     107            int i=1;
     108            Element test_s = (Element)services.item(0);
     109            while (i<services.getLength() && (test_s.getAttribute(GSXML.TYPE_ATT).equals(GSXML.SERVICE_TYPE_RETRIEVE) || test_s.getAttribute(GSXML.TYPE_ATT).equals(GSXML.SERVICE_TYPE_OAI))) {
     110                test_s = (Element)services.item(i); i++;
     111            }
     112            if (i==services.getLength()) {
     113                // we have only found retrieve or oai services, so dont need descripitons anyway
     114                return;
     115            }
     116            if (GSXML.getChildByTagName(test_s, GSXML.DISPLAY_TEXT_ELEM) !=null) {
     117                // have got descriptions already,
     118                return;
     119            }
     120        }
    167121
    168     logger.error("************ Coverage Metadata request created");
    169     logger.error("************ add extra info, page request="+this.converter.getString(info_message));
     122        // if get here, we need to get the service descriptions
    170123
    171     info_response = (Element)this.mr.process(info_message);
    172     logger.error("************ page response="+this.converter.getString(info_response));
     124        // we will send all the requests in a single message
     125        Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     126        for (int i=0; i<services.getLength(); i++) {
     127            Element c = (Element)services.item(i);
     128            String name = c.getAttribute(GSXML.NAME_ATT);
     129            String address = GSPath.appendLink(coll_name, name);
     130            Element info_request = GSXML.createBasicRequest(this.doc,  GSXML.REQUEST_TYPE_DESCRIBE, address, lang, uid);
     131            Element req_param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     132            req_param_list.appendChild(GSXML.createParameter(this.doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER));
     133            info_request.appendChild(req_param_list);
     134            info_message.appendChild(info_request);
    173135
    174     Element coverage_metadata = (Element)GSXML.getNodeByPath(info_response, "response/metadataSetList");
    175     logger.error("************ This should be metadata set list="+this.converter.getString(coverage_metadata));
    176     if(coverage_metadata != null)
    177     {
    178         coverage_metadata = (Element)this.doc.importNode(coverage_metadata, true);
    179         coll_description.appendChild(coverage_metadata);
    180     }
    181    
     136        }
     137
     138        Element info_response = (Element)this.mr.process(info_message);
     139
     140        NodeList service_responses = info_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
     141        // check that have same number of responses as collections
     142        if (services.getLength() != service_responses.getLength()) {
     143            logger.error(" didn't get a response for each service - somethings gone wrong!");
     144            // for now, dont use the metadata
     145        } else {
     146            for (int i=0; i<services.getLength(); i++) {
     147                Element c1 = (Element)services.item(i);
     148                Element c2 = (Element)GSXML.getChildByTagName((Element)service_responses.item(i), GSXML.SERVICE_ELEM);
     149                if (c1 !=null && c2 !=null && c1.getAttribute(GSXML.NAME_ATT).equals(c2.getAttribute(GSXML.NAME_ATT))) {
     150                    //add the service data into the original response
     151                    GSXML.mergeElements(c1, c2);
     152                } else {
     153                    logger.debug(" response does not correspond to request!");
     154                }
     155
     156            }
     157        }
     158
     159        // Request collection metadata
     160        info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     161        String address = GSPath.appendLink(coll_name, "CoverageMetadataRetrieve");
     162        Element info_request = GSXML.createBasicRequest(this.doc,  GSXML.REQUEST_TYPE_PROCESS, address, lang, uid);
     163        Element req_param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     164        req_param_list.appendChild(GSXML.createParameter(this.doc, "metadata", "All")); // GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER));
     165        info_request.appendChild(req_param_list);
     166        info_message.appendChild(info_request);
     167
     168        logger.error("************ Coverage Metadata request created");
     169        logger.error("************ add extra info, page request="+this.converter.getString(info_message));
     170
     171        info_response = (Element)this.mr.process(info_message);
     172        logger.error("************ page response="+this.converter.getString(info_response));
     173
     174        Element coverage_metadata = (Element)GSXML.getNodeByPath(info_response, "response/metadataSetList");
     175        logger.error("************ This should be metadata set list="+this.converter.getString(coverage_metadata));
     176        if(coverage_metadata != null)
     177        {
     178            coverage_metadata = (Element)this.doc.importNode(coverage_metadata, true);
     179            coll_description.appendChild(coverage_metadata);
     180        }
     181
    182182    }
    183183}
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r24010 r24203  
    426426       
    427427    String xslt_file = getXSLTFileName(action, subaction, collection);
     428    logger.error("I am looking for the XSLT file for action "+action+", subaction "+subaction+" and collection "+collection);
     429    logger.error("The XSLT file I have found is "+xslt_file);
    428430    if (xslt_file==null) {
    429431      // returning file not found error page to indicate which file is missing
     
    771773  protected String getXSLTFileName(String action, String subaction,
    772774                   String collection) {
     775    logger.error("getXSLTFileName: I am looking for the XSLT file for action "+action+", subaction "+subaction+" and collection "+collection);
    773776
    774777    String name = null;
Note: See TracChangeset for help on using the changeset viewer.