Changeset 3863


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

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

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/action
Files:
2 edited

Legend:

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

    r3817 r3863  
    7777    ds_param.setAttribute(GSXML.VALUE_ATT, "children");
    7878
    79     // Create a content section to store the list of documents we are interested in
    80     Element ds_content = doc_.createElement(GSXML.CONTENT_ELEM);
    81     ds_request.appendChild(ds_content);
    82     Element ds_doc_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
    83     ds_content.appendChild(ds_doc_list);
    84     Element ds_doc = doc_.createElement(GSXML.DOCUMENT_ELEM);
     79    // create a doc_node_list and put in the doc_node that we are interested in
     80    Element ds_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     81    ds_request.appendChild(ds_doc_list);
     82    Element ds_doc = doc_.createElement(GSXML.DOC_NODE_ELEM);
    8583    ds_doc_list.appendChild(ds_doc);
    86     ds_doc.setAttribute(GSXML.NAME_ATT, document_name);
    87 
     84    ds_doc.setAttribute(GSXML.DOC_NODE_ID_ATT, document_name);
     85   
    8886    // Process the document structure retrieve message
    8987    // System.out.println("(DocumentAction) Structure request:\n" + converter_.getString(ds_message));
    90     Element ds_response = (Element) mr_.process(ds_message);
    91     // System.out.println("(DocumentAction) Structure response:\n" + converter_.getString(ds_response));
    92 
    93     Element ds_response_content = (Element) GSXML.getNodeByPath(ds_response, "response/content");
    94     Element ds_response_doc_list = (Element) GSXML.getNodeByPath(ds_response_content, "documentList");
    95     Element ds_response_document = (Element) GSXML.getNodeByPath(ds_response_doc_list, "document");
     88    Element ds_response_message = (Element) mr_.process(ds_message);
     89    // System.out.println("(DocumentAction) Structure response:\n" + converter_.getString(ds_response_message));
     90
     91    // get the doc_node bit
     92    String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     93    path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM);
     94    path = GSPath.appendLink(path, GSXML.DOC_NODE_STRUCTURE_ELEM);
     95    Element ds_response_structure = (Element) GSXML.getNodeByPath(ds_response_message, path);
     96
     97    // the_document is where all the extra info is added into, to be returned in the page
     98    Element the_document = doc_.createElement(GSXML.DOCUMENT_ELEM);
     99    // add the contents of the structure bit into the_document
     100    NodeList structs = ds_response_structure.getChildNodes();
     101    for (int i=0; i<structs.getLength();i++) {
     102        the_document.appendChild(doc_.importNode(structs.item(i), true));
     103    }
     104    //Element ds_response = (Element) GSXML.getChildByTagName(ds_response_message, GSXML.RESPONSE_ELEM);
     105    //Element ds_response_doc_list = (Element) GSXML.getChildByTagName(ds_response, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     106    //Element ds_response_document = (Element) GSXML.getChildByTagName(ds_response_doc_list, GSXML.DOC_NODE_ELEM);
    96107
    97108    // Detach the document from the list, remove the list, and add the document back
    98     ds_response_content.removeChild(ds_response_doc_list);
    99     ds_response_content.appendChild(ds_response_document);
     109    // ds_response is the re
     110    //ds_response.removeChild(ds_response_doc_list);
     111    //ds_response.appendChild(ds_response_document);
    100112
    101113
     
    110122
    111123    // Create a parameter list to specify the required metadata information
     124    // for now get Title
    112125    Element dm_param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    113126    dm_request.appendChild(dm_param_list);
     
    117130    dm_param.setAttribute(GSXML.VALUE_ATT, "Title");
    118131
    119     // Create a content section to store the list of documents we are interested in
    120     Element dm_content = doc_.createElement(GSXML.CONTENT_ELEM);
    121     dm_request.appendChild(dm_content);
    122     Element dm_doc_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
    123     dm_content.appendChild(dm_doc_list);
    124 
    125     // Get the title metadata of the document nodes
    126     NodeList doc_nodes = ds_response_document.getElementsByTagName(GSXML.DOC_NODE_ELEM);
     132    // create the doc node list for the metadata request
     133    Element dm_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     134    dm_request.appendChild(dm_doc_list);
     135
     136    // Add each node from the structure response into the metadata request
     137    NodeList doc_nodes = the_document.getElementsByTagName(GSXML.DOC_NODE_ELEM);
    127138    for (int i = 0; i < doc_nodes.getLength(); i++) {
    128139        Element doc_node = (Element) doc_nodes.item(i);
     
    138149
    139150    // System.out.println("(DocumentAction) Metadata request:\n" + converter_.getString(dm_request));
    140     Element dm_response = (Element) mr_.process(dm_message);
     151    Element dm_response_message = (Element) mr_.process(dm_message);
    141152    // System.out.println("(DocumentAction) Metadata response:\n" + converter_.getString(dm_response));
    142153
    143     Element dm_response_content = (Element) GSXML.getNodeByPath(dm_response, "response/content");
    144     Element dm_response_doc_list = (Element) GSXML.getNodeByPath(dm_response_content, "documentList");
     154    path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     155    Element dm_response_doc_list = (Element) GSXML.getNodeByPath(dm_response_message, path);
     156
     157    //Element dm_response_content = (Element) GSXML.getNodeByPath(dm_response, "response/content");
     158    //Element dm_response_doc_list = (Element) GSXML.getNodeByPath(dm_response_content, "documentList");
    145159
    146160    // Merge the metadata with the structure information
     
    160174    dc_request.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT));
    161175
    162     // Create a parameter list to specify the request parameters
     176    // Create a parameter list to specify the request parameters - empty for now
    163177    Element dc_param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    164178    dc_request.appendChild(dc_param_list);
    165179
    166     // Create a content section to store the list of documents we are interested in
    167     Element dc_content = doc_.createElement(GSXML.CONTENT_ELEM);
    168     dc_request.appendChild(dc_content);
    169     Element dc_doc_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
    170     dc_content.appendChild(dc_doc_list);
    171     Element dc_doc = doc_.createElement(GSXML.DOCUMENT_ELEM);
    172     dc_doc_list.appendChild(dc_doc);
    173     dc_doc.setAttribute(GSXML.NAME_ATT, document_name);
     180    // the doc list for the content request is the same as the one for the structure request
     181    dc_request.appendChild(ds_doc_list);
     182//      Element dc_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     183//      dc_request.appendChild(dc_doc_list);
     184//      Element dc_doc = doc_.createElement(GSXML.DOC_NODE_ELEM);
     185//      dc_doc_list.appendChild(dc_doc);
     186//      dc_doc.setAttribute(GSXML.DOC_NODE_ID, document_name);
    174187
    175188    // System.out.println("(DocumentAction) Content request:\n" + converter_.getString(dc_request));
    176     Element dc_response = (Element) mr_.process(dc_message);
     189    Element dc_response_message = (Element) mr_.process(dc_message);
    177190    // System.out.println("(DocumentAction) Content response:\n" + converter_.getString(dc_response));
    178 
    179     Element dc_response_doc_content = (Element) GSXML.getNodeByPath(dc_response, "response/content/documentList/document/content");
     191   
     192    path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM);
     193    path = GSPath.appendLink(path, GSXML.DOC_NODE_CONTENT_ELEM);
     194    Element dc_response_doc_content = (Element) GSXML.getNodeByPath(dc_response_message, path);
    180195
    181196    // Merge the document content with the metadata and structure information
     
    185200        String dc_doc_id = doc_node_id.getNodeValue();
    186201        if (dc_doc_id == document_name) {
    187         doc_node.appendChild(dc_response_doc_content);
     202        doc_node.appendChild(doc_.importNode(dc_response_doc_content, true));
    188203        break;
    189204        }
    190205    }
    191 
    192206
    193207    // Create the return page tree
     
    203217    Element response = doc_.createElement(GSXML.RESPONSE_ELEM);
    204218    page.appendChild(response);
    205     response.appendChild(doc_.importNode(ds_response_content, true));
    206 
     219    response.appendChild(the_document);
     220   
    207221    // System.out.println("Finished page: " + converter_.getString(page));
    208 
    209 
     222   
     223   
    210224    // Finally, process using the stylesheet, and return
    211225    String stylesheet = GSFile.stylesheetFile(config_, "document.xsl");
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r3802 r3863  
    166166    // check that there are some documents - for now check the list, but later should use a numdocs metadata elem
    167167    path = GSXML.RESPONSE_ELEM;
    168     path = GSPath.appendLink(path, GSXML.CONTENT_ELEM);
    169     path = GSPath.appendLink(path, GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER);
     168    //path = GSPath.appendLink(path, GSXML.CONTENT_ELEM);
     169    path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    170170   
    171171    Element document_list = (Element)GSXML.getNodeByPath(mr_query_response,
     
    202202    dm_param.setAttribute(GSXML.VALUE_ATT, "Title");
    203203
    204     Element meta_content = doc_.createElement(GSXML.CONTENT_ELEM);
    205     mr_metadata_request.appendChild(meta_content);
     204    //Element meta_content = doc_.createElement(GSXML.CONTENT_ELEM);
     205    //mr_metadata_request.appendChild(meta_content);
    206206   
    207207    // the first part of the content is the doc list
    208     meta_content.appendChild(doc_.importNode(document_list, true));
    209    
     208    //meta_content.appendChild(doc_.importNode(document_list, true));
     209    mr_metadata_request.appendChild(doc_.importNode(document_list, true));
    210210    // System.out.println("Metadata request: " + converter_.getString(mr_metadata_message));
    211211    Element mr_metadata_response = (Element)mr_.process(mr_metadata_message);
     
    219219    // If there is some metadata about the query results, add it in
    220220    if (query_term_info_list != null) {
    221         Element result_content = (Element) GSXML.getChildByTagName(result_response,
    222                                        GSXML.CONTENT_ELEM);
    223         result_content.appendChild(query_term_info_list);
     221        //Element result_content = (Element) GSXML.getChildByTagName(result_response, GSXML.CONTENT_ELEM);
     222        //result_content.appendChild(query_term_info_list);
     223        result_response.appendChild(query_term_info_list);
    224224    }
    225225
    226226    page.appendChild(doc_.importNode(result_response, true));
    227227   
    228     // System.out.println("XMLTransformer input: " + converter_.getString(page));
     228    System.out.println("XMLTransformer input: " + converter_.getString(page));
    229229   
    230230    // output the page
Note: See TracChangeset for help on using the changeset viewer.