Changeset 28861

Show
Ignore:
Timestamp:
27.02.2014 14:32:54 (6 years ago)
Author:
kjdon
Message:

removed use of this.doc. Some static strings now coming from GSXML not OAIXML. OAIXML creating error elements has changed syntax. Added method to set up set info. includes any super set that this collection may belong to.

Files:
1 modified

Legend:

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

    r26096 r28861  
    5050 *  Dig into each collection's database and retrieve the metadata 
    5151 * 
    52  * @author <a href="mailto:xiao@cs.waikato.ac.nz">Xiao</a> 
    5352 */ 
    5453 
     
    6261  protected String coll_name = ""; 
    6362  
     63  // set this up during configure 
     64  protected Element list_sets_response = null; 
     65   
    6466  /** constructor */ 
    6567  public OAIPMH() { 
     
    8082    } 
    8183     
     84    Document doc = this.converter.newDOM(); 
     85    this.short_service_info = doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER); 
    8286    //get the names from ServiceRack.java 
    8387    this.site_name = this.router.getSiteName(); 
     
    127131    } 
    128132     
     133    // work out what sets this collection has. Will usually contain the collection itself, optional super collection, and maybe subcolls if appropriate classifiers are present. 
     134    configureSetInfo(); 
    129135    // the short_service_info is used by the message router to find the method names,  
    130136    //so we just use the doc variable in class ServiceRack to create the xml; but 
    131     // in each method we will use OAIXML to create the response xml 
     137    // in each method we will use OAIXMLto create the response xml 
    132138    // set up short_service_info_ - just the name 
    133   
    134     Element identify = this.doc.createElement(OAIXML.SERVICE); 
    135  
    136     identify.setAttribute(OAIXML.NAME, OAIXML.IDENTIFY); 
    137     identify.setAttribute(GSXML.TYPE_ATT, "oai"); 
    138     this.short_service_info.appendChild(identify); 
    139  
    140     Element list_records = this.doc.createElement(OAIXML.SERVICE); 
    141     list_records.setAttribute(OAIXML.NAME, OAIXML.LIST_RECORDS); 
     139 
     140    Element list_records = doc.createElement(GSXML.SERVICE_ELEM); 
     141    list_records.setAttribute(GSXML.NAME_ATT, OAIXML.LIST_RECORDS); 
    142142    list_records.setAttribute(GSXML.TYPE_ATT, "oai"); 
    143143    this.short_service_info.appendChild(list_records); 
    144144 
    145     Element list_identifiers = this.doc.createElement(OAIXML.SERVICE); 
    146     list_identifiers.setAttribute(OAIXML.NAME, OAIXML.LIST_IDENTIFIERS); 
     145    Element list_identifiers = doc.createElement(GSXML.SERVICE_ELEM); 
     146    list_identifiers.setAttribute(GSXML.NAME_ATT, OAIXML.LIST_IDENTIFIERS); 
    147147    list_identifiers.setAttribute(GSXML.TYPE_ATT, "oai"); 
    148148    this.short_service_info.appendChild(list_identifiers); 
    149149     
    150     Element list_sets = this.doc.createElement(OAIXML.SERVICE); 
    151     list_sets.setAttribute(OAIXML.NAME, OAIXML.LIST_SETS); 
     150    Element list_sets = doc.createElement(GSXML.SERVICE_ELEM); 
     151    list_sets.setAttribute(GSXML.NAME_ATT, OAIXML.LIST_SETS); 
    152152    list_sets.setAttribute(GSXML.TYPE_ATT, "oai"); 
    153153    this.short_service_info.appendChild(list_sets); 
    154154     
    155     Element list_metadata_formats = this.doc.createElement(OAIXML.SERVICE); 
    156     list_metadata_formats.setAttribute(OAIXML.NAME, OAIXML.LIST_METADATA_FORMATS); 
     155    Element list_metadata_formats = doc.createElement(GSXML.SERVICE_ELEM); 
     156    list_metadata_formats.setAttribute(GSXML.NAME_ATT, OAIXML.LIST_METADATA_FORMATS); 
    157157    list_metadata_formats.setAttribute(GSXML.TYPE_ATT, "oai"); 
    158158    this.short_service_info.appendChild(list_metadata_formats); 
    159159 
    160     Element get_record = this.doc.createElement(OAIXML.SERVICE); 
    161     get_record.setAttribute(OAIXML.NAME, OAIXML.GET_RECORD); 
     160    Element get_record = doc.createElement(GSXML.SERVICE_ELEM); 
     161    get_record.setAttribute(GSXML.NAME_ATT, OAIXML.GET_RECORD); 
    162162    get_record.setAttribute(GSXML.TYPE_ATT, "oai"); 
    163163    this.short_service_info.appendChild(get_record); 
     
    165165    return true; 
    166166  } 
     167 
    167168  /** returns a specific service description */ 
    168169  public Element getServiceDescription(String service_id, String lang, String subset) { 
    169170     
    170     if (service_id.equals(OAIXML.IDENTIFY)) { 
    171       Element identify = this.doc.createElement(OAIXML.SERVICE); 
    172       identify.setAttribute(OAIXML.NAME, OAIXML.IDENTIFY); 
    173       identify.setAttribute(GSXML.TYPE_ATT, "oai"); 
    174       return identify; 
    175     } 
     171    Document doc = this.converter.newDOM(); 
    176172    if (service_id.equals(OAIXML.LIST_RECORDS)) { 
    177       Element list_records = this.doc.createElement(OAIXML.SERVICE); 
    178       list_records.setAttribute(OAIXML.NAME, OAIXML.LIST_RECORDS); 
     173      Element list_records = doc.createElement(GSXML.SERVICE_ELEM); 
     174      list_records.setAttribute(GSXML.NAME_ATT, OAIXML.LIST_RECORDS); 
    179175      list_records.setAttribute(GSXML.TYPE_ATT, "oai"); 
    180176      return list_records; 
     
    182178     
    183179    if (service_id.equals(OAIXML.LIST_IDENTIFIERS)) { 
    184       Element list_identifiers = this.doc.createElement(OAIXML.SERVICE); 
    185       list_identifiers.setAttribute(OAIXML.NAME, OAIXML.LIST_IDENTIFIERS); 
     180      Element list_identifiers = doc.createElement(GSXML.SERVICE_ELEM); 
     181      list_identifiers.setAttribute(GSXML.NAME_ATT, OAIXML.LIST_IDENTIFIERS); 
    186182      list_identifiers.setAttribute(GSXML.TYPE_ATT, "oai"); 
    187183      return list_identifiers; 
    188184    } 
    189185    if (service_id.equals(OAIXML.LIST_SETS)) { 
    190       Element list_sets = this.doc.createElement(OAIXML.SERVICE); 
    191       list_sets.setAttribute(OAIXML.NAME, OAIXML.LIST_SETS); 
     186      Element list_sets = doc.createElement(GSXML.SERVICE_ELEM); 
     187      list_sets.setAttribute(GSXML.NAME_ATT, OAIXML.LIST_SETS); 
    192188      list_sets.setAttribute(GSXML.TYPE_ATT, "oai"); 
    193189      return list_sets; 
    194190    } 
    195191    if (service_id.equals(OAIXML.LIST_METADATA_FORMATS)) { 
    196       Element list_metadata_formats = this.doc.createElement(OAIXML.SERVICE); 
    197       list_metadata_formats.setAttribute(OAIXML.NAME, OAIXML.LIST_METADATA_FORMATS); 
     192      Element list_metadata_formats = doc.createElement(GSXML.SERVICE_ELEM); 
     193      list_metadata_formats.setAttribute(GSXML.NAME_ATT, OAIXML.LIST_METADATA_FORMATS); 
    198194      list_metadata_formats.setAttribute(GSXML.TYPE_ATT, "oai"); 
    199195      return list_metadata_formats; 
     
    201197     
    202198    if (service_id.equals(OAIXML.GET_RECORD)) { 
    203       Element get_record = this.doc.createElement(OAIXML.SERVICE); 
    204       get_record.setAttribute(OAIXML.NAME, OAIXML.GET_RECORD); 
     199      Element get_record = doc.createElement(GSXML.SERVICE_ELEM); 
     200      get_record.setAttribute(GSXML.NAME_ATT, OAIXML.GET_RECORD); 
    205201      get_record.setAttribute(GSXML.TYPE_ATT, "oai"); 
    206202      return get_record; 
     
    209205    return null; 
    210206  } 
    211   /** return the metadata information about this set of the repository */ 
    212   protected Element processIdentify(Element req) { 
    213     return null; 
    214   } 
     207  // /** return the metadata information about this set of the repository */ 
     208  // protected Element processIdentify(Element req) { 
     209  //   return null; 
     210  // } 
    215211  /** return the metadata information  */ 
    216212  protected Element processListSets(Element req) { 
    217     //This method is never called unless each set in the returned message contain a 
    218     //'description' element so that we need to ask each collection for their info 
    219     return null;     
     213    return list_sets_response; 
    220214  } 
    221215  /** return the metadata information  */ 
     
    226220     *  Exceptions: badArgument; cannotDisseminateFormat; idDoesNotExist 
    227221     */  
    228     NodeList params = GSXML.getChildrenByTagName(req, OAIXML.PARAM); 
    229     HashMap<String, String> param_map = OAIXML.getParamMap(params);     
     222    NodeList params = GSXML.getChildrenByTagName(req, GSXML.PARAM_ELEM); 
     223    HashMap<String, String> param_map = GSXML.getParamMap(params);     
    230224     
    231225    String prefix = param_map.get(OAIXML.METADATA_PREFIX); 
     
    233227      //Just a double-check 
    234228      logger.error("the value of metadataPrefix att is not present in the request."); 
    235       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.CANNOT_DISSEMINATE_FORMAT, "")); 
     229      return OAIXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, ""); 
    236230    } 
    237231     
     
    239233    if(metadata_format == null) { 
    240234      logger.error("metadata prefix is not supported."); 
    241       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.CANNOT_DISSEMINATE_FORMAT, "")); 
    242     } 
    243      
    244     String oid = param_map.get(OAIXML.OID); 
     235      return OAIXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, ""); 
     236    } 
     237     
     238    String oid = param_map.get(OAIXML.OID); // TODO should this be identifier??? 
    245239 
    246240    //get a DBInfo object of the identifier; if this identifier is not present in the database, 
     
    249243    if (info == null) { 
    250244      logger.error("OID: " + oid + " is not present in the database."); 
    251       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.ID_DOES_NOT_EXIST, "")); 
    252     } 
    253  
     245      return OAIXML.createErrorResponse(OAIXML.ID_DOES_NOT_EXIST, ""); 
     246    } 
     247 
     248    Document doc = this.converter.newDOM(); 
    254249    ArrayList<String> keys = new ArrayList<String>(info.getKeys()); 
    255250    String oailastmodified = ""; 
     
    259254    } 
    260255 
    261     Element get_record = OAIXML.createElement(OAIXML.GET_RECORD); 
    262     Element record = OAIXML.createElement(OAIXML.RECORD); 
     256    Element get_record_response = doc.createElement(GSXML.RESPONSE_ELEM); 
     257    Element get_record = doc.createElement(OAIXML.GET_RECORD); 
     258    get_record_response.appendChild(get_record); 
     259    Element record = doc.createElement(OAIXML.RECORD); 
    263260    //compose the header element 
    264     record.appendChild(createHeaderElement(oid, oailastmodified));       
     261    record.appendChild(createHeaderElement(doc, oid, oailastmodified));       
    265262    //compose the metadata element 
    266     record.appendChild(createMetadataElement(prefix, info, metadata_format)); 
     263    record.appendChild(createMetadataElement(doc, prefix, info, metadata_format)); 
    267264    get_record.appendChild(record); 
    268     return OAIXML.getResponse(get_record); 
     265    return get_record_response; 
    269266  } 
    270267  /** return a list of identifiers  */ 
     
    278275     *  Exceptions: badArgument; cannotDisseminateFormat; idDoesNotExist 
    279276     */  
    280     NodeList params = GSXML.getChildrenByTagName(req, OAIXML.PARAM); 
     277    NodeList params = GSXML.getChildrenByTagName(req, GSXML.PARAM_ELEM); 
    281278     
    282279    if(params.getLength() == 0) { 
    283280      logger.error("must at least have the metadataPrefix parameter, can't be none"); 
    284       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.BAD_ARGUMENT, "")); 
    285     } 
    286      
    287     HashMap<String, String> param_map = OAIXML.getParamMap(params);   
     281      return OAIXML.createErrorResponse(OAIXML.BAD_ARGUMENT, ""); 
     282    } 
     283     
     284    HashMap<String, String> param_map = GSXML.getParamMap(params);   
    288285     
    289286    String prefix = ""; 
     
    294291      //Just a double-check 
    295292      logger.error("A param element containing the metadataPrefix is not present."); 
    296       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.CANNOT_DISSEMINATE_FORMAT, "")); 
     293      return OAIXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, ""); 
    297294    } 
    298295    prefix = param_map.get(OAIXML.METADATA_PREFIX); 
     
    300297      //Just a double-check 
    301298      logger.error("the value of metadataPrefix att is not present in the request."); 
    302       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.CANNOT_DISSEMINATE_FORMAT, "")); 
     299      return OAIXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, ""); 
    303300    } 
    304301     
     
    315312    if(metadata_format == null) { 
    316313      logger.error("metadata prefix is not supported."); 
    317       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.CANNOT_DISSEMINATE_FORMAT, "")); 
     314      return OAIXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, ""); 
    318315    } 
    319316    ArrayList<String> oid_list = getChildrenIds(OAIXML.BROWSELIST); 
    320317    if (oid_list == null) { 
    321318      logger.error("No matched records found in collection: browselist is empty"); 
    322       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.NO_RECORDS_MATCH, "")); 
     319      return OAIXML.createErrorResponse(OAIXML.NO_RECORDS_MATCH, ""); 
    323320    } 
    324321    // all validation is done 
    325     Element list_identifiers = OAIXML.createElement(OAIXML.LIST_IDENTIFIERS); 
     322 
     323    Document doc = this.converter.newDOM(); 
     324    Element list_identifiers_response = doc.createElement(GSXML.RESPONSE_ELEM); 
     325    Element list_identifiers = doc.createElement(OAIXML.LIST_IDENTIFIERS); 
     326    list_identifiers_response.appendChild(list_identifiers); 
     327 
    326328    for(int i=0; i<oid_list.size(); i++) { 
    327329      String oid = oid_list.get(i); 
     
    350352      }       
    351353      //compose the header element and append it 
    352       list_identifiers.appendChild(createHeaderElement(oid, oailastmodified));       
     354      list_identifiers.appendChild(createHeaderElement(doc, oid, oailastmodified));       
    353355    }//end of for(int i=0; i<oid_list.size(); i++) of doing thru each record 
    354356     
    355     return OAIXML.getResponse(list_identifiers);         
     357    return list_identifiers_response;         
    356358  } 
    357359  /** return a list of records  */ 
     
    363365     * argument but a 'metadataPrefix' param. The OAIReceptionist makes sure of this. 
    364366     */ 
    365     NodeList params = GSXML.getChildrenByTagName(req, OAIXML.PARAM); 
     367    NodeList params = GSXML.getChildrenByTagName(req, GSXML.PARAM_ELEM); 
    366368     
    367369    if(params.getLength() == 0) { 
    368370      logger.error("must at least have the metadataPrefix parameter, can't be none"); 
    369       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.BAD_ARGUMENT, "")); 
    370     } 
    371      
    372     HashMap<String, String> param_map = OAIXML.getParamMap(params);     
     371      return OAIXML.createErrorResponse(OAIXML.BAD_ARGUMENT, ""); 
     372    } 
     373     
     374    HashMap<String, String> param_map = GSXML.getParamMap(params);     
    373375 
    374376    String prefix = ""; 
     
    379381      //Just a double-check 
    380382      logger.error("A param element containing the metadataPrefix is not present."); 
    381       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.CANNOT_DISSEMINATE_FORMAT, "")); 
     383      return OAIXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, ""); 
    382384    } 
    383385    prefix = param_map.get(OAIXML.METADATA_PREFIX); 
     
    385387      //Just a double-check 
    386388      logger.error("the value of metadataPrefix att is not present in the request."); 
    387       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.CANNOT_DISSEMINATE_FORMAT, "")); 
     389      return OAIXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, ""); 
    388390    } 
    389391     
     
    399401    if(metadata_format == null) { 
    400402      logger.error("metadata prefix is not supported."); 
    401       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.CANNOT_DISSEMINATE_FORMAT, "")); 
     403      return OAIXML.createErrorResponse(OAIXML.CANNOT_DISSEMINATE_FORMAT, ""); 
    402404    } 
    403405     
     
    406408    if (oid_list == null) { 
    407409      logger.error("No matched records found in collection: browselist is empty"); 
    408       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.NO_RECORDS_MATCH, "")); 
     410      return OAIXML.createErrorResponse(OAIXML.NO_RECORDS_MATCH, ""); 
    409411    } 
    410412    // all validation is done 
    411     Element list_records = OAIXML.createElement(OAIXML.LIST_RECORDS); 
     413 
     414    Document doc = this.converter.newDOM(); 
     415    Element list_records_response = doc.createElement(GSXML.RESPONSE_ELEM); 
     416    Element list_records = doc.createElement(OAIXML.LIST_RECORDS); 
     417    list_records_response.appendChild(list_records); 
    412418    for(int i=0; i<oid_list.size(); i++) { 
    413419      String oid = oid_list.get(i); 
     
    436442      } 
    437443       
    438       Element record = OAIXML.createElement(OAIXML.RECORD); 
     444      Element record = doc.createElement(OAIXML.RECORD); 
    439445      list_records.appendChild(record); 
    440446      //compose the header element 
    441       record.appendChild(createHeaderElement(oid, oailastmodified));       
     447      record.appendChild(createHeaderElement(doc, oid, oailastmodified));       
    442448      //compose the metadata element 
    443       record.appendChild(createMetadataElement(prefix, info, metadata_format)); 
     449      record.appendChild(createMetadataElement(doc, prefix, info, metadata_format)); 
    444450       
    445451    }//end of for(int i=0; i<oid_list.size(); i++) of doing thru each record 
    446452     
    447     return OAIXML.getResponse(list_records);     
     453    return list_records_response;     
    448454  } 
    449455   
     456  // have implemented setDescription as an element, instead of a container containing metadata 
     457  private boolean configureSetInfo() { 
     458 
     459    Document doc = this.converter.newDOM(); 
     460    this.list_sets_response = doc.createElement(GSXML.RESPONSE_ELEM); 
     461    Element list_sets_elem = doc.createElement(OAIXML.LIST_SETS); 
     462    this.list_sets_response.appendChild(list_sets_elem); 
     463    String set_name = this.coll_name; 
     464    String set_description = null; 
     465    Element name_elem = (Element)GSXML.getChildByTagName(this.config_info, OAIXML.SET_NAME); 
     466    if (name_elem!=null) { 
     467      set_name = GSXML.getNodeText(name_elem); 
     468      if (set_name.equals("")) { 
     469    set_name = this.coll_name; // default to coll name if can't find one 
     470      } 
     471    } 
     472    Element description_elem = (Element)GSXML.getChildByTagName(this.config_info, OAIXML.SET_DESCRIPTION); 
     473    if (description_elem!=null) { 
     474      set_description = GSXML.getNodeText(description_elem); 
     475      if (set_description.equals("")) { 
     476    set_description = null; 
     477      } 
     478    } 
     479    Element coll_set = OAIXML.createSet(doc, this.coll_name, set_name, set_description); 
     480    list_sets_elem.appendChild(coll_set); 
     481     
     482    // are we part of any super sets? 
     483    NodeList super_set_list = GSXML.getChildrenByTagName(this.config_info, OAIXML.OAI_SUPER_SET); 
     484    for (int i=0; i<super_set_list.getLength(); i++) { 
     485      String super_name = ((Element)super_set_list.item(i)).getAttribute(GSXML.NAME_ATT); 
     486      if (super_name != null && !super_name.equals("")) { 
     487    list_sets_elem.appendChild(OAIXML.createSet(doc, super_name, super_name, null)); 
     488      } 
     489    } 
     490    return true; 
     491  } 
    450492  /** get the metadataFormat element from the collectionConfig.xml containing the specified metadata prefix. 
    451493   *  return null if not found. 
     
    458500  /** create the metadata element used when processing ListRecords/GetRecord requests 
    459501   */ 
    460   private Element createMetadataElement(String prefix, DBInfo info, Element metadata_format) { 
     502  private Element createMetadataElement(Document doc, String prefix, DBInfo info, Element metadata_format) { 
    461503        //the prefix string is in the form: oai_dc, for example. 
    462504        String prfx_str = ""; 
     
    478520        //create the <metadata> element 
    479521        //OAIXML.oai_version is read from OAIConfig.xml and its default value is "2.0" 
    480     Element metadata = OAIXML.createElement(OAIXML.METADATA); 
    481         Element prfx_str_elem = OAIXML.getMetadataPrefixElement(prfx_str, OAIXML.oai_version); 
     522    Element metadata = doc.createElement(OAIXML.METADATA); 
     523        Element prfx_str_elem = OAIXML.getMetadataPrefixElement(doc, prfx_str, OAIXML.oai_version); 
    482524        metadata.appendChild(prfx_str_elem); 
    483525        String[] metadata_names = getMetadataNameMapping(metadata_format); 
     
    499541      //meta_name = meta_name.replace('.', ':'); // namespace separator should be : for oai 
    500542      String meta_value = (String)men.getValue(); 
    501       Element e = OAIXML.createElement(meta_name); 
     543      Element e = doc.createElement(meta_name); 
    502544      GSXML.setNodeText(e, meta_value); 
    503545      prfx_str_elem.appendChild(e); 
     
    508550  /** create a header element used when processing requests like ListRecords/GetRecord/ListIdentifiers 
    509551   */ 
    510   private Element createHeaderElement(String oid, String oailastmodified) {     
    511         Element header = OAIXML.createElement(OAIXML.HEADER); 
    512         Element identifier = OAIXML.createElement(OAIXML.IDENTIFIER); 
    513         GSXML.setNodeText(identifier, site_name + ":" + coll_name + ":" + oid); 
     552  private Element createHeaderElement(Document doc, String oid, String oailastmodified) {     
     553        Element header = doc.createElement(OAIXML.HEADER); 
     554        Element identifier = doc.createElement(OAIXML.IDENTIFIER); 
     555        //GSXML.setNodeText(identifier, site_name + ":" + coll_name + ":" + oid); 
     556    GSXML.setNodeText(identifier, coll_name + ":" + oid); 
    514557        header.appendChild(identifier); 
    515         Element set_spec = OAIXML.createElement(OAIXML.SET_SPEC); 
    516         GSXML.setNodeText(set_spec, site_name + ":" + coll_name); 
     558        Element set_spec = doc.createElement(OAIXML.SET_SPEC); 
     559        //GSXML.setNodeText(set_spec, site_name + ":" + coll_name); 
     560    GSXML.setNodeText(set_spec, coll_name); 
    517561        header.appendChild(set_spec); 
    518         Element datestamp = OAIXML.createElement(OAIXML.DATESTAMP); 
     562        Element datestamp = doc.createElement(OAIXML.DATESTAMP); 
    519563        GSXML.setNodeText(datestamp, oailastmodified); 
    520564        header.appendChild(datestamp); 
     
    524568  protected Element processListMetadataFormats(Element req) { 
    525569    // the request sent here must contain an OID. see doListMetadataFormats() in OAIReceptionist 
    526     Element param = GSXML.getNamedElement(req, OAIXML.PARAM, OAIXML.NAME, OAIXML.OID); 
     570    Element param = GSXML.getNamedElement(req, GSXML.PARAM_ELEM, GSXML.NAME_ATT, OAIXML.OID); 
    527571    if (param == null) { 
    528572      logger.error("An element containing the OID attribute not is present."); 
    529       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.ID_DOES_NOT_EXIST, "")); 
    530     } 
    531     String oid = param.getAttribute(OAIXML.VALUE); 
     573      return OAIXML.createErrorResponse(OAIXML.ID_DOES_NOT_EXIST, ""); 
     574    } 
     575    String oid = param.getAttribute(GSXML.VALUE_ATT); 
    532576    if (oid == null || oid.equals("")) { 
    533577      logger.error("No OID is present in the request."); 
    534       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.ID_DOES_NOT_EXIST, "")); 
     578      return OAIXML.createErrorResponse(OAIXML.ID_DOES_NOT_EXIST, ""); 
    535579    } 
    536580    ArrayList<String> oid_list = getChildrenIds(OAIXML.BROWSELIST); 
    537581    if (oid_list == null || oid_list.contains(oid) == false) { 
    538582      logger.error("OID: " + oid + " is not present in the database."); 
    539       Element e= OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.ID_DOES_NOT_EXIST, "")); 
     583      Element e= OAIXML.createErrorResponse(OAIXML.ID_DOES_NOT_EXIST, ""); 
    540584//      logger.error((new XMLConverter()).getPrettyString (e)); 
    541585      return e; 
     
    545589    info = this.coll_db.getInfo(oid); 
    546590    if (info == null) { //just double check 
    547       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.OAI_SERVICE_UNAVAILABLE, "")); 
     591      return OAIXML.createErrorResponse(OAIXML.OAI_SERVICE_UNAVAILABLE, ""); 
    548592    } 
    549593     
     
    551595    if (meta_list == null || meta_list.getLength() == 0) { 
    552596      logger.error("No metadata format is present in collectionConfig.xml"); 
    553       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.NO_METADATA_FORMATS, "")); 
    554     } 
    555  
    556     Element list_metadata_formats = OAIXML.createElement(OAIXML.LIST_METADATA_FORMATS); 
     597      return OAIXML.createErrorResponse(OAIXML.NO_METADATA_FORMATS, ""); 
     598    } 
     599 
     600    Document doc = this.converter.newDOM(); 
     601    Element list_metadata_formats_response = doc.createElement(GSXML.RESPONSE_ELEM); 
     602     
     603    Element list_metadata_formats = doc.createElement(OAIXML.LIST_METADATA_FORMATS); 
     604    list_metadata_formats_response.appendChild(list_metadata_formats); 
    557605    boolean has_meta_format = false; 
    558606     
     
    562610      if (containsMetadata(info, metadata_names) == true) { 
    563611        has_meta_format = true; 
    564         Element meta_fmt = OAIXML.createElement(OAIXML.METADATA_FORMAT); 
    565         OAIXML.copyElement(meta_fmt, metadata_format, OAIXML.METADATA_PREFIX); 
    566         OAIXML.copyElement(meta_fmt, metadata_format, OAIXML.METADATA_NAMESPACE); 
    567         OAIXML.copyElement(meta_fmt, metadata_format, OAIXML.SCHEMA); 
     612    // TODO, can we do this in an easier way?? 
     613        Element meta_fmt = doc.createElement(OAIXML.METADATA_FORMAT); 
     614        GSXML.copyElement(meta_fmt, metadata_format, OAIXML.METADATA_PREFIX); 
     615        GSXML.copyElement(meta_fmt, metadata_format, OAIXML.METADATA_NAMESPACE); 
     616        GSXML.copyElement(meta_fmt, metadata_format, OAIXML.SCHEMA); 
    568617        list_metadata_formats.appendChild(meta_fmt); 
    569618      } 
     
    571620    if (has_meta_format == false) { 
    572621      logger.error("Specified metadata names are not contained in the database."); 
    573       return OAIXML.getResponse(OAIXML.createErrorElement(OAIXML.NO_METADATA_FORMATS, "")); 
     622      return OAIXML.createErrorResponse(OAIXML.NO_METADATA_FORMATS, ""); 
    574623    } else { 
    575       return OAIXML.getResponse(list_metadata_formats); 
     624      return list_metadata_formats_response; 
    576625    } 
    577626  }