Ignore:
Timestamp:
02/08/17 19:08:39 (4 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.

Location:
main/trunk/greenstone2/runtime-src/src/colservr
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/colservr/Makefile.in

    r27063 r31388  
    145145    collectserver.cpp \
    146146    collectset.cpp \
     147    colservertools.cpp \
    147148        colservrconfig.cpp \
    148149    comtypes.cpp \
     
    169170    collectserver.o \
    170171    collectset.o \
     172    colservertools.o \
    171173        colservrconfig.o \
    172174    comtypes.o \
  • main/trunk/greenstone2/runtime-src/src/colservr/browsefilter.cpp

    r31387 r31388  
    2525
    2626#include "browsefilter.h"
     27#include "colservertools.h"
    2728#include "fileutil.h"
    2829#include <assert.h>
     
    8788  }
    8889
    89   db_filename = resolve_db_filename(indexstem,db_ptr->getfileextension());
     90  db_filename = resolve_db_filename(gsdlhome, dbhome, collecthome, collection,
     91                    indexstem,db_ptr->getfileextension());
    9092  if (!file_exists(db_filename)) {
    9193    logout << text_t2ascii
     
    9496  }
    9597
    96   oaidb_filename = resolve_oaidb_filename(oaidb_ptr->getfileextension());
     98  oaidb_filename = resolve_oaidb_filename(gsdlhome, dbhome, collecthome, collection,
     99                      oaidb_ptr->getfileextension());
    97100
    98101  return true;
  • main/trunk/greenstone2/runtime-src/src/colservr/filter.cpp

    r31387 r31388  
    6161}
    6262
    63 text_t filterclass::getcollectionpath()
    64 {
    65   text_t resolved_filename;
    66  
    67   if (gsdlhome==dbhome) {
    68     // dbhome has defaulted to gsdlhome which we take to means the
    69     // database has been specifically moved out of gsdlhome area.
    70     // => it should be whereever collecthome is set to
    71     resolved_filename = filename_cat(collecthome, collection);
    72   }
    73   else {
    74     // dbhome is explicitly set to something other than gsdlhome
    75     // => use dbhome
    76     resolved_filename = filename_cat(dbhome, "collect", collection);
    77   }
    78 
    79   return resolved_filename;
    80 }
    81 
    82 text_t filterclass::resolve_db_filename(const text_t& idx,
    83                     const text_t& file_ext)
    84 {
    85   /*
    86   text_t resolved_filename;
    87 
    88   if (gsdlhome==dbhome) {
    89     // dbhome has defaulted to gsdlhome which we take to means the
    90     // database has been specifically moved out of gsdlhome area.
    91     // => it should be whereever collecthome is set to
    92     resolved_filename = filename_cat(collecthome, collection, "index", "text", idx);
    93   }
    94   else {
    95     // dbhome is explicitly set to something other than gsdlhome
    96     // => use dbhome
    97     resolved_filename = filename_cat(dbhome, "collect", collection, "index", "text", idx);
    98   }
    99   */
    100  
    101   text_t resolved_filename = filename_cat(getcollectionpath(), "index", "text", idx);
    102   resolved_filename += file_ext;
    103 
    104   return resolved_filename;
    105 }
    106 
    107 text_t filterclass::resolve_oaidb_filename(const text_t& file_ext)
    108 {
    109   text_t resolved_filename = filename_cat(getcollectionpath(), "etc", "oai-inf");
    110 
    111   resolved_filename += file_ext;
    112 
    113   return resolved_filename;
    114 }
    115 
    11663
    11764// init should be called after all the configuration is done but
  • main/trunk/greenstone2/runtime-src/src/colservr/filter.h

    r31387 r31388  
    6666               FilterResponse_t &response,
    6767               comerror_t &err, ostream &logout);
    68 
    69  protected:
    70   text_t resolve_db_filename(const text_t& idx,const text_t& file_ext);
    71   text_t resolve_oaidb_filename(const text_t& file_ext);
    72   text_t getcollectionpath();
    7368
    7469};
  • main/trunk/greenstone2/runtime-src/src/colservr/queryfilter.cpp

    r27084 r31388  
    2525
    2626#include "queryfilter.h"
     27#include "colservertools.h"
    2728#include "fileutil.h"
    2829
     
    253254    indexstem = collection;
    254255  }
    255   db_filename = resolve_db_filename(indexstem,db_ptr->getfileextension());
     256  db_filename = resolve_db_filename(gsdlhome, dbhome, collecthome, collection,
     257                    indexstem,db_ptr->getfileextension());
    256258  if (!file_exists(db_filename)) {
    257259    logout << text_t2ascii
  • 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;
  • main/trunk/greenstone2/runtime-src/src/colservr/source.h

    r31387 r31388  
    109109  virtual bool is_searchable(bool &issearchable, comerror_t &err, ostream &logout);
    110110
    111  protected:
    112   text_t resolve_db_filename(const text_t& idx,
    113                  const text_t& file_ext);
    114   text_t resolve_oaidb_filename(const text_t& file_ext);
    115   text_t getcollectionpath();
    116 
    117111};
    118112
  • main/trunk/greenstone2/runtime-src/src/colservr/sqlfilter.cpp

    r22049 r31388  
    2626
    2727#include "fileutil.h"
     28#include "colservertools.h"
    2829#include "sqlfilter.h"
    2930
     
    6768
    6869  // get the filename for the database and make sure it exists
    69   sql_db_filename = resolve_db_filename(indexstem,sql_db_ptr->getfileextension());
     70  sql_db_filename = resolve_db_filename(gsdlhome, dbhome, collecthome, collection,
     71                    indexstem,sql_db_ptr->getfileextension());
    7072  if (!file_exists(sql_db_filename))
    7173  {
Note: See TracChangeset for help on using the changeset viewer.