Changeset 14529 for greenstone3


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

processing the external links

File:
1 edited

Legend:

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

    r14225 r14529  
    2828import org.greenstone.gsdl3.util.MacroResolver;
    2929import org.greenstone.gsdl3.util.OID;
     30import org.greenstone.gsdl3.util.GlobalProperties;
     31import org.greenstone.gsdl3.util.GSConstants;
    3032
    3133// XML classes
     
    138140        }
    139141    }
    140 
     142     
    141143    if (macro_resolver != null) {
    142         macro_resolver.setSiteDetails(this.site_http_address, this.cluster_name);
     144        macro_resolver.setSiteDetails(this.site_http_address, this.cluster_name, this.getLibraryName());
    143145        // set up the macro resolver
    144146        Element replacement_elem = (Element)GSXML.getChildByTagName(extra_info, "replaceList");
     
    183185        return result;
    184186    }
    185 
    186187    // Get the parameters of the request
    187188    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     
    238239
    239240    // Whew, now we have checked (almost) all the syntax of the request, now we can process it.
    240    
    241241    for (int i = 0; i < request_nodes.getLength(); i++) {
    242242        Element request_node = (Element) request_nodes.item(i);
    243243        String node_id = request_node.getAttribute(GSXML.NODE_ID_ATT);
    244 
    245         if (external_id) {
    246         // can we have .pr etc extensions with external ids?
    247         node_id = translateExternalId(node_id);
    248         } else if (idNeedsTranslating(node_id)) {
    249         node_id = translateId(node_id);
    250         }       
     244       
     245        boolean is_external_link = false;
     246        if (!node_id.startsWith("HASH")){   
     247        if (node_id.endsWith(".rt")){
     248            node_id = getHrefOID(node_id.substring(0,node_id.length()-3));
     249            if (node_id!=null){
     250            node_id += ".rt";
     251            }else{
     252            is_external_link = true;
     253            }
     254        }else{
     255            node_id = getHrefOID(node_id);
     256            if (node_id==null){
     257            is_external_link = true;
     258            }
     259        }
     260        }
     261        if (!is_external_link){
     262        if (external_id) {
     263            // can we have .pr etc extensions with external ids?
     264            node_id = translateExternalId(node_id);
     265        } else if (idNeedsTranslating(node_id)) {
     266            node_id = translateId(node_id);
     267        }
     268        }
     269       
    251270        if (node_id == null) {
    252271        continue;
    253272        }
    254         try {
    255         Element metadata_list = getMetadataList(node_id, all_metadata, metadata_names_list);
    256         request_node.appendChild(metadata_list);
    257         } catch (GSException e) {       
    258         GSXML.addError(this.doc, result, e.getMessage(), e.getType());
    259         if (e.getType().equals(GSXML.ERROR_TYPE_SYSTEM)) {
    260             // there is no point trying any others
    261             return result;
    262         }
    263         }
     273        if (!is_external_link){
     274        try {
     275            Element metadata_list = getMetadataList(node_id, all_metadata, metadata_names_list);
     276            request_node.appendChild(metadata_list);
     277        } catch (GSException e) {       
     278            GSXML.addError(this.doc, result, e.getMessage(), e.getType());
     279            if (e.getType().equals(GSXML.ERROR_TYPE_SYSTEM)) {
     280            // there is no point trying any others
     281            return result;
     282            }
     283        }
     284        }else{
     285        request_node.setAttribute("external_link",request_node.getAttribute(GSXML.NODE_ID_ATT));
     286        }
    264287    }
    265288       
     
    366389        Element doc = (Element) node_list.item(i);
    367390        String doc_id = doc.getAttribute(GSXML.NODE_ID_ATT);
    368         if (external_id) {
    369         doc_id = translateExternalId(doc_id);
    370         doc.setAttribute(GSXML.NODE_ID_ATT, doc_id);
    371         } else if (idNeedsTranslating(doc_id)) {
    372         doc_id = translateId(doc_id);   
    373         doc.setAttribute(GSXML.NODE_ID_ATT, doc_id);
    374         }
     391        String is_external=doc.getAttribute("externalURL");
     392
     393        boolean is_external_link = false;
     394        if (is_external.equals("0")) {is_external_link = true;}
     395        if (!doc_id.startsWith("HASH") && !is_external_link){
     396        if (doc_id.endsWith(".rt")){
     397            doc_id = getHrefOID(doc_id.substring(0,doc_id.length()-3));
     398            if (doc_id!=null){
     399            doc_id += ".rt";
     400            // }else{
     401            //  is_external_link = true;
     402            // }
     403            }else{
     404            doc_id = getHrefOID(doc_id);
     405            //   if (doc_id==null){
     406            //  is_external_link = true;
     407            }
     408        }
     409        }
     410       
     411        if (!is_external_link){
     412        if (external_id) {
     413            doc_id = translateExternalId(doc_id);
     414            doc.setAttribute(GSXML.NODE_ID_ATT, doc_id);
     415        } else if (idNeedsTranslating(doc_id)) {
     416            doc_id = translateId(doc_id);   
     417            doc.setAttribute(GSXML.NODE_ID_ATT, doc_id);
     418        }
     419       
    375420        if (doc_id == null) {
    376421        continue;
     
    461506        }
    462507        } // if want structure
     508
     509        }else{
     510        Element external_link_elem = this.doc.createElement("external");
     511        external_link_elem.setAttribute("external_link",doc.getAttribute(GSXML.NODE_ID_ATT));
     512        doc.appendChild(external_link_elem);
     513        }// if is_external_link
    463514    } // for each doc
    464515    return result;
     
    501552    String[] doc_ids = GSXML.getAttributeValuesFromList(query_doc_list,
    502553                                GSXML.NODE_ID_ATT);
     554    String[] is_externals=GSXML.getAttributeValuesFromList(query_doc_list,"externalURL");
     555
    503556    for (int i = 0; i < doc_ids.length; i++) {
    504557        String doc_id = doc_ids[i];
     558        String is_external=is_externals[i];
     559        boolean is_external_link=false;
     560        if (is_external.equals("0")){is_external_link = true;}
     561        if (!doc_id.startsWith("HASH") && !is_external_link){
     562        if (doc_id.endsWith(".rt")){
     563            String find_doc_id = getHrefOID(doc_id.substring(0,doc_id.length()-3));
     564            if (find_doc_id!=null){
     565            doc_id = doc_id + ".rt";
     566            //}else{
     567            //is_external_link=true;   
     568            }
     569        }else {
     570            String find_doc_id = getHrefOID(doc_id);
     571            if (find_doc_id!=null){
     572                doc_id = find_doc_id;
     573            //}else{
     574            //is_external_link=true;
     575            }
     576        }
     577        }
     578
     579        if (!is_external_link){
    505580        // Create the document node
    506581        Element doc = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     
    525600        return result;
    526601       
     602        }
     603        }else{
     604         Element doc = this.doc.createElement(GSXML.DOC_NODE_ELEM);
     605         doc.setAttribute(GSXML.NODE_ID_ATT, doc_id);
     606         //doc.setAttribute("external_link", doc_id);
     607         Element external_link_elem = this.doc.createElement("external");
     608         external_link_elem.setAttribute("external_link",doc_id);
     609         doc.appendChild(external_link_elem);
     610
     611         doc_list.appendChild(doc);
    527612        }
    528613    }
     
    701786     */
    702787    abstract protected String getStructureInfo(String doc_id, String info_type);
     788
     789    protected String getHrefOID(String href_url){
     790    return null;
     791    }
    703792   
    704793}   
Note: See TracChangeset for help on using the changeset viewer.