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);
10 use OpenILS::Application::Storage::FTS;
13 # the easy way to get to the logger...
14 my $log = "OpenSRF::Utils::Logger";
20 my $conf = OpenSRF::Utils::SettingsClient->new;
22 $log->debug('Initializing ' . __PACKAGE__ . '...', DEBUG);
24 my $driver = "OpenILS::Application::Storage::Driver::".
25 $conf->config_value( apps => 'open-ils.storage' => app_settings => databases => 'driver');
28 $log->debug("Attempting to load $driver ...", DEBUG);
32 $log->debug( "Can't load $driver! : $@", ERROR );
33 $log->error( "Can't load $driver! : $@");
34 throw OpenILS::EX::PANIC ( "Can't load $driver! : $@" );
37 $log->debug("$driver loaded successfully", DEBUG);
39 # Suck in the method publishing modules
40 @OpenILS::Application::Storage::CDBI::ISA = ( $driver );
42 eval 'use OpenILS::Application::Storage::Publisher;';
43 eval 'use OpenILS::Application::Storage::WORM;';
48 $log->debug('Running child_init for ' . __PACKAGE__ . '...', DEBUG);
50 my $conf = OpenSRF::Utils::SettingsClient->new;
52 $log->debug('Calling the Driver child_init', DEBUG);
53 OpenILS::Application::Storage::CDBI->child_init(
54 $conf->config_value( apps => 'open-ils.storage' => app_settings => databases => 'database')
57 if (OpenILS::Application::Storage::CDBI->db_Main()) {
58 OpenILS::Application::Storage::WORM->child_init();
59 $log->debug("Success initializing driver!", DEBUG);
69 $log->debug(" XACT --> 'BEGIN'ing transaction for session ".$client->session->session_id,DEBUG);
70 return OpenILS::Application::Storage::CDBI->db_Main->begin_work;
72 __PACKAGE__->register_method(
73 method => 'begin_xaction',
74 api_name => 'open-ils.storage.transaction.begin',
83 $log->debug(" XACT --> 'COMMIT'ing transaction for session ".$client->session->session_id,DEBUG);
84 return OpenILS::Application::Storage::CDBI->db_Main->commit;
86 __PACKAGE__->register_method(
87 method => 'commit_xaction',
88 api_name => 'open-ils.storage.transaction.commit',
94 sub rollback_xaction {
98 $log->debug(" XACT --> 'ROLLBACK'ing transaction for session ".$client->session->session_id,DEBUG);
99 return OpenILS::Application::Storage::CDBI->db_Main->rollback;
101 __PACKAGE__->register_method(
102 method => 'rollback_xaction',
103 api_name => 'open-ils.storage.transaction.rollback',
112 return { map { ( $_ => $obj->$_ ) } ($obj->columns('All')) };
118 return [ map { $self->_cdbi2Hash($_) } @objs ];