Changeset 14525 for greenstone3/trunk


Ignore:
Timestamp:
2007-09-17T15:27:38+12:00 (17 years ago)
Author:
qq6
Message:

adding href and rl values into the document node, if they can be identified from the params list

File:
1 edited

Legend:

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

    r13270 r14525  
    8383    // just in case there are some that need to get passed to the services
    8484    HashMap service_params = (HashMap)params.get("s0");
    85 
     85   
     86    String has_rl = null;
     87    String has_href = null;
     88    has_href = (String) params.get("href");//for an external link : get the href URL if it is existing in the params list
     89    has_rl = (String) params.get("rl");//for an external link : get the rl value if it is existing in the params list
    8690    String collection = (String) params.get(GSParams.COLLECTION);
    8791    String lang = request.getAttribute(GSXML.LANG_ATT);
    8892    String uid = request.getAttribute(GSXML.USER_ID_ATT);
    8993    String document_name = (String) params.get(GSParams.DOCUMENT);
    90     if (document_name == null || document_name.equals("")) {
     94    if ((document_name == null || document_name.equals("")) && (has_href == null || has_href.equals(""))) {
    9195        logger.error("no document specified!");
    9296        return result;
     
    141145    Element current_doc = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    142146    basic_doc_list.appendChild(current_doc);
    143     current_doc.setAttribute(GSXML.NODE_ID_ATT, document_name);
    144    
     147    if (document_name.length()!=0){
     148        current_doc.setAttribute(GSXML.NODE_ID_ATT, document_name);
     149    }else if (has_href.length()!=0){
     150        current_doc.setAttribute(GSXML.NODE_ID_ATT, has_href);
     151        current_doc.setAttribute("externalURL", has_rl);
     152    }
     153
    145154    // Create a parameter list to specify the required structure information
    146155    Element ds_param_list = this.doc.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     
    239248        // no structure nodes, so put in a dummy doc node
    240249        Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    241         doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name);
     250        if (document_name.length()!=0){
     251            doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name);
     252        }else if (has_href.length()!=0){
     253            doc_node.setAttribute(GSXML.NODE_ID_ATT, has_href);
     254            doc_node.setAttribute("externalURL", has_rl);
     255        }
    242256        the_document.appendChild(doc_node);
    243257        has_dummy = true;
     
    247261        // no structure request, so just put in a dummy doc node
    248262        Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    249         doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name);
     263        if (document_name.length()!=0){
     264        doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name);
     265        }else if (has_href.length()!=0){
     266        doc_node.setAttribute(GSXML.NODE_ID_ATT, has_href);
     267        doc_node.setAttribute("externalURL", has_rl);
     268        }
    250269        the_document.appendChild(doc_node);
    251270        has_dummy = true;
     
    312331    Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
    313332    // the node we want is the root document node
    314     doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name+".rt");
     333    if (document_name.length()!=0){
     334        doc_node.setAttribute(GSXML.NODE_ID_ATT, document_name+".rt");
     335    }else if (has_href.length()!=0){
     336        doc_node.setAttribute(GSXML.NODE_ID_ATT, has_href+".rt");
     337        doc_node.setAttribute("externalURL", has_rl);
     338    }
    315339    doc_list.appendChild(doc_node);
    316340    Element dm_response_message = (Element) this.mr.process(dm_message);
     
    374398        }
    375399    } else {
    376        
    377400        //path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM);
    378401        Element dc_response_doc = (Element) GSXML.getChildByTagName(dc_response_doc_list, GSXML.DOC_NODE_ELEM);
    379402        Element dc_response_doc_content = (Element) GSXML.getChildByTagName(dc_response_doc, GSXML.NODE_CONTENT_ELEM);
     403        Element dc_response_doc_external = (Element) GSXML.getChildByTagName(dc_response_doc, "external");
    380404       
    381405        if (dc_response_doc_content == null) {
    382406        // no content to add
     407        if (dc_response_doc_external !=null){
     408            String modified_doc_id = dc_response_doc.getAttribute(GSXML.NODE_ID_ATT);
     409           
     410            the_document.setAttribute("selectedNode", modified_doc_id);
     411            the_document.setAttribute("external", dc_response_doc_external.getAttribute("external_link"));
     412        }
    383413        return result;
    384414        }
Note: See TracChangeset for help on using the changeset viewer.