Ignore:
Timestamp:
2003-03-12T15:04:12+13:00 (21 years ago)
Author:
kjdon
Message:

new xml format - removed content from request and response, document has been renamed documentNode

File:
1 edited

Legend:

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

    r3820 r3862  
    102102    result.setAttribute(GSXML.FROM_ATT, from);
    103103    result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
    104     Element result_content = doc_.createElement(GSXML.CONTENT_ELEM);
    105     result.appendChild(result_content);
     104    //Element result_content = doc_.createElement(GSXML.CONTENT_ELEM);
     105    //result.appendChild(result_content);
    106106
    107     // Get the parameters of the request
    108     Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    109     if (param_list == null) {
    110         System.err.println("GS2Retrieve, DocumentContentRetrieve Error: missing paramList.\n");
    111         return result;  // Return the empty result
    112     }
    113 
    114     String index = default_index_;
    115 
    116     // Process the request parameters
    117     Element param = (Element) param_list.getFirstChild();
    118     while (param != null) {
    119         if (!param.getNodeName().equals(GSXML.PARAM_ELEM)) {
    120         System.err.println("Warning: Non-param in paramList (ignored).");
    121         }
    122         else {
    123         //
    124         if (param.getAttribute(GSXML.NAME_ATT) == INDEX_PARAM) {
    125             index = GSXML.getValue(param);
    126             System.out.println("Index: " + index);
    127         }
    128         }
    129 
    130         param = (Element) param.getNextSibling();
    131     }
     107    // Get the parameters of the request - no parameters at this stage
     108    //Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    132109
    133110    // Get the request content
    134     Element content = (Element) GSXML.getChildByTagName(request, GSXML.CONTENT_ELEM);
    135     if (content == null) {
    136         System.err.println("Error: DocumentContentRetrieve request had no content.\n");
     111   
     112    Element query_doc_list = (Element) GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     113    if (query_doc_list == null) {
     114        System.err.println("Error: DocumentContentRetrieve request specified no doc nodes.\n");
    137115        return result;
    138116    }
    139 
    140     Element doc_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
    141     result_content.appendChild(doc_list);
    142 
     117   
     118    Element doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     119    result.appendChild(doc_list);
     120   
    143121    // The location of the MG index and text files
    144122    String basedir = GSFile.collectionBaseDir(site_home_, cluster_name_)
    145                      + File.separatorChar;  // Needed by MG
     123                          + File.separatorChar;  // Needed by MG
    146124    String textdir = GSFile.collectionTextPath(cluster_name_);
    147     String indexpath = GSFile.collectionIndexPath(cluster_name_, index);
    148 
     125    // index is only needed to start up MG, not used so just use the default index
     126    String indexpath = GSFile.collectionIndexPath(cluster_name_, default_index_);
    149127    mg_src_.setIndex(indexpath);
    150 
     128   
    151129    // Get the documents
    152     String[] doc_ids = GSXML.getDocumentNameList(content);
     130    //String[] doc_ids = GSXML.getDocumentNameList(query_doc_list);
     131    String[] doc_ids = GSXML.getAttributeValuesFromList(query_doc_list,
     132                                GSXML.DOC_NODE_ID_ATT);
    153133    for (int i = 0; i < doc_ids.length; i++) {
    154134        String doc_id = doc_ids[i];
    155135        long doc_num = gdbm_src_.oid2Docnum(doc_id);
    156136        String doc_content = mg_src_.getDocument(basedir, textdir, doc_num);
    157 
    158         // For now, stick it in a text node - eventually should be parsed as xml??
    159         Element doc = GSXML.createDocumentElement(doc_, doc_id);
     137        // Stick it in a text node
     138        Element doc = doc_.createElement(GSXML.DOC_NODE_ELEM);
     139        doc.setAttribute(GSXML.DOC_NODE_ID_ATT, doc_id);
    160140        GSXML.addDocText(doc_, doc, doc_content);
    161141        doc_list.appendChild(doc);
Note: See TracChangeset for help on using the changeset viewer.