Changeset 22067

Show
Ignore:
Timestamp:
07.05.2010 21:11:22 (9 years ago)
Author:
ak19
Message:

1. More changes to makefiles: rm JDBMWrapper.jar and jdbm.jar on clean. 2. DB files (argdb, users, key, history) now not only for gdbm but to work with other db types like jdbm, sqlite and mssql.

Location:
main/trunk/greenstone2
Files:
20 modified

Legend:

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

    r22058 r22067  
    137137      (cd $$subdir && $(MAKE) clean) || exit 1; \ 
    138138    done 
     139    if test -e ../bin/java/JDBMWrapper.jar; then \ 
     140      rm ../bin/java/JDBMWrapper.jar; \ 
     141    fi 
     142    if test -e ../lib/java/jdbm.jar; then \ 
     143      rm ../lib/java/jdbm.jar; \ 
     144    fi 
     145 
    139146 
    140147# commented out - jrm21 Dec 2004 - can get confused by cvs timestamps 
  • main/trunk/greenstone2/common-src/src/lib/dbclass.h

    r15679 r22067  
    5151{ 
    5252public: 
    53   dbclass() { logout = &cerr; } 
     53  dbclass(const text_t& gsdlhome) { logout = &cerr; } 
    5454  virtual ~dbclass(); 
    5555 
  • main/trunk/greenstone2/common-src/src/lib/gdbmclass.cpp

    r21796 r22067  
    3131#include <cstring> 
    3232 
     33 
     34gdbmclass::gdbmclass(const text_t& gsdlhome)  
     35  : dbclass(gsdlhome) 
     36{  
     37  gdbmfile = NULL;  
     38} 
    3339 
    3440gdbmclass::~gdbmclass() 
  • main/trunk/greenstone2/common-src/src/lib/gdbmclass.h

    r21405 r22067  
    5252{ 
    5353public: 
    54   gdbmclass() { gdbmfile = NULL; }; 
     54  gdbmclass(const text_t& gsdlhome); 
    5555  ~gdbmclass(); 
    5656 
  • main/trunk/greenstone2/common-src/src/lib/jdbmnaiveclass.cpp

    r22043 r22067  
    3838 
    3939jdbmnaiveclass::jdbmnaiveclass(const text_t& gsdlhome) 
    40   : dbclass() 
     40  : dbclass(gsdlhome) 
    4141{ 
    4242  gsdlhome_ = gsdlhome; 
  • main/trunk/greenstone2/common-src/src/lib/mssqldbclass.cpp

    r22043 r22067  
    4242 
    4343 
    44 mssqldbclass::mssqldbclass () 
     44mssqldbclass::mssqldbclass (const text_t& gsdlhome) 
     45  : sqldbclass(gsdlhome) 
    4546{ 
    4647  dbptr = NULL; 
  • main/trunk/greenstone2/common-src/src/lib/mssqldbclass.h

    r22043 r22067  
    3838 public: 
    3939 
    40   mssqldbclass (); 
     40  mssqldbclass (const text_t& gsdlhome); 
    4141  virtual ~mssqldbclass (); 
    4242   
  • main/trunk/greenstone2/common-src/src/lib/sqldbclass.cpp

    r22057 r22067  
    2626#include "sqldbclass.h" 
    2727 
    28 sqldbclass::sqldbclass()  
     28sqldbclass::sqldbclass(const text_t& gsdlhome)  
     29  : dbclass(gsdlhome) 
    2930{  
    3031} 
  • main/trunk/greenstone2/common-src/src/lib/sqldbclass.h

    r22043 r22067  
    3636{ 
    3737public: 
    38   sqldbclass(); 
     38  sqldbclass(const text_t& gsdlhome); 
    3939  virtual ~sqldbclass(); 
    4040 
  • main/trunk/greenstone2/common-src/src/lib/sqlitedbclass.cpp

    r22043 r22067  
    3939#define SQLITE_MAX_RETRIES 8 
    4040 
    41 sqlitedbclass::sqlitedbclass()  
     41sqlitedbclass::sqlitedbclass(const text_t& gsdlhome)  
     42  : sqldbclass(gsdlhome) 
    4243{  
    4344  sqlitefile = NULL;  
  • main/trunk/greenstone2/common-src/src/lib/sqlitedbclass.h

    r22043 r22067  
    3636{ 
    3737public: 
    38   sqlitedbclass(); 
     38  sqlitedbclass(const text_t& gsdlhome); 
    3939  virtual ~sqlitedbclass(); 
    4040 
  • main/trunk/greenstone2/runtime-src/src/colservr/collectset.cpp

    r22050 r22067  
    339339      { 
    340340#ifdef USE_SQLITE 
    341     sqlitedbclass *sql_db_ptr = new sqlitedbclass(); 
     341    sqlitedbclass *sql_db_ptr = new sqlitedbclass(gsdlhome); 
    342342    db_ptr = sql_db_ptr; 
    343343 
     
    361361      { 
    362362#ifdef USE_MSSQL 
    363     mssqldbclass *mssql_db_ptr = new mssqldbclass(); 
     363    mssqldbclass *mssql_db_ptr = new mssqldbclass(gsdlhome); 
    364364    db_ptr = mssql_db_ptr; 
    365365 
     
    388388    if (db_ptr == NULL) { 
    389389#ifdef USE_GDBM 
    390       db_ptr = new gdbmclass(); 
     390      db_ptr = new gdbmclass(gsdlhome); 
    391391#else 
    392392    cerr << "Warning: infodbtype of 'gdbm' was not compiled in to " << endl; 
  • main/trunk/greenstone2/runtime-src/src/recpt/argdb.cpp

    r15683 r22067  
    2727#ifdef GSDL_USE_COLLECTOR_ACTION 
    2828 
     29#include "fileutil.h" 
     30 
    2931// argdb is used by the collector for storing cgi arguments on disk (in a database) 
    3032 
    3133#include "argdb.h" 
     34 
     35#if defined(USE_GDBM) 
    3236#include "gdbmclass.h" 
     37#define DBCLASS gdbmclass 
     38#define DBFNAME "argdb.gdb" 
    3339 
    34 argdb::argdb (const text_t &filename) { 
    35   dbfile = filename; 
     40#elif defined(USE_JDBM) 
     41#include "jdbmnaiveclass.h" 
     42#define DBCLASS jdbmnaiveclass 
     43#define DBFNAME "argdb.jdb" 
     44 
     45#elif defined(USE_SQLITE) 
     46#include "sqlitedbclass.h" 
     47#define DBCLASS sqlitedbclass 
     48#define DBFNAME "argdb.litedb" 
     49 
     50#elif defined(USE_MSSQL) 
     51#include "mssqldbclass.h" 
     52#define DBCLASS mssqldbclass 
     53#define DBFNAME "argdb.msdb" 
     54 
     55#else 
     56#error "Unable to compile Greenstone. Need at least one database backend enabled." 
     57#endif 
     58 
     59 
     60argdb::argdb (const text_t& gsdlhome, const text_t &args_tmp) { 
     61 
     62  gsdlhome_ = gsdlhome; 
     63  dbfile_ = filename_cat(gsdlhome, "tmp", args_tmp, DBFNAME); 
     64 
    3665} 
    3766   
    3867bool argdb::update_args (text_tmap &argmap) { 
    39   gdbmclass argdb; 
    40   if (!argdb.opendatabase(dbfile, DB_WRITER_CREATE, 1000, true)) return false; 
     68 
     69  DBCLASS argdb(gsdlhome_); 
     70  if (!argdb.opendatabase(dbfile_, DB_WRITER_CREATE, 1000, true)) return false; 
    4171  infodbclass info; 
    4272   
     
    5989bool argdb::get_args (text_tmap &argmap) { 
    6090  argmap.erase(argmap.begin(), argmap.end()); 
    61   gdbmclass argdb; 
    62   if (!argdb.opendatabase(dbfile, DB_READER, 1000, true)) return false; 
     91  DBCLASS argdb(gsdlhome_); 
     92  if (!argdb.opendatabase(dbfile_, DB_READER, 1000, true)) return false; 
    6393  infodbclass info; 
    6494   
  • main/trunk/greenstone2/runtime-src/src/recpt/argdb.h

    r15432 r22067  
    3636protected: 
    3737 
    38   text_t dbfile; 
     38  text_t gsdlhome_; 
     39  text_t dbfile_; 
    3940 
    4041public: 
    4142   
    42   argdb (const text_t &filename); 
     43  argdb (const text_t& gsdlhome, const text_t &args_tmp); 
    4344  virtual ~argdb () {} 
    4445   
  • main/trunk/greenstone2/runtime-src/src/recpt/collectoraction.cpp

    r21877 r22067  
    306306    } 
    307307 
    308     text_t argfile = filename_cat(gsdlhome, "tmp", args["bc1tmp"], "argdb.gdb"); 
    309     argdb *args_on_disk = new argdb(argfile); 
     308    argdb *args_on_disk = new argdb(gsdlhome,args["bc1tmp"]); 
    310309    if (!args_on_disk->update_args(saved_args)) { 
    311310      // error 
    312       logout << "collectoraction: argdb::update_args failed (" << argfile << ")\n"; 
     311      logout << "collectoraction: argdb::update_args failed\n"; 
    313312    } 
    314313 
     
    317316    if (!args_on_disk->get_args(saved_args)) { 
    318317      // error 
    319       logout << "collectoraction: argdb::get_args failed (" << argfile << ")\n"; 
     318      logout << "collectoraction: argdb::get_args failed\n"; 
    320319    } 
    321320    delete args_on_disk; 
  • main/trunk/greenstone2/runtime-src/src/recpt/historydb.cpp

    r21485 r22067  
    3131#include "dbclass.h" 
    3232 
    33 #ifdef USE_GDBM 
     33#if defined(USE_GDBM) 
    3434#include "gdbmclass.h" 
     35#define DBCLASS gdbmclass 
     36//#define DBFNAME "history.gdb" 
     37 
     38#elif defined(USE_JDBM) 
     39#include "jdbmnaiveclass.h" 
     40#define DBCLASS jdbmnaiveclass 
     41//#define DBFNAME "history.jdb" 
     42 
     43#elif defined(USE_SQLITE) 
     44#include "sqlitedbclass.h" 
     45#define DBCLASS sqlitedbclass 
     46//#define DBFNAME "history.litedb" 
     47 
     48#elif defined(USE_MSSQL) 
     49#include "mssqldbclass.h" 
     50#define DBCLASS mssqldbclass 
     51//#define DBFNAME "history.msdb" 
     52 
     53#else 
     54#error "Unable to compile Greenstone. Need at least one database backend enabled." 
    3555#endif 
    3656 
     
    4060 
    4161 
    42 dbclass* get_history_db_ptr () 
     62dbclass* get_history_db_ptr (const text_t& gsdlhome) 
    4363{ 
    4464  // Create a dbclass of the correct type 
    4565  dbclass *historydb = NULL; 
    4666 
    47   // Use GDBM only at this stage 
    48 #ifdef USE_GDBM 
    49     historydb = new gdbmclass(); 
    50 #endif 
     67  historydb = new DBCLASS(gsdlhome); 
    5168 
    5269  return historydb; 
     
    6279 
    6380  // Create a dbclass of the correct type 
    64   dbclass *historydb = get_history_db_ptr(); 
     81  dbclass *historydb = get_history_db_ptr(gsdlhome); 
    6582  if (historydb == NULL) return false; 
    6683  text_t historyfile = filename_cat(gsdlhome, "etc", "history") + historydb->getfileextension(); 
     
    98115 
    99116  // Create a dbclass of the correct type 
    100   dbclass *historydb = get_history_db_ptr(); 
     117  dbclass *historydb = get_history_db_ptr(gsdlhome); 
    101118  if (historydb == NULL) return false; 
    102119  text_t historyfile = filename_cat(gsdlhome, "etc", "history") + historydb->getfileextension(); 
     
    153170 
    154171  // Create a dbclass of the correct type 
    155   dbclass *historydb = get_history_db_ptr(); 
     172  dbclass *historydb = get_history_db_ptr(gsdlhome); 
    156173  if (historydb == NULL) return false; 
    157174  text_t historyfile = filename_cat(gsdlhome, "etc", "history") + historydb->getfileextension(); 
  • main/trunk/greenstone2/runtime-src/src/recpt/librarymain.cpp

    r22046 r22067  
    157157  recpt.add_action (adocumentaction); 
    158158 
    159   text_t userdbfile = filename_cat(gsdlhome, "etc", "users.gdb"); 
    160   userdbclass *udb = new userdbclass(userdbfile); 
    161  
    162   text_t keydbfile = filename_cat(gsdlhome, "etc", "key.gdb"); 
    163   keydbclass *kdb = new keydbclass(keydbfile); 
     159  userdbclass *udb = new userdbclass(gsdlhome); 
     160  keydbclass *kdb = new keydbclass(gsdlhome); 
    164161 
    165162#ifdef GSDL_USE_USERS_ACTION 
  • main/trunk/greenstone2/runtime-src/src/recpt/userdb.cpp

    r21489 r22067  
    3030#include <stdlib.h> 
    3131 
    32 #ifdef USE_GDBM 
     32 
     33#if defined(USE_GDBM) 
    3334#include "gdbmclass.h" 
     35#define DBCLASS gdbmclass 
     36#define USERDBFNAME "users.gdb" 
     37#define KEYDBFNAME "key.gdb" 
     38 
     39#elif defined(USE_JDBM) 
     40#include "jdbmnaiveclass.h" 
     41#define DBCLASS jdbmnaiveclass 
     42#define USERDBFNAME "users.jdb" 
     43#define KEYDBFNAME "key.jdb" 
     44 
     45#elif defined(USE_SQLITE) 
     46#include "sqlitedbclass.h" 
     47#define DBCLASS sqlitedbclass 
     48#define USERDBFNAME "users.litedb" 
     49#define KEYDBFNAME "key.litedb" 
     50 
     51#elif defined(USE_MSSQL) 
     52#include "mssqldbclass.h" 
     53#define DBCLASS mssqldbclass 
     54#define USERDBFNAME "users.msdb" 
     55#define KEYDBFNAME "key.msdb" 
     56 
     57#else 
     58#error "Unable to compile Greenstone. Need at least one database backend enabled." 
    3459#endif 
     60 
    3561 
    3662// include crypt 
     
    4571#endif 
    4672 
     73 
    4774//==========================================// 
    4875//      userinfo_t functions (Start)        // 
     
    79106//      userdbclass functions (Start)       // 
    80107//==========================================// 
    81 userdbclass::userdbclass(const text_t &userdbfilename) 
    82 { 
    83   storeduserdbfilename = userdbfilename; 
     108userdbclass::userdbclass(const text_t &gsdlhome) 
     109{ 
     110 
     111  storeduserdbfilename = filename_cat(gsdlhome, "etc", USERDBFNAME); 
    84112 
    85113  // Create a dbclass of the correct type 
    86114  userdb = NULL; 
    87115 
    88   // Use GDBM only at this stage 
    89 #ifdef USE_GDBM 
    90   userdb = new gdbmclass(); 
    91 #endif 
     116  // Use the correct database type 
     117  userdb = new DBCLASS(gsdlhome); 
    92118 
    93119  // Check a dbclass of some type has been created 
     
    385411//      keydbclass functions (Start)        // 
    386412//==========================================// 
    387 keydbclass::keydbclass(const text_t &keydbfilename) 
    388 { 
    389   storedkeydbfilename = keydbfilename; 
     413keydbclass::keydbclass(const text_t &gsdlhome) 
     414{ 
     415  storedkeydbfilename = filename_cat(gsdlhome, "etc", KEYDBFNAME); 
    390416 
    391417  // Create a dbclass of the correct type 
    392418  keydb = NULL; 
    393419 
    394   // Use GDBM only at this stage 
    395 #ifdef USE_GDBM 
    396   keydb = new gdbmclass(); 
    397 #endif 
     420  // Use the correct DB class type at this stage 
     421  keydb = new DBCLASS(gsdlhome); 
    398422 
    399423  // Check a dbclass of some type has been created 
  • main/trunk/greenstone2/runtime-src/src/recpt/userdb.h

    r15586 r22067  
    6767   
    6868 public: 
    69   userdbclass (const text_t &userdbfilename); 
     69  userdbclass (const text_t &gsdlhome); 
    7070  virtual ~userdbclass(); 
    7171 
     
    126126   
    127127 public: 
    128   keydbclass (const text_t &keydbfilename); 
     128  keydbclass (const text_t &gsdlhome); 
    129129  virtual ~keydbclass(); 
    130130  // functions dealing with databases of temporary keys 
  • main/trunk/greenstone2/runtime-src/src/recpt/wizardaction.cpp

    r21877 r22067  
    127127    } 
    128128       
    129     text_t argfile = filename_cat(gsdlhome, "tmp", args[macro_prefix+"tmp"], "argdb.gdb"); 
    130     argdb *args_on_disk = new argdb(argfile); 
     129    argdb *args_on_disk = new argdb(gsdlhome,args[macro_prefix+"tmp"]); 
    131130    if (!args_on_disk->update_args(saved_args)) { 
    132131      // error 
    133       logout << "wizardaction: argdb::update_args failed (" << argfile << ")\n"; 
     132      logout << "wizardaction: argdb::update_args failed\n"; 
    134133    } 
    135134     
     
    138137    if (!args_on_disk->get_args(saved_args)) { 
    139138      // error 
    140       logout << "wizardaction: argdb::get_args failed (" << argfile << ")\n"; 
     139      logout << "wizardaction: argdb::get_args failed\n"; 
    141140    } 
    142141    delete args_on_disk;