Changeset 30327


Ignore:
Timestamp:
12/02/15 11:58:30 (5 years ago)
Author:
kjdon
Message:

changed the way we read in collect.cfg to find depositormetadata. New way copied from other places that read in collect.cfg. Keeps it in utf8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/depositoraction.cpp

    r29381 r30327  
    454454    // check configured metadata elements
    455455    if (args["metadataconf"] == "var DepositorMDFields = new Array();" || args["metadataconf"] == "") {
     456
    456457      text_t cfgfile_name = filename_cat (collecthome, args[macro_prefix + "dirname"], "etc", "collect.cfg");
    457       text_t cfgfile_content;
     458      text_t key;
     459      text_tarray cfgline;
     460      char *cstr = cfgfile_name.getcstr();
     461      ifstream confin (cstr);
     462      delete []cstr;
     463
    458464      text_t metadata_str;
    459      
    460       if (read_file (cfgfile_name, cfgfile_content)) {
    461     text_t::const_iterator here = cfgfile_content.begin();
    462     text_t::const_iterator end = cfgfile_content.end();
    463     while (here != end) {
    464       here = findchar (here, end, 'd');
    465       if (here == end) break;
    466       if ((here+17 < end) && (substr (here, here+17) == "depositormetadata")) {
    467         here = findchar (here, end, '"');
    468         if (here == end) break; 
    469         text_t enddelimit = "\"\n";
    470         getdelimitstr (here+1, end, enddelimit, metadata_str);
    471         args["metadataconf"] = "var DepositorMDFields = new Array("+metadata_str+");";     
     465      if (confin) {
     466    while (read_cfg_line(confin, cfgline) >= 0) {
     467      if (cfgline.size () >= 2) {
     468        key = cfgline[0];
     469        if (key == "collectionmeta") {
     470          if (cfgline[1] == "depositormetadata") {
     471        metadata_str = cfgline[2];
     472         
     473        break;
     474          }
     475        }
    472476      }
    473       ++here;
    474477    }
    475478      }
    476 
     479      confin.close ();
     480     
    477481      if (metadata_str == "") {
    478     args["metadataconf"] = "var DepositorMDFields = new Array({\"name\":\"dc.Title\",\"label\":\"Title\",\"tooltip\":\"dc.Title: A name given to the resource.\",\"type\":\"text\"}, {\"name\":\"dc.Creator\",\"label\":\"Creator\",\"tooltip\":\"dc.Creator: An entity primarily responsible for making the content of the resource.\",\"type\":\"text\"}, {\"name\":\"dc.Description\",\"label\":\"Description\",\"tooltip\":\"dc.Description: An account of the content of the resource.\",\"type\":\"textarea\"});";
     482    metadata_str = "{\"name\":\"dc.Title\",\"label\":\"Title\",\"tooltip\":\"dc.Title: A name given to the resource.\",\"type\":\"text\"}, {\"name\":\"dc.Creator\",\"label\":\"Creator\",\"tooltip\":\"dc.Creator: An entity primarily responsible for making the content of the resource.\",\"type\":\"text\"}, {\"name\":\"dc.Description\",\"label\":\"Description\",\"tooltip\":\"dc.Description: An account of the content of the resource.\",\"type\":\"textarea\"}";
    479483      }
     484      args["metadataconf"] = "var DepositorMDFields = new Array("+metadata_str+");";
     485 
    480486    }
    481487
     
    806812            for (int i = 0; i < numvalues; ++i) {
    807813              if (!mdvalues[i].empty()) {
    808 
    809814                decode_cgi_arg(mdvalues[i]);
    810 
    811815                metadata_file += "            <Metadata mode=\"accumulate\" name=\"";       
    812816                metadata_file += args_suffix;
Note: See TracChangeset for help on using the changeset viewer.