Changeset 3569 for trunk/gsdl3/src/java


Ignore:
Timestamp:
2002-11-26T13:58:26+13:00 (22 years ago)
Author:
kjdon
Message:

now handles multiple requests in the same message properly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java

    r3512 r3569  
    205205
    206206    // for now, just process each request one by one, and append the results to mainResult
    207     for (int i=0; i<requests.getLength(); i++) {
     207    // Note: if you add an element to another node in the same document, it
     208    // gets removed from where it was. This changes the node list - you cant iterate over the node list in a normal manner if you are moving elements out of it
     209    int num_requests = requests.getLength();
     210    for (int i=0; i< num_requests; i++) {
    208211        Node result=null;
    209         Element req = (Element)requests.item(i);
     212        Element req = (Element)requests.item(0);
    210213        String path = req.getAttribute(GSXML.TO_ATT); // returns "" if no att of this name
    211214        if (path.equals("")) {
     
    224227            // append the contents of the message to the mainResult - there will only be one response at this stage
    225228            mainResult.appendChild(doc_.importNode(GSXML.getChildByTagName(result, GSXML.RESPONSE_ELEM), true));
     229            } else {
     230            System.err.println("MessageRouter Error: request had null result!");
    226231            }
    227232        } else {   
    228             System.err.println("MessageRouter: request has illegal module name in:\n"+converter_.getString(req));
     233            System.err.println("MessageRouter Error: request has illegal module name in:\n"+converter_.getString(req));
    229234        }
    230235        }
    231236       
    232237    } // for each request
    233     System.out.println("MR returning result");
    234     System.out.println(converter_.getString(mainResult));
    235238
    236239    return mainResult;
Note: See TracChangeset for help on using the changeset viewer.