Ignore:
Timestamp:
2017-02-08T19:08:39+13:00 (7 years ago)
Author:
ak19
Message:

Second commit to do with implementing OAI deletion policy for GS2. This commit is only loosely related, as it shifts functions duplicated in source.h and filter.h (and cpp files) into the new colserver.h and cpp files for sharing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/colservr/source.cpp

    r31387 r31388  
    2525
    2626#include "source.h"
     27#include "colservertools.h"
    2728#include "fileutil.h"
    2829#include "OIDtools.h"
     
    8889}
    8990
    90 text_t sourceclass::getcollectionpath()
    91 {
    92   text_t resolved_filename;
    93  
    94   if (gsdlhome==dbhome) {
    95     // dbhome has defaulted to gsdlhome which we take to means the
    96     // database has been specifically moved out of gsdlhome area.
    97     // => it should be whereever collecthome is set to
    98     resolved_filename = filename_cat(collecthome, collection);
    99   }
    100   else {
    101     // dbhome is explicitly set to something other than gsdlhome
    102     // => use dbhome
    103     resolved_filename = filename_cat(dbhome, "collect", collection);
    104   }
    105 
    106   return resolved_filename;
    107 }
    108 
    109 text_t sourceclass::resolve_db_filename(const text_t& idx,
    110                     const text_t& file_ext)
    111 {
    112   // This is an exact copy of the method (of the same name) in filterclass
    113   // Makes sense to merge them, in which either gsdlhome, collecthome,
    114   // dbhome, and collection need to also be passed in as parameters,
    115   // or else there is some notion of a shared base class that both
    116   // filter and source inherit from
    117 
    118   // NB: there is an even greater opportunity to share more code in this
    119   // function if sql_db_ptr/db_ptr and db_filename and sql_db_filename
    120   // are also drawn from one object
    121 
    122   /*
    123   text_t resolved_filename;
    124 
    125   if (gsdlhome==dbhome) {
    126     // dbhome has defaulted to gsdlhome which we take to means the
    127     // database has been specifically moved out of gsdlhome area.
    128     // => it should be whereever collecthome is set to
    129 
    130     resolved_filename = filename_cat(collecthome, collection, "index", "text", idx);
    131   }
    132   else {
    133     // dbhome is explicitly set to something other than gsdlhome
    134     // => use dbhome
    135     resolved_filename = filename_cat(dbhome, "collect", collection, "index", "text", idx);
    136   }
    137   */
    138 
    139   text_t resolved_filename = filename_cat(getcollectionpath(), "index", "text", idx);
    140   resolved_filename += file_ext;
    141 
    142   return resolved_filename;
    143 }
    144 
    145 text_t sourceclass::resolve_oaidb_filename(const text_t& file_ext)
    146 {
    147   text_t resolved_filename = filename_cat(getcollectionpath(), "etc", "oai-inf");
    148 
    149   resolved_filename += file_ext;
    150 
    151   return resolved_filename;
    152 }
    15391
    15492// init should be called after all the configuration is done but
     
    204142    indexstem = collection;
    205143  }
    206   db_filename = resolve_db_filename(indexstem, db_ptr->getfileextension());
     144  db_filename = resolve_db_filename(gsdlhome, dbhome, collecthome, collection,
     145                    indexstem, db_ptr->getfileextension());
    207146  if (!file_exists(db_filename)) {
    208147    logout << text_t2ascii
     
    211150  }
    212151 
    213   oaidb_filename = resolve_oaidb_filename(oaidb_ptr->getfileextension());
     152  oaidb_filename = resolve_oaidb_filename(gsdlhome, dbhome, collecthome, collection,
     153                      oaidb_ptr->getfileextension());
    214154
    215155  return true;
Note: See TracChangeset for help on using the changeset viewer.