1 package OpenILS::Application::Storage;
2 use OpenSRF::Application;
3 use base qw/OpenSRF::Application/;
5 use OpenSRF::EX qw/:try/;
6 use OpenSRF::Utils::Logger qw/:level/;
8 # Pull this in so we can adjust it's @ISA
9 use OpenILS::Application::Storage::CDBI (1);
11 use OpenILS::Application::Storage::FTS;
13 # Suck in the method publishing modules
14 use OpenILS::Application::Storage::Publisher;
15 use OpenILS::Application::Storage::WORM;
17 # the easy way to get to the logger...
18 my $log = "OpenSRF::Utils::Logger";
24 my $conf = OpenSRF::Utils::SettingsClient->new;
26 $log->debug('Initializing ' . __PACKAGE__ . '...', DEBUG);
28 my $driver = "OpenILS::Application::Storage::Driver::".
29 $conf->config_value( apps => 'open-ils.storage' => app_settings => databases => 'driver');
32 $log->debug("Attempting to load $driver ...", DEBUG);
36 $log->debug( "Can't load $driver! : $@", ERROR );
37 $log->error( "Can't load $driver! : $@");
38 throw OpenILS::EX::PANIC ( "Can't load $driver! : $@" );
41 $log->debug("$driver loaded successfully", DEBUG);
43 @OpenILS::Application::Storage::CDBI::ISA = ( $driver );
48 $log->debug('Running child_init for ' . __PACKAGE__ . '...', DEBUG);
50 my $conf = OpenSRF::Utils::SettingsClient->new;
52 # XXX -- this died... router down?
53 #$log->debug('Prepopulating method_lookup cache', DEBUG);
54 #OpenSRF::Application->method_lookup('crappola');
56 $log->debug('Calling the Driver child_init', DEBUG);
57 OpenILS::Application::Storage::CDBI->child_init(
58 $conf->config_value( apps => 'open-ils.storage' => app_settings => databases => 'database')
61 if (OpenILS::Application::Storage::CDBI->db_Main()) {
62 $log->debug("Success initializing driver!", DEBUG);
72 $log->debug(" XACT --> 'BEGIN'ing transaction for session ".$client->session->session_id,DEBUG);
73 return OpenILS::Application::Storage::CDBI->db_Main->begin_work;
75 __PACKAGE__->register_method(
76 method => 'begin_xaction',
77 api_name => 'open-ils.storage.transaction.begin',
86 $log->debug(" XACT --> 'COMMIT'ing transaction for session ".$client->session->session_id,DEBUG);
87 return OpenILS::Application::Storage::CDBI->db_Main->commit;
89 __PACKAGE__->register_method(
90 method => 'commit_xaction',
91 api_name => 'open-ils.storage.transaction.commit',
97 sub rollback_xaction {
101 $log->debug(" XACT --> 'ROLLBACK'ing transaction for session ".$client->session->session_id,DEBUG);
102 return OpenILS::Application::Storage::CDBI->db_Main->rollback;
104 __PACKAGE__->register_method(
105 method => 'rollback_xaction',
106 api_name => 'open-ils.storage.transaction.rollback',
115 return { map { ( $_ => $obj->$_ ) } ($obj->columns('All')) };
121 return [ map { $self->_cdbi2Hash($_) } @objs ];