Changeset 13568


Ignore:
Timestamp:
2007-01-11T14:31:23+13:00 (15 years ago)
Author:
shaoqun
Message:

added the guard to check the null node begore using it

File:
1 edited

Legend:

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

    r13270 r13568  
    278278    // process the metadata requests
    279279    Element metadata_response = (Element)this.mr.process(metadata_message);
    280     if (did_classifier) {
     280        if (did_classifier) {
    281281        // the classifier one will be the first response
    282282        // add the metadata lists for each node back into the
     
    284284        path = GSPath.appendLink(GSXML.RESPONSE_ELEM,
    285285                   GSXML.CLASS_NODE_ELEM+GSXML.LIST_MODIFIER);
    286         NodeList meta_response_cls = GSXML.getNodeByPath(metadata_response, path).getChildNodes();
     286            Node pathNode = GSXML.getNodeByPath(metadata_response, path);
     287            if (pathNode ==null){
     288            return page_response;
     289        }
     290        NodeList meta_response_cls = pathNode.getChildNodes();
    287291        for (int i = 0; i < cl_nodes.getLength(); i++) {
    288292        GSXML.mergeMetadataLists(cl_nodes.item(i), meta_response_cls.item(i));
    289         }
    290     }
     293       
     294        }
     295    }
     296
    291297    if (did_documents) {
    292298        NodeList meta_response_docs = null;
     
    295301        path = GSPath.appendLink(GSXML.RESPONSE_ELEM,
    296302                     GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    297         meta_response_docs = GSXML.getNodeByPath(metadata_response, path).getChildNodes();
     303        Node pathNode = GSXML.getNodeByPath(metadata_response, path);
     304        if (pathNode ==null){
     305            return page_response;
     306                 }
     307
     308        meta_response_docs = pathNode.getChildNodes();
     309       
     310
    298311        } else { // its the second response
    299         meta_response_docs = GSXML.getChildByTagName(metadata_response.getElementsByTagName(GSXML.RESPONSE_ELEM).item(1), GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER).getChildNodes();
     312                Node nodes = GSXML.getChildByTagName(metadata_response.getElementsByTagName(GSXML.RESPONSE_ELEM).item(1), GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     313        if (nodes ==null){
     314            return page_response;
     315                 }
     316        meta_response_docs = nodes.getChildNodes();
    300317        }
    301318       
Note: See TracChangeset for help on using the changeset viewer.