Changeset 3799

Show
Ignore:
Timestamp:
05.03.2003 14:00:32 (17 years ago)
Author:
mdewsnip
Message:

Modified to inherit from GS2Retrieve.java base class. Only implements search engine specific DocumentContentRetrieve? service.

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/service
Files:
2 modified

Legend:

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

    r3678 r3799  
    1919package org.greenstone.gsdl3.service; 
    2020 
    21 // greenstone classes 
     21 
     22// Greenstone classes 
    2223import org.greenstone.mgpp.*; 
    23 import org.greenstone.gdbm.*; 
    2424import org.greenstone.gsdl3.util.*; 
    2525 
    26 // xml classes 
    27 import org.w3c.dom.Document;  
    28 import org.w3c.dom.Node;  
    29 import org.w3c.dom.Text;  
     26// XML classes 
    3027import org.w3c.dom.Element;  
    31 import org.w3c.dom.NodeList;  
    3228 
    33 // general java classes 
    34 import java.util.HashMap; 
    35 import java.util.Vector; 
    36 import java.util.Set; 
    37 import java.util.Map; 
    38 import java.util.Iterator; 
    39 import java.util.Locale; 
    4029 
    4130/** 
     
    4736 */ 
    4837public class GS2MGPPRetrieve  
    49     extends ServiceRack { 
     38    extends GS2Retrieve { 
    5039 
    51     // these strings must match what is found in the properties file 
    52     // the services on offer 
    53     private static final String DOCUMENT_RETRIEVE_SERVICE = "DocumentRetrieve"; 
    54     private static final String METADATA_RETRIEVE_SERVICE = "MetadataRetrieve"; 
    55  
    56     // params used 
     40    // Parameters used 
    5741    private static final String LEVEL_PARAM = "level"; 
    5842 
    59     // elements used in the config file that are specific to this class 
     43    // Elements used in the config file that are specific to this class 
    6044    private static final String DEFAULT_LEVEL_ELEM = "defaultLevel"; 
     45 
     46    private MGPPWrapper mgpp_src_ = null; 
    6147     
    62     private MGPPWrapper mgpp_src_=null; 
    63     private GDBMWrapper gdbm_src_=null; 
    64      
    65     private String default_level_=null; 
     48    private String default_level_ = null; 
    6649 
    67     private Element config_info_ = null; 
    6850 
    69     public GS2MGPPRetrieve() { 
     51    /** constructor */ 
     52    public GS2MGPPRetrieve() 
     53    { 
     54    System.out.println("Constructing GS2MGPPRetrieve..."); 
    7055    mgpp_src_ = new MGPPWrapper(); 
    71     gdbm_src_ = new GDBMWrapper(); 
     56    } 
    7257 
    73     } 
    74      
     58 
    7559    /** configure this service */ 
    76     public boolean configure(Element info) { 
     60    public boolean configure(Element info) 
     61    { 
     62    // Do specific configuration 
     63    System.out.println("Configuring GS2MGPPRetrieve..."); 
    7764 
    78     System.out.println("configuring GS2MGPPRetrieve"); 
    79     config_info_ = info; 
    80  
    81     // get the default level out of <defaultLevel> 
    82     Element def = (Element)GSXML.getChildByTagName(info, DEFAULT_LEVEL_ELEM); 
    83     if (def !=null) { 
     65    // Get the default level out of <defaultLevel> (buildConfig.xml) 
     66    Element def = (Element) GSXML.getChildByTagName(info, DEFAULT_LEVEL_ELEM); 
     67    if (def != null) { 
    8468        default_level_ = def.getAttribute(GSXML.NAME_ATT); 
    8569    } 
    86     if (default_level_==null||default_level_.equals("")) { 
     70    if (default_level_ == null || default_level_.equals("")) { 
    8771        System.err.println("Error: default level not specified!"); 
    8872        return false; 
    8973    } 
     74    System.out.println("Default level: " + default_level_); 
    9075 
    91     // set up which services are available for this collection 
    92     Element e = null; 
    93     // these entries should reflect the build config file - some services may not be available depending on how the collection was built. 
    94  
    95     // set up short_service_info_ - for now just has name and type 
    96     e = doc_.createElement(GSXML.SERVICE_ELEM); 
    97     e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    98     e.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE); 
    99     short_service_info_.appendChild(e); 
    100  
    101     e = doc_.createElement(GSXML.SERVICE_ELEM); 
    102     e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    103     e.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE); 
    104     short_service_info_.appendChild(e); 
    105  
    106     // set up service_info_map_ - for now, just has the same elements as above 
    107     // should have full details about each service incl params lists etc. 
    108     // do the text query one - for now a static list. later use buildcfg.xml values to dynamically change this 
    109     e = doc_.createElement(GSXML.SERVICE_ELEM); 
    110     e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    111     e.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE); 
    112     service_info_map_.put(DOCUMENT_RETRIEVE_SERVICE, e); 
    113      
    114     e = doc_.createElement(GSXML.SERVICE_ELEM); 
    115     e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    116     e.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE); 
    117     service_info_map_.put(METADATA_RETRIEVE_SERVICE, e); 
    118  
    119     if (gdbm_src_.openDatabase(GSFile.GDBMDatabaseFile(site_home_, cluster_name_), GDBMWrapper.READER)) { 
    120         return true; 
    121     } 
    122     else { 
    123         System.err.println("couldn't open gdbm database!"); 
    124         return false; 
    125     } 
    126     } 
    127    
    128  
    129     /** creates a display element containing all the text strings needed to display the service page, in the language specified  
    130      * these retrieval services dont get displayed to the users - they are only used internally by the actions. so this returns an empty display element*/ 
    131     protected Element createServiceDisplay(String service, String lang) { 
    132     return doc_.createElement(GSXML.DISPLAY_ELEM); 
     76    // Do generic configuration 
     77    return super.configure(info); 
    13378    } 
    13479 
    13580 
    136     /** retrieve a document */ 
    137     protected Element processDocumentRetrieve(Element request) { 
    138  
    139     // where the mgpp text files are 
    140     String basedir = GSFile.collectionBaseDir(site_home_,  
    141                           cluster_name_); 
    142     String textdir = GSFile.collectionTextPath(cluster_name_); 
    143  
    144     // an empty result 
    145     Element result = doc_.createElement(GSXML.RESPONSE_ELEM); 
    146     String from = GSPath.appendLink(cluster_name_, DOCUMENT_RETRIEVE_SERVICE); 
    147     result.setAttribute(GSXML.FROM_ATT, from); 
    148     result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY); 
    149     Element result_doc = doc_.createElement(GSXML.CONTENT_ELEM); 
    150     result.appendChild(result_doc); 
    151      
    152     // get param list and content  
    153     Element param_elem=null; 
    154     Element content_elem=null; 
    155     Node n = request.getFirstChild(); 
    156     while (n!=null) { 
    157       String node_name = n.getNodeName(); 
    158       if (node_name.equals(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER)) { 
    159           param_elem = (Element)n; 
    160       } else if (node_name.equals(GSXML.CONTENT_ELEM)) { 
    161           content_elem = (Element)n; 
    162       } 
    163       n = n.getNextSibling(); 
    164     } 
    165  
    166     if (param_elem==null || content_elem==null) { 
    167         System.err.println("GS2MGPPRetrieve: malformed request sent to DocumentRetrieve service"); 
    168         return result; // empty result 
    169     } 
    170      
    171     HashMap params = GSXML.extractParams(param_elem); 
    172  
    173     // get docs from mgpp 
    174     String level = (String)params.get(LEVEL_PARAM); // level at which to retrieve a doc 
    175     if (level==null) { 
    176         level=default_level_; 
    177     } 
    178     // get the text for each doc in the list 
    179     String []ids = GSXML.getDocumentNameList(content_elem); 
    180     for (int j=0; j<ids.length; j++) { 
    181         long real_num = gdbm_src_.oid2Docnum(ids[j]); 
    182         String document = mgpp_src_.getDocument(basedir, textdir,  level, real_num); 
    183         // for now, stick it in a text node - eventually should be parsed as xml?? 
    184         // something funny with the doc -  
    185         Element new_doc = GSXML.createDocumentElement(doc_, ids[j]); 
    186         GSXML.addDocText(doc_, new_doc, document); 
    187         result_doc.appendChild(new_doc); 
    188     } 
    189     return result; 
    190     } 
    191  
    192     /** retrieve metadata */ 
    193     protected Element processMetadataRetrieve(Element request) { 
    194     Element result = doc_.createElement(GSXML.RESPONSE_ELEM); 
    195     String from = GSPath.appendLink(cluster_name_, METADATA_RETRIEVE_SERVICE); 
    196     result.setAttribute(GSXML.FROM_ATT, from); 
    197     result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY); 
    198     Element result_content = doc_.createElement(GSXML.CONTENT_ELEM); 
    199     result.appendChild(result_content); 
    200     Element document_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 
    201     result_content.appendChild(document_list); 
    202     // get the metadata 
    203      
    204     Element content = (Element)request.getElementsByTagName(GSXML.CONTENT_ELEM).item(0); 
    205     if (content==null) { 
    206         // error: query had no content!! - should make an error message 
    207         return result; 
    208     } 
    209     String []metas = GSXML.getMetaNameList(content); 
    210     String []ids = GSXML.getDocumentNameList(content); 
    211     for (int j=0; j<ids.length; j++) { // for each document 
    212         Element doc = GSXML.createDocumentElement(doc_, ids[j]); 
    213         Element list = GSXML.addMetaList(doc_, doc); 
    214         DBInfo info = gdbm_src_.getInfo(ids[j]); 
    215         for (int m=0; m<metas.length; m++) { 
    216         String value = info.getInfo(metas[m]); 
    217         GSXML.addMetadata(doc_, list, metas[m], value); 
    218         } 
    219         document_list.appendChild(doc); 
    220     } 
    221     return result; 
     81    /** Retrieve the structure of a document */ 
     82    protected Element processDocumentStructureRetrieve(Element request) 
     83    { 
     84    return super.processDocumentStructureRetrieve(request); 
    22285    } 
    22386 
    22487 
     88    /** Retrieve metadata associated with a document */ 
     89    protected Element processDocumentMetadataRetrieve(Element request) 
     90    { 
     91    return super.processDocumentMetadataRetrieve(request); 
     92    } 
    22593 
    22694 
     95    /** Retrieve the content of a document */ 
     96    protected Element processDocumentContentRetrieve(Element request) 
     97    { 
     98    // Create a new (empty) result message 
     99    Element result = doc_.createElement(GSXML.RESPONSE_ELEM); 
     100    String from = GSPath.appendLink(cluster_name_, DOCUMENT_CONTENT_RETRIEVE_SERVICE); 
     101    result.setAttribute(GSXML.FROM_ATT, from); 
     102    result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     103    Element result_content = doc_.createElement(GSXML.CONTENT_ELEM); 
     104    result.appendChild(result_content); 
     105 
     106    // Get the parameters of the request 
     107    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
     108    if (param_list == null) { 
     109        System.err.println("GS2Retrieve, DocumentContentRetrieve Error: missing paramList.\n"); 
     110        return result;  // Return the empty result 
     111    } 
     112 
     113    String level = default_level_; 
     114 
     115    // Process the request parameters 
     116    Element param = (Element) param_list.getFirstChild(); 
     117    while (param != null) { 
     118        if (!param.getNodeName().equals(GSXML.PARAM_ELEM)) { 
     119        System.err.println("Warning: Non-param in paramList (ignored)."); 
     120        } 
     121        else { 
     122        // 
     123        if (param.getAttribute(GSXML.NAME_ATT) == LEVEL_PARAM) { 
     124            level = GSXML.getValue(param); 
     125            System.out.println("Level: " + level); 
     126        } 
     127        } 
     128 
     129        param = (Element) param.getNextSibling(); 
     130    } 
     131 
     132    // Get the request content 
     133    Element content = (Element) GSXML.getChildByTagName(request, GSXML.CONTENT_ELEM); 
     134    if (content == null) { 
     135        System.err.println("Error: DocumentContentRetrieve request had no content.\n"); 
     136        return result; 
     137    } 
     138 
     139    Element doc_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 
     140    result_content.appendChild(doc_list); 
     141 
     142    // The location of the MGPP text files 
     143    String basedir = GSFile.collectionBaseDir(site_home_, cluster_name_); 
     144    String textdir = GSFile.collectionTextPath(cluster_name_); 
     145    System.out.println("Base directory: " + basedir); 
     146    System.out.println("Text directory: " + textdir); 
     147 
     148    // Get the documents 
     149    String[] doc_ids = GSXML.getDocumentNameList(content); 
     150    for (int i = 0; i < doc_ids.length; i++) { 
     151        String doc_id = doc_ids[i]; 
     152        System.out.println("Retrieving content of " + doc_id + "..."); 
     153 
     154        long doc_num = gdbm_src_.oid2Docnum(doc_id); 
     155        String doc_content = mgpp_src_.getDocument(basedir, textdir, level, doc_num); 
     156 
     157        // For now, stick it in a text node - eventually should be parsed as xml?? 
     158        Element doc = GSXML.createDocumentElement(doc_, doc_id); 
     159        GSXML.addDocText(doc_, doc, doc_content); 
     160        doc_list.appendChild(doc); 
     161    } 
     162 
     163    return result; 
     164    } 
    227165} 
    228   
    229  
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java

    r3754 r3799  
    1919package org.greenstone.gsdl3.service; 
    2020 
    21 // greenstone classes 
     21 
     22// Greenstone classes 
    2223import org.greenstone.mg.*; 
    23 import org.greenstone.gdbm.*; 
    2424import org.greenstone.gsdl3.util.*; 
    2525 
    26 // xml classes 
    27 import org.w3c.dom.CDATASection; 
    28 import org.w3c.dom.Document;  
    29 import org.w3c.dom.Element;  
    30 import org.w3c.dom.Node;  
    31 import org.w3c.dom.NodeList;  
    32 import org.w3c.dom.Text;  
     26// XML classes 
     27import org.w3c.dom.Element; 
    3328 
    34 // general Java classes 
     29// General Java classes 
    3530import java.io.File; 
    36 import java.util.HashMap; 
     31 
    3732 
    3833/** 
     
    4338 
    4439public class GS2MGRetrieve 
    45     extends ServiceRack { 
     40    extends GS2Retrieve { 
    4641 
    47     // the services on offer 
    48     // these strings must match what is found in the properties file 
    49     private static final String DOCUMENT_RETRIEVE_SERVICE = "DocumentRetrieve"; 
    50     private static final String METADATA_RETRIEVE_SERVICE = "MetadataRetrieve"; 
    51  
    52     // params used 
     42    // Parameters used 
    5343    private static final String INDEX_PARAM = "index"; 
    5444 
    55     // elements used in the config file that are specific to this class 
     45    // Elements used in the config file that are specific to this class 
    5646    private static final String DEFAULT_INDEX_ELEM = "defaultIndex"; 
    5747 
    5848    private MGWrapper mg_src_ = null; 
    59     private GDBMWrapper gdbm_src_ = null; 
    60      
     49 
    6150    private String default_index_ = null; 
    6251 
    6352 
    6453    /** constructor */ 
    65     public GS2MGRetrieve() { 
     54    public GS2MGRetrieve() 
     55    { 
     56    System.out.println("Constructing GS2MGRetrieve..."); 
    6657    mg_src_ = new MGWrapper(); 
    67     gdbm_src_ = new GDBMWrapper(); 
    6858    } 
     59 
    6960 
    7061    /** configure this service */ 
    7162    public boolean configure(Element info) 
    7263    { 
    73     System.out.println("configuring GS2MGRetrieve"); 
     64    // Do specific configuration 
     65    System.out.println("Configuring GS2MGRetrieve..."); 
    7466 
    75     // get the default index out of <defaultIndex> (buildConfig.xml) 
     67    // Get the default index out of <defaultIndex> (buildConfig.xml) 
    7668    Element def = (Element) GSXML.getChildByTagName(info, DEFAULT_INDEX_ELEM); 
    7769    if (def != null) { 
     
    8476    System.out.println("Default index: " + default_index_); 
    8577 
    86     Element e = null; 
    87     // these entries should reflect the build config file - some services may not be available depending on how the colleciton was built. 
    88     // set up short_service_info_ - for now just has name and type 
    89     e = doc_.createElement(GSXML.SERVICE_ELEM); 
    90     e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    91     e.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE); 
    92     short_service_info_.appendChild(e); 
    93  
    94     e = doc_.createElement(GSXML.SERVICE_ELEM); 
    95     e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    96     e.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE); 
    97     short_service_info_.appendChild(e); 
    98  
    99     // set up service_info_map_ - for now, just has the same elements as above 
    100     // should have full details about each service incl params lists etc. 
    101     e = doc_.createElement(GSXML.SERVICE_ELEM); 
    102     e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    103     e.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE); 
    104     service_info_map_.put(DOCUMENT_RETRIEVE_SERVICE, e); 
    105  
    106     e = doc_.createElement(GSXML.SERVICE_ELEM); 
    107     e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_RETRIEVE); 
    108     e.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE); 
    109     service_info_map_.put(METADATA_RETRIEVE_SERVICE, e); 
    110  
    111     // Open GDBM database for querying 
    112     String gdbm_db_file = GSFile.GDBMDatabaseFile(site_home_, cluster_name_); 
    113     if (gdbm_src_.openDatabase(gdbm_db_file, GDBMWrapper.READER)) { 
    114         return true; 
    115     } 
    116     else { 
    117         System.err.println("Error: Could not open gdbm database!"); 
    118         return false; 
    119     } 
    120     } 
    121  
    122     /** creates a display element containing all the text strings needed to display the service page, in the language specified  
    123      * these retrieval services dont get displayed to the users - they are only used internally by the actions. so this returns an empty display element*/ 
    124     protected Element createServiceDisplay(String service, String lang) 
    125     { 
    126     return doc_.createElement(GSXML.DISPLAY_ELEM); 
     78    // Do generic configuration 
     79    return super.configure(info); 
    12780    } 
    12881 
    12982 
    130     /** retrieve a document */ 
    131     protected Element processDocumentRetrieve(Element request) 
     83    /** Retrieve the structure of a document */ 
     84    protected Element processDocumentStructureRetrieve(Element request) 
    13285    { 
    133     // an empty result 
     86    return super.processDocumentStructureRetrieve(request); 
     87    } 
     88 
     89 
     90    /** Retrieve metadata associated with a document */ 
     91    protected Element processDocumentMetadataRetrieve(Element request) 
     92    { 
     93    return super.processDocumentMetadataRetrieve(request); 
     94    } 
     95 
     96 
     97    /** Retrieve the content of a document */ 
     98    protected Element processDocumentContentRetrieve(Element request) 
     99    { 
     100    // Create a new (empty) result message 
    134101    Element result = doc_.createElement(GSXML.RESPONSE_ELEM); 
    135     String from = GSPath.appendLink(cluster_name_, DOCUMENT_RETRIEVE_SERVICE); 
     102    String from = GSPath.appendLink(cluster_name_, DOCUMENT_CONTENT_RETRIEVE_SERVICE); 
    136103    result.setAttribute(GSXML.FROM_ATT, from); 
    137     result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY); 
    138     Element result_doc = doc_.createElement(GSXML.CONTENT_ELEM); 
    139     result.appendChild(result_doc); 
     104    result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS); 
     105    Element result_content = doc_.createElement(GSXML.CONTENT_ELEM); 
     106    result.appendChild(result_content); 
    140107 
    141     // get param list and content  
    142     Element param_elem = null; 
    143     Element content_elem = null; 
    144     Node n = request.getFirstChild(); 
    145     while (n != null) { 
    146         String node_name = n.getNodeName(); 
    147         if (node_name.equals(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER)) { 
    148         param_elem = (Element) n; 
    149         } else if (node_name.equals(GSXML.CONTENT_ELEM)) { 
    150         content_elem = (Element) n; 
    151         } 
    152         n = n.getNextSibling(); 
     108    // Get the parameters of the request 
     109    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
     110    if (param_list == null) { 
     111        System.err.println("GS2Retrieve, DocumentContentRetrieve Error: missing paramList.\n"); 
     112        return result;  // Return the empty result 
    153113    } 
    154114 
    155     if (param_elem==null || content_elem==null) { 
    156         System.err.println("GS2MGRetrieve: malformed request sent to DocumentRetrieve service"); 
    157         return result; // empty result 
     115    String index = default_index_; 
     116 
     117    // Process the request parameters 
     118    Element param = (Element) param_list.getFirstChild(); 
     119    while (param != null) { 
     120        if (!param.getNodeName().equals(GSXML.PARAM_ELEM)) { 
     121        System.err.println("Warning: Non-param in paramList (ignored)."); 
     122        } 
     123        else { 
     124        // 
     125        if (param.getAttribute(GSXML.NAME_ATT) == INDEX_PARAM) { 
     126            index = GSXML.getValue(param); 
     127            System.out.println("Index: " + index); 
     128        } 
     129        } 
     130 
     131        param = (Element) param.getNextSibling(); 
    158132    } 
    159      
    160     HashMap params = GSXML.extractParams(param_elem); 
    161133 
    162     // get docs from mg 
    163     String index = (String) params.get(INDEX_PARAM);  
    164     if (index == null) { // if it is not present, use the default index 
    165         index = default_index_; 
     134    // Get the request content 
     135    Element content = (Element) GSXML.getChildByTagName(request, GSXML.CONTENT_ELEM); 
     136    if (content == null) { 
     137        System.err.println("Error: DocumentContentRetrieve request had no content.\n"); 
     138        return result; 
    166139    } 
    167     System.out.println("Index: " + index); 
    168140 
    169     String basedir = GSFile.collectionBaseDir(site_home_, cluster_name_) + File.separatorChar;  // Needed by MG 
     141    Element doc_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 
     142    result_content.appendChild(doc_list); 
     143 
     144    // The location of the MG index and text files 
     145    String basedir = GSFile.collectionBaseDir(site_home_, cluster_name_) 
     146                     + File.separatorChar;  // Needed by MG 
    170147    String textdir = GSFile.collectionTextPath(cluster_name_); 
    171148    String indexpath = GSFile.collectionIndexPath(cluster_name_, index); 
     
    176153    mg_src_.setIndex(indexpath); 
    177154 
    178     // get the text for each doc in the list 
    179     String[] ids = GSXML.getDocumentNameList(content_elem); 
    180     for (int j=0; j<ids.length; j++) { 
    181         long real_num = gdbm_src_.oid2Docnum(ids[j]); 
    182         String document = mg_src_.getDocument(basedir, textdir, real_num); 
    183         System.out.println("(MGRetrieve) Document: " + document); 
    184         // for now, stick it in a text node - eventually should be parsed as xml?? 
    185         // something funny with the doc -  
    186         Element new_doc = GSXML.createDocumentElement(doc_, ids[j]); 
    187         GSXML.addDocText(doc_, new_doc, document); 
     155    // Get the documents 
     156    String[] doc_ids = GSXML.getDocumentNameList(content); 
     157    for (int i = 0; i < doc_ids.length; i++) { 
     158        String doc_id = doc_ids[i]; 
     159        System.out.println("Retrieving content of " + doc_id + "..."); 
    188160 
    189         result_doc.appendChild(new_doc); 
     161        long doc_num = gdbm_src_.oid2Docnum(doc_id); 
     162        String doc_content = mg_src_.getDocument(basedir, textdir, doc_num); 
     163 
     164        // For now, stick it in a text node - eventually should be parsed as xml?? 
     165        Element doc = GSXML.createDocumentElement(doc_, doc_id); 
     166        GSXML.addDocText(doc_, doc, doc_content); 
     167        doc_list.appendChild(doc); 
    190168    } 
    191     return result; 
    192     } 
    193169 
    194  
    195     /** retrieve metadata */ 
    196     protected Element processMetadataRetrieve(Element request) 
    197     { 
    198     Element result = doc_.createElement(GSXML.RESPONSE_ELEM); 
    199     String from = GSPath.appendLink(cluster_name_, METADATA_RETRIEVE_SERVICE); 
    200     result.setAttribute(GSXML.FROM_ATT, from); 
    201     result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_QUERY); 
    202  
    203     Element result_content = doc_.createElement(GSXML.CONTENT_ELEM); 
    204     result.appendChild(result_content); 
    205     Element document_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 
    206     result_content.appendChild(document_list); 
    207  
    208     // get the metadata 
    209         Element content = (Element) request.getElementsByTagName(GSXML.CONTENT_ELEM).item(0); 
    210     if (content == null) { 
    211         // error: query had no content!! - should make an error message 
    212         return result; 
    213     } 
    214     String[] metas = GSXML.getMetaNameList(content); 
    215     String[] ids = GSXML.getDocumentNameList(content); 
    216     for (int j = 0; j < ids.length; j++) { // for each document 
    217         Element doc = GSXML.createDocumentElement(doc_, ids[j]); 
    218         Element list = GSXML.addMetaList(doc_, doc); 
    219         DBInfo info = gdbm_src_.getInfo(ids[j]); 
    220         for (int m = 0; m < metas.length; m++) { 
    221         String value = info.getInfo(metas[m]); 
    222         GSXML.addMetadata(doc_, list, metas[m], value); 
    223         } 
    224         document_list.appendChild(doc); 
    225     } 
    226170    return result; 
    227171    }