Changeset 31774


Ignore:
Timestamp:
2017-07-03T13:46:36+12:00 (7 years ago)
Author:
kjdon
Message:

added a bit of checking for null elements

File:
1 edited

Legend:

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

    r31285 r31774  
    7676        // get the format info - there may be global format info in the collection that searching needs
    7777        Element format_elem = getFormatInfo(to, userContext);
    78         // set the format type
    79         format_elem.setAttribute(GSXML.TYPE_ATT, "search");
    80         // for now just add to the response
    81         page_response.appendChild(doc.importNode(format_elem, true));
    82 
    83         //if (request_type.indexOf("d") != -1)
    84         //{
     78        if (format_elem != null) {
     79          // set the format type
     80          format_elem.setAttribute(GSXML.TYPE_ATT, "search");
     81          // for now just add to the response
     82          page_response.appendChild(doc.importNode(format_elem, true));
     83        }
    8584        // get the service description
    8685            // we have been asked for the service description
     
    9190            // process the message
    9291            Element mr_info_response = (Element) this.mr.process(mr_info_message);
     92
     93            boolean does_paging = false;
     94
    9395            // the response
    94 
    9596            Element service_response = (Element) GSXML.getChildByTagName(mr_info_response, GSXML.RESPONSE_ELEM);
    9697
    97             Element service_description = (Element) doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);
    98 
    99 
    100             // have we been asked to return it as part of the response?
     98            Element service_description = (Element)GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM);
     99            if (service_description != null) {
     100              service_description = (Element) doc.importNode(service_description, true);
     101
     102              Element meta_list =(Element) GSXML.getChildByTagName(service_description, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
     103              if (meta_list != null) {
     104                String value = GSXML.getMetadataValue(meta_list, "does_paging");
     105                if (value.equals("true")) {
     106                  does_paging = true;
     107                }
     108              }
     109             
     110              if (does_paging == false) {
     111                // we will do the paging, so lets add in a hitsPerPage param to the service
     112                addHitsParamToService(doc, service_description, lang);
     113              }
     114            }
     115            //Element service_description = (Element) doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);
     116
     117
     118            // have we been asked to return the service description
     119            // as part of the response?
    101120            if (request_type.indexOf("d") != -1) {
    102               page_response.appendChild(service_description);
     121              if (service_description != null) {
     122                page_response.appendChild(service_description);
     123              }
    103124              addCollectionsHierarchy(page_response,userContext);
    104125            }
    105             //}
    106         boolean does_paging = false;
    107         Element meta_list =(Element) GSXML.getChildByTagName(service_description, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
    108         if (meta_list != null) {
    109           String value = GSXML.getMetadataValue(meta_list, "does_paging");
    110           if (value.equals("true")) {
    111             does_paging = true;
    112           }
    113         }
    114 
    115         if (does_paging == false) {
    116           // we will do the paging, so lets add in a hitsPerPage param to the service
    117           addHitsParamToService(doc, service_description, lang);
    118         }
     126
    119127        if (request_type.indexOf("r") == -1)
    120128        {
Note: See TracChangeset for help on using the changeset viewer.