Changeset 8833


Ignore:
Timestamp:
2004-12-16T15:36:53+13:00 (19 years ago)
Author:
kjdon
Message:

query term highlighting and annotations are now controlled by interfaceCOnfig.xml. also now check for empty doc content

File:
1 edited

Legend:

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

    r8731 r8833  
    4848    /** if this is set to true, when a document is displayed, any annotation
    4949     * type services (enrich) will be offered to the user as well */
    50     protected static final boolean provide_annotations = false; //true;
    51 
    52 
     50    protected boolean provide_annotations = false;
     51   
     52    protected boolean highlight_query_terms = false;
     53
     54    public boolean configure() {
     55    super.configure();
     56    String highlight = (String)config_params.get("highlightQueryTerms");
     57    if (highlight != null && highlight.equals("true")) {
     58        highlight_query_terms = true;
     59    }
     60    String annotate = (String)config_params.get("displayAnnotationService");
     61    if (annotate != null && annotate.equals("true")) {
     62        provide_annotations = true;
     63    }
     64    return true;
     65    }
    5366    public Element process (Element message)
    5467    {
     
    326339    dc_request.appendChild(dc_param_list);
    327340
     341    // get the content
    328342    // the doc list for the content request is the same as the one for the structure request unless we want the whole document, in which case its the same as for the metadata request.
    329343    if (expand_document) {
     
    332346        dc_request.appendChild(basic_doc_list);
    333347    }
     348    System.err.println("request = "+converter.getString(dc_message));
    334349    Element dc_response_message = (Element) this.mr.process(dc_message);
    335350    Element dc_response_doc_list = (Element) GSXML.getNodeByPath(dc_response_message, path);
     
    339354        NodeList dc_response_docs = dc_response_doc_list.getChildNodes();
    340355        for (int i = 0; i < doc_nodes.getLength(); i++) {
    341         doc_nodes.item(i).appendChild(this.doc.importNode(GSXML.getChildByTagName((Element)dc_response_docs.item(i), "nodeContent"), true));
     356        Node content = GSXML.getChildByTagName((Element)dc_response_docs.item(i), "nodeContent");
     357        if (content != null) {
     358            doc_nodes.item(i).appendChild(this.doc.importNode(content, true));
     359        }
    342360        //GSXML.mergeMetadataLists(doc_nodes.item(i), dm_response_docs.item(i));
    343361        }
     
    347365        Element dc_response_doc = (Element) GSXML.getChildByTagName(dc_response_doc_list, GSXML.DOC_NODE_ELEM);
    348366        Element dc_response_doc_content = (Element) GSXML.getChildByTagName(dc_response_doc, GSXML.NODE_CONTENT_ELEM);
    349    
    350            
    351         boolean highlight_query_terms = true;
     367       
     368        if (dc_response_doc_content == null) {
     369        // no content to add
     370        return result;
     371        }
    352372        if (highlight_query_terms) {
    353373        dc_response_doc.removeChild(dc_response_doc_content);
    354        
     374       
    355375        dc_response_doc_content = highlightQueryTerms(request, dc_response_doc_content);
    356376        dc_response_doc.appendChild(dc_response_doc.getOwnerDocument().importNode(dc_response_doc_content, true));
     
    385405       
    386406        }
    387     }
     407    } // if provide_annotations
    388408
    389409   
Note: See TracChangeset for help on using the changeset viewer.