]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application.pm
Address long-standing typo: clense_ISO8601, matching change to OpenSRF-trunk.
[working/Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application.pm
1 package OpenILS::Application;
2 use OpenSRF::Application;
3 use UNIVERSAL::require;
4 use base qw/OpenSRF::Application/;
5
6 sub ils_version {
7     # version format is "x-y-z-p", for example "1-2-1-0" for Evergreen 1.2.1.0
8     return "1-5";
9 }
10
11 __PACKAGE__->register_method(
12     api_name    => 'opensrf.open-ils.system.ils_version',
13     api_level   => 1,
14     method      => 'ils_version',
15 );
16
17 __PACKAGE__->register_method(
18     api_name => 'opensrf.open-ils.fetch_idl.file',
19     api_level => 1,
20     method => 'get_idl_file',
21 );
22 sub get_idl_file {
23     use OpenSRF::Utils::SettingsClient;
24     return OpenSRF::Utils::SettingsClient->new->config_value('IDL');
25 }
26
27 sub register_method {
28     my $class = shift;
29     my %args = @_;
30     my %dup_args = %args;
31
32     $class = ref($class) || $class;
33
34     $args{package} ||= $class;
35     __PACKAGE__->SUPER::register_method( %args );
36
37     if (exists($dup_args{authoritative}) and $dup_args{authoritative}) {
38         (my $name = $dup_args{api_name}) =~ s/$/.authoritative/o;
39         if ($name ne $dup_args{api_name}) {
40             $dup_args{real_api_name} = $dup_args{api_name};
41             $dup_args{method} = 'authoritative_wrapper';
42             $dup_args{api_name} = $name;
43             $dup_args{package} = __PACKAGE__;
44             __PACKAGE__->SUPER::register_method( %dup_args );
45         }
46     }
47 }
48
49 sub authoritative_wrapper {
50
51     if (!$OpenILS::Utils::CStoreEditor::_loaded) {
52         die "Couldn't load OpenILS::Utils::CStoreEditor!" unless 'OpenILS::Utils::CStoreEditor'->use;
53     }
54
55     my $self = shift;
56     my $client = shift;
57     my @args = @_;
58
59     my $method = $self->method_lookup($self->{real_api_name});
60     die unless $method;
61
62     local $OpenILS::Utils::CStoreEditor::always_xact = 1;
63
64     $client->respond( $_ ) for ( $method->run(@args) );
65
66     OpenILS::Utils::CStoreEditor->flush_forced_xacts();
67
68     return undef;
69 }
70
71 1;
72