From ef604e1639c7c64a9101f43278c4cdb5a764750d Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 2 Jul 2007 15:11:15 +0000 Subject: [PATCH] Patch from Dan Scott to move JSON to OpenSRF::Utils::JSON: I noticed back when I was first installing OpenSRF that it includes a module, JSON.pm, that exists at the root level of the package directories. This would be fine, except it conflicts with a CPAN module that is also named JSON, which confuses the CPAN installer when you check for upgrades and conceivably could lead to a broken system. I suggested to Mike that it would probably make sense to move the OpenSRF version of the module into the OpenSRF/Utils/ package namespace, and he agreed. Of course, there are ramifications throughout the code, so I've tried to be extra-careful in catching and correcting all of the places where the use of this module surfaces in both OpenSRF and Evergreen. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@989 9efc2488-bf62-4759-914b-345cdb29e865 --- examples/fieldmapper2perl.xsl | 2 +- examples/multisession-test.pl | 7 +++--- src/perlmods/JSON.pm | 28 ++++++++++----------- src/perlmods/OpenSRF/AppSession.pm | 3 ++- src/perlmods/OpenSRF/Application.pm | 8 +++--- src/perlmods/OpenSRF/Application/Demo/MathDB.pm | 10 ++++---- src/perlmods/OpenSRF/Application/Persist.pm | 16 ++++++------ src/perlmods/OpenSRF/DomainObject/oilsMessage.pm | 8 +++--- src/perlmods/OpenSRF/DomainObject/oilsMethod.pm | 8 +++--- src/perlmods/OpenSRF/DomainObject/oilsResponse.pm | 30 +++++++++++------------ src/perlmods/OpenSRF/System.pm | 2 +- src/perlmods/OpenSRF/Transport.pm | 3 ++- src/perlmods/OpenSRF/UnixServer.pm | 4 +-- src/perlmods/OpenSRF/Utils/Cache.pm | 8 +++--- 14 files changed, 69 insertions(+), 68 deletions(-) diff --git a/examples/fieldmapper2perl.xsl b/examples/fieldmapper2perl.xsl index 4d3a8a5..8ef601e 100644 --- a/examples/fieldmapper2perl.xsl +++ b/examples/fieldmapper2perl.xsl @@ -13,7 +13,7 @@ package Fieldmapper; -use JSON; +use OpenSRF::Utils::JSON; use Data::Dumper; use base 'OpenSRF::Application'; diff --git a/examples/multisession-test.pl b/examples/multisession-test.pl index bb75a46..21c0c99 100755 --- a/examples/multisession-test.pl +++ b/examples/multisession-test.pl @@ -4,7 +4,7 @@ use OpenSRF::System; use OpenILS::Application::AppUtils; use OpenILS::Event; use OpenSRF::EX qw/:try/; -use JSON; +use OpenSRF::Utils::JSON; use Data::Dumper; use OpenILS::Utils::Fieldmapper; use Digest::MD5 qw/md5_hex/; @@ -12,7 +12,6 @@ use OpenSRF::Utils qw/:daemon/; use OpenSRF::MultiSession; use OpenSRF::AppSession; use Time::HiRes qw/time/; -use JSON; my $config = shift; @@ -37,7 +36,7 @@ $mses->success_handler( sub { my $ses = shift; my $req = shift; - print $req->{params}->[0] . "\t: " . JSON->perl2JSON($req->{response}->[0]->content)."\n"; + print $req->{params}->[0] . "\t: " . OpenSRF::Utils::JSON->perl2JSON($req->{response}->[0]->content)."\n"; } ); @@ -45,7 +44,7 @@ $mses->failure_handler( sub { my $ses = shift; my $req = shift; - warn "record $req->{params}->[0] failed: ".JSON->perl2JSON($req->{response}); + warn "record $req->{params}->[0] failed: " . OpenSRF::Utils::JSON->perl2JSON($req->{response}); } ); diff --git a/src/perlmods/JSON.pm b/src/perlmods/JSON.pm index 2128f96..b417425 100644 --- a/src/perlmods/JSON.pm +++ b/src/perlmods/JSON.pm @@ -1,5 +1,5 @@ -package JSON::number; +package OpenSRF::Utils::JSON::number; sub new { my $class = shift; my $x = shift || $class; @@ -10,7 +10,7 @@ use overload ( '""' => \&toString ); sub toString { defined($_[1]) ? ${$_[1]} : ${$_[0]} } -package JSON::bool::true; +package OpenSRF::Utils::JSON::bool::true; sub new { return bless {} => __PACKAGE__ } use overload ( '""' => \&toString ); use overload ( 'bool' => sub { 1 } ); @@ -18,7 +18,7 @@ use overload ( '0+' => sub { 1 } ); sub toString { 'true' } -package JSON::bool::false; +package OpenSRF::Utils::JSON::bool::false; sub new { return bless {} => __PACKAGE__ } use overload ( '""' => \&toString ); use overload ( 'bool' => sub { 0 } ); @@ -26,7 +26,7 @@ use overload ( '0+' => sub { 0 } ); sub toString { 'false' } -package JSON; +package OpenSRF::Utils::JSON; use Unicode::Normalize; use vars qw/%_class_map/; @@ -80,7 +80,7 @@ sub _json_hint_to_class { $type = 'hash' if ($type eq '}'); $type = 'array' if ($type eq ']'); - JSON->register_class_hint(name => $hint, hint => $hint, type => $type); + OpenSRF::Utils::JSON->register_class_hint(name => $hint, hint => $hint, type => $type); return $hint; } @@ -112,12 +112,12 @@ sub JSON2perl { s/:/ => /sog; # Do numbers... - #s/\b(-?\d+\.?\d*)\b/ JSON::number::new($1) /sog; + #s/\b(-?\d+\.?\d*)\b/ OpenSRF::Utils::JSON::number::new($1) /sog; # Change javascript stuff to perl... s/null/ undef /sog; - s/true/ bless( {}, "JSON::bool::true") /sog; - s/false/ bless( {}, "JSON::bool::false") /sog; + s/true/ bless( {}, "OpenSRF::Utils::JSON::bool::true") /sog; + s/false/ bless( {}, "OpenSRF::Utils::JSON::bool::false") /sog; my $ret; return eval '$ret = '.$_; @@ -638,7 +638,7 @@ sub old_JSON2perl { } elsif ($element =~ /^\/\*/) { next; } elsif ($element =~ /^\d/) { - $output .= "do { JSON::number::new($element) }"; + $output .= "do { OpenSRF::Utils::JSON::number::new($element) }"; next; } elsif ($element eq '{' or $element eq '[') { $casting_depth++; @@ -654,10 +654,10 @@ sub old_JSON2perl { $output .= ' => '; next; } elsif ($element eq 'true') { - $output .= 'bless( {}, "JSON::bool::true")'; + $output .= 'bless( {}, "OpenSRF::Utils::JSON::bool::true")'; next; } elsif ($element eq 'false') { - $output .= 'bless( {}, "JSON::bool::false")'; + $output .= 'bless( {}, "OpenSRF::Utils::JSON::bool::false")'; next; } @@ -674,7 +674,7 @@ sub perl2JSON { if (!defined($perl)) { $output = '' if $strict; $output = 'null' unless $strict; - } elsif (ref($perl) and ref($perl) =~ /^JSON/) { + } elsif (ref($perl) and ref($perl) =~ /^OpenSRF::Utils::JSON/) { $output .= $perl; } elsif ( ref($perl) && exists($_class_map{classes}{ref($perl)}) ) { $output .= '/*--S '.$_class_map{classes}{ref($perl)}{hint}.'--*/'; @@ -720,7 +720,7 @@ sub perl2JSON { } elsif (ref($perl) and ("$perl" =~ /^([^=]+)=(\w+)/o)) { my $type = $2; my $name = $1; - JSON->register_class_hint(name => $name, hint => $name, type => lc($type)); + OpenSRF::Utils::JSON->register_class_hint(name => $name, hint => $name, type => lc($type)); $output .= perl2JSON(undef,$perl, $strict); } else { $perl = NFC($perl); @@ -750,7 +750,7 @@ sub perl2prettyJSON { if (!defined($perl)) { $output = " "x$depth unless($nospace); $output .= 'null'; - } elsif (ref($perl) and ref($perl) =~ /^JSON/) { + } elsif (ref($perl) and ref($perl) =~ /^OpenSRF::Utils::JSON/) { $output = " "x$depth unless($nospace); $output .= $perl; } elsif ( ref($perl) && exists($_class_map{classes}{ref($perl)}) ) { diff --git a/src/perlmods/OpenSRF/AppSession.pm b/src/perlmods/OpenSRF/AppSession.pm index 6c32af1..3dcfc61 100644 --- a/src/perlmods/OpenSRF/AppSession.pm +++ b/src/perlmods/OpenSRF/AppSession.pm @@ -5,6 +5,7 @@ use OpenSRF::DomainObject::oilsMessage; use OpenSRF::DomainObject::oilsMethod; use OpenSRF::DomainObject::oilsResponse qw/:status/; use OpenSRF::Transport::PeerHandle; +use OpenSRF::Utils::JSON; use OpenSRF::Utils::Logger qw(:level); use OpenSRF::Utils::SettingsClient; use OpenSRF::Utils::Config; @@ -531,7 +532,7 @@ sub send { } } - my $json = JSON->perl2JSON(\@doc); + my $json = OpenSRF::Utils::JSON->perl2JSON(\@doc); $logger->internal("AppSession sending doc: $json"); $self->{peer_handle}->send( diff --git a/src/perlmods/OpenSRF/Application.pm b/src/perlmods/OpenSRF/Application.pm index 0b3f9b7..71e62a4 100644 --- a/src/perlmods/OpenSRF/Application.pm +++ b/src/perlmods/OpenSRF/Application.pm @@ -10,7 +10,7 @@ use Data::Dumper; use Time::HiRes qw/time/; use OpenSRF::EX qw/:try/; use Carp; -use JSON; +use OpenSRF::Utils::JSON; #use OpenSRF::UnixServer; # to get the server class from UnixServer::App sub DESTROY{}; @@ -148,7 +148,7 @@ sub handler { for my $p (0 .. scalar(@{ $sig->{params} }) - 1 ) { my $s = $sig->{params}->[$p]; my $a = $args[$p]; - if ($s->{class} && JSON->lookup_hint(ref $a) ne $s->{class}) { + if ($s->{class} && OpenSRF::Utils::JSON->lookup_hint(ref $a) ne $s->{class}) { die "Incorrect param class at position $p : should be a '$$s{class}'"; } elsif ($s->{type}) { if (lc($s->{type}) eq 'object' && $a !~ /HASH/o) { @@ -225,7 +225,7 @@ sub handler { for my $p (0 .. scalar(@{ $sig->{params} }) - 1 ) { my $s = $sig->{params}->[$p]; my $a = $args[$p]; - if ($s->{class} && JSON->lookup_hint(ref $a) ne $s->{class}) { + if ($s->{class} && OpenSRF::Utils::JSON->lookup_hint(ref $a) ne $s->{class}) { die "Incorrect param class at position $p : should be a '$$s{class}'"; } elsif ($s->{type}) { if (lc($s->{type}) eq 'object' && $a !~ /HASH/o) { @@ -393,7 +393,7 @@ sub register_method { ($args{object_hint} = $args{package}) =~ s/::/_/go; } - JSON->register_class_hint( name => $args{package}, hint => $args{object_hint}, type => "hash" ); + OpenSRF::Utils::JSON->register_class_hint( name => $args{package}, hint => $args{object_hint}, type => "hash" ); $_METHODS[$args{api_level}]{$args{api_name}} = bless \%args => $app; diff --git a/src/perlmods/OpenSRF/Application/Demo/MathDB.pm b/src/perlmods/OpenSRF/Application/Demo/MathDB.pm index eb90345..69985a6 100644 --- a/src/perlmods/OpenSRF/Application/Demo/MathDB.pm +++ b/src/perlmods/OpenSRF/Application/Demo/MathDB.pm @@ -1,5 +1,5 @@ package OpenSRF::Application::Demo::MathDB; -use JSON; +use OpenSRF::Utils::JSON; use base qw/OpenSRF::Application/; use OpenSRF::Application; use OpenSRF::DomainObject::oilsResponse qw/:status/; @@ -20,7 +20,7 @@ sub add_1 { my $n1 = shift; my $n2 = shift; my $a = $n1 + $n2; - return JSON::number->new($a); + return OpenSRF::Utils::JSON::number->new($a); } __PACKAGE__->register_method( method => 'sub_1', api_name => 'dbmath.sub' ); @@ -31,7 +31,7 @@ sub sub_1 { my $n1 = shift; my $n2 = shift; my $a = $n1 - $n2; - return JSON::number->new($a); + return OpenSRF::Utils::JSON::number->new($a); } __PACKAGE__->register_method( method => 'mult_1', api_name => 'dbmath.mult' ); @@ -42,7 +42,7 @@ sub mult_1 { my $n1 = shift; my $n2 = shift; my $a = $n1 * $n2; - return JSON::number->new($a); + return OpenSRF::Utils::JSON::number->new($a); } __PACKAGE__->register_method( method => 'div_1', api_name => 'dbmath.div' ); @@ -53,7 +53,7 @@ sub div_1 { my $n1 = shift; my $n2 = shift; my $a = $n1 / $n2; - return JSON::number->new($a); + return OpenSRF::Utils::JSON::number->new($a); } 1; diff --git a/src/perlmods/OpenSRF/Application/Persist.pm b/src/perlmods/OpenSRF/Application/Persist.pm index 1099dba..b8b291f 100644 --- a/src/perlmods/OpenSRF/Application/Persist.pm +++ b/src/perlmods/OpenSRF/Application/Persist.pm @@ -6,7 +6,7 @@ use OpenSRF::Utils::SettingsClient; use OpenSRF::EX qw/:try/; use OpenSRF::Utils qw/:common/; use OpenSRF::Utils::Logger; -use JSON; +use OpenSRF::Utils::JSON; use DBI; use vars qw/$dbh $log $default_expire_time/; @@ -227,7 +227,7 @@ sub add_item { $dbh->do('DELETE FROM storage WHERE name_id = ?;', {}, $name_id); } - $dbh->do('INSERT INTO storage (name_id,value) VALUES (?,?);', {}, $name_id, JSON->perl2JSON($value)); + $dbh->do('INSERT INTO storage (name_id,value) VALUES (?,?);', {}, $name_id, OpenSRF::Utils::JSON->perl2JSON($value)); _flush_by_name($name); @@ -344,7 +344,7 @@ sub pop_queue { _flush_by_name($name); - return JSON->JSON2perl( $value->[1] ); + return OpenSRF::Utils::JSON->JSON2perl( $value->[1] ); } catch Error with { #my $e = shift; #return $e; @@ -377,7 +377,7 @@ sub peek_slot { my $values = $dbh->selectall_arrayref("SELECT value FROM storage WHERE name_id = ? ORDER BY id $order;", {}, $name_id); - $client->respond( JSON->JSON2perl( $_->[0] ) ) for (@$values); + $client->respond( OpenSRF::Utils::JSON->JSON2perl( $_->[0] ) ) for (@$values); _flush_by_name($name); return undef; @@ -407,7 +407,7 @@ sub store_size { my $value = $dbh->selectcol_arrayref('SELECT SUM(LENGTH(value)) FROM storage WHERE name_id = ?;', {}, $name_id); - return JSON->JSON2perl( $value->[0] ); + return OpenSRF::Utils::JSON->JSON2perl( $value->[0] ); } __PACKAGE__->register_method( api_name => 'opensrf.persist.queue.size', @@ -436,7 +436,7 @@ sub store_depth { my $value = $dbh->selectcol_arrayref('SELECT COUNT(*) FROM storage WHERE name_id = ?;', {}, $name_id); - return JSON->JSON2perl( $value->[0] ); + return OpenSRF::Utils::JSON->JSON2perl( $value->[0] ); } __PACKAGE__->register_method( api_name => 'opensrf.persist.queue.length', @@ -465,7 +465,7 @@ sub shift_stack { _flush_by_name($name); - return JSON->JSON2perl( $value->[1] ); + return OpenSRF::Utils::JSON->JSON2perl( $value->[1] ); } catch Error with { my $e = shift; return undef; @@ -498,7 +498,7 @@ sub get_object { _flush_by_name($name); - return JSON->JSON2perl( $value->[1] ); + return OpenSRF::Utils::JSON->JSON2perl( $value->[1] ); } catch Error with { return undef; }; diff --git a/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm b/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm index 56fa9d3..1374e28 100644 --- a/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm +++ b/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm @@ -1,18 +1,18 @@ package OpenSRF::DomainObject::oilsMessage; -use JSON; +use OpenSRF::Utils::JSON; use OpenSRF::AppSession; use OpenSRF::DomainObject::oilsResponse qw/:status/; use OpenSRF::Utils::Logger qw/:level/; use warnings; use strict; use OpenSRF::EX qw/:try/; -JSON->register_class_hint(hint => 'osrfMessage', name => 'OpenSRF::DomainObject::oilsMessage', type => 'hash'); +OpenSRF::Utils::JSON->register_class_hint(hint => 'osrfMessage', name => 'OpenSRF::DomainObject::oilsMessage', type => 'hash'); sub toString { my $self = shift; my $pretty = shift; - return JSON->perl2prettyJSON($self) if ($pretty); - return JSON->perl2JSON($self); + return OpenSRF::Utils::JSON->perl2prettyJSON($self) if ($pretty); + return OpenSRF::Utils::JSON->perl2JSON($self); } sub new { diff --git a/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm b/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm index 6c81902..f83727b 100644 --- a/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm +++ b/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm @@ -1,13 +1,13 @@ package OpenSRF::DomainObject::oilsMethod; -use JSON; -JSON->register_class_hint(hint => 'osrfMethod', name => 'OpenSRF::DomainObject::oilsMethod', type => 'hash'); +use OpenSRF::Utils::JSON; +OpenSRF::Utils::JSON->register_class_hint(hint => 'osrfMethod', name => 'OpenSRF::DomainObject::oilsMethod', type => 'hash'); sub toString { my $self = shift; my $pretty = shift; - return JSON->perl2prettyJSON($self) if ($pretty); - return JSON->perl2JSON($self); + return OpenSRF::Utils::JSON->perl2prettyJSON($self) if ($pretty); + return OpenSRF::Utils::JSON->perl2JSON($self); } sub new { diff --git a/src/perlmods/OpenSRF/DomainObject/oilsResponse.pm b/src/perlmods/OpenSRF/DomainObject/oilsResponse.pm index 673516b..0469b79 100644 --- a/src/perlmods/OpenSRF/DomainObject/oilsResponse.pm +++ b/src/perlmods/OpenSRF/DomainObject/oilsResponse.pm @@ -1,11 +1,11 @@ package OpenSRF::DomainObject::oilsResponse; use vars qw/@EXPORT_OK %EXPORT_TAGS/; use Exporter; -use JSON; +use OpenSRF::Utils::JSON; use base qw/Exporter/; use OpenSRF::Utils::Logger qw/:level/; -JSON->register_class_hint( hint => 'osrfResponse', name => 'OpenSRF::DomainObject::oilsResponse', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfResponse', name => 'OpenSRF::DomainObject::oilsResponse', type => 'hash' ); BEGIN { @EXPORT_OK = qw/STATUS_CONTINUE STATUS_OK STATUS_ACCEPTED @@ -74,8 +74,8 @@ my $log = 'OpenSRF::Utils::Logger'; sub toString { my $self = shift; my $pretty = shift; - return JSON->perl2prettyJSON($self) if ($pretty); - return JSON->perl2JSON($self); + return OpenSRF::Utils::JSON->perl2prettyJSON($self) if ($pretty); + return OpenSRF::Utils::JSON->perl2JSON($self); } sub new { @@ -115,7 +115,7 @@ package OpenSRF::DomainObject::oilsStatus; use OpenSRF::DomainObject::oilsResponse qw/:status/; use base 'OpenSRF::DomainObject::oilsResponse'; use vars qw/$status $statusCode/; -JSON->register_class_hint( hint => 'osrfStatus', name => 'OpenSRF::DomainObject::oilsStatus', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfStatus', name => 'OpenSRF::DomainObject::oilsStatus', type => 'hash' ); =head1 NAME @@ -146,7 +146,7 @@ package OpenSRF::DomainObject::oilsConnectStatus; use OpenSRF::DomainObject::oilsResponse qw/:status/; use base 'OpenSRF::DomainObject::oilsStatus'; use vars qw/$status $statusCode/; -JSON->register_class_hint( hint => 'osrfConnectStatus', name => 'OpenSRF::DomainObject::oilsConnectStatus', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfConnectStatus', name => 'OpenSRF::DomainObject::oilsConnectStatus', type => 'hash' ); =head1 NAME @@ -184,7 +184,7 @@ package OpenSRF::DomainObject::oilsContinueStatus; use OpenSRF::DomainObject::oilsResponse qw/:status/; use base 'OpenSRF::DomainObject::oilsStatus'; use vars qw/$status $statusCode/; -JSON->register_class_hint( hint => 'osrfContinueStatus', name => 'OpenSRF::DomainObject::oilsContinueStatus', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfContinueStatus', name => 'OpenSRF::DomainObject::oilsContinueStatus', type => 'hash' ); =head1 NAME @@ -227,7 +227,7 @@ use OpenSRF::DomainObject::oilsResponse qw/:status/; use OpenSRF::DomainObject::oilsPrimitive; use base 'OpenSRF::DomainObject::oilsResponse'; use vars qw/$status $statusCode/; -JSON->register_class_hint( hint => 'osrfResult', name => 'OpenSRF::DomainObject::oilsResult', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfResult', name => 'OpenSRF::DomainObject::oilsResult', type => 'hash' ); $status = 'OK'; @@ -296,7 +296,7 @@ use OpenSRF::EX; use base qw/OpenSRF::EX OpenSRF::DomainObject::oilsResponse/; use vars qw/$status $statusCode/; use Error; -JSON->register_class_hint( hint => 'osrfException', name => 'OpenSRF::DomainObject::oilsException', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfException', name => 'OpenSRF::DomainObject::oilsException', type => 'hash' ); sub message { my $self = shift; @@ -339,7 +339,7 @@ use OpenSRF::DomainObject::oilsResponse qw/:status/; use OpenSRF::EX; use base qw/OpenSRF::DomainObject::oilsException OpenSRF::EX::ERROR/; use vars qw/$status $statusCode/; -JSON->register_class_hint( hint => 'osrfConnectException', name => 'OpenSRF::DomainObject::oilsConnectException', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfConnectException', name => 'OpenSRF::DomainObject::oilsConnectException', type => 'hash' ); =head1 NAME @@ -375,7 +375,7 @@ package OpenSRF::DomainObject::oilsMethodException; use OpenSRF::DomainObject::oilsResponse qw/:status/; use base 'OpenSRF::DomainObject::oilsException'; use vars qw/$status $statusCode/; -JSON->register_class_hint( hint => 'osrfMethodException', name => 'OpenSRF::DomainObject::oilsMethodException', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfMethodException', name => 'OpenSRF::DomainObject::oilsMethodException', type => 'hash' ); =head1 NAME @@ -414,7 +414,7 @@ package OpenSRF::DomainObject::oilsServerError; use OpenSRF::DomainObject::oilsResponse qw/:status/; use base 'OpenSRF::DomainObject::oilsException'; use vars qw/$status $statusCode/; -JSON->register_class_hint( hint => 'osrfServerError', name => 'OpenSRF::DomainObject::oilsServerError', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfServerError', name => 'OpenSRF::DomainObject::oilsServerError', type => 'hash' ); $status = 'Internal Server Error'; $statusCode = STATUS_INTERNALSERVERERROR; @@ -430,7 +430,7 @@ use OpenSRF::DomainObject::oilsResponse qw/:status/; use OpenSRF::EX; use base qw/OpenSRF::DomainObject::oilsException OpenSRF::EX::ERROR/; use vars qw/$status $statusCode/; -JSON->register_class_hint( hint => 'osrfBrokenSession', name => 'OpenSRF::DomainObject::oilsBrokenSession', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfBrokenSession', name => 'OpenSRF::DomainObject::oilsBrokenSession', type => 'hash' ); $status = "Request on Disconnected Session"; $statusCode = STATUS_EXPFAILED; @@ -439,7 +439,7 @@ use OpenSRF::DomainObject::oilsResponse qw/:status/; use OpenSRF::EX; use base qw/OpenSRF::DomainObject::oilsException OpenSRF::EX::ERROR/; use vars qw/$status $statusCode/; -JSON->register_class_hint( hint => 'osrfXMLParseError', name => 'OpenSRF::DomainObject::oilsXMLParseError', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfXMLParseError', name => 'OpenSRF::DomainObject::oilsXMLParseError', type => 'hash' ); $status = "XML Parse Error"; $statusCode = STATUS_EXPFAILED; @@ -447,7 +447,7 @@ package OpenSRF::DomainObject::oilsAuthException; use OpenSRF::DomainObject::oilsResponse qw/:status/; use OpenSRF::EX; use base qw/OpenSRF::DomainObject::oilsException OpenSRF::EX::ERROR/; -JSON->register_class_hint( hint => 'osrfAuthException', name => 'OpenSRF::DomainObject::oilsAuthException', type => 'hash' ); +OpenSRF::Utils::JSON->register_class_hint( hint => 'osrfAuthException', name => 'OpenSRF::DomainObject::oilsAuthException', type => 'hash' ); use vars qw/$status $statusCode/; $status = "Authentication Failure"; $statusCode = STATUS_FORBIDDEN; diff --git a/src/perlmods/OpenSRF/System.pm b/src/perlmods/OpenSRF/System.pm index cf3e840..1f0f6dc 100644 --- a/src/perlmods/OpenSRF/System.pm +++ b/src/perlmods/OpenSRF/System.pm @@ -111,7 +111,7 @@ sub load_bootstrap_config { OpenSRF::Utils::Config->load( config_file => $bootstrap_config_file ); - JSON->register_class_hint( name => "OpenSRF::Application", hint => "method", type => "hash" ); + OpenSRF::Utils::JSON->register_class_hint( name => "OpenSRF::Application", hint => "method", type => "hash" ); OpenSRF::Transport->message_envelope( "OpenSRF::Transport::SlimJabber::MessageWrapper" ); OpenSRF::Transport::PeerHandle->set_peer_client( "OpenSRF::Transport::SlimJabber::PeerConnection" ); diff --git a/src/perlmods/OpenSRF/Transport.pm b/src/perlmods/OpenSRF/Transport.pm index 4ee322c..9af9282 100644 --- a/src/perlmods/OpenSRF/Transport.pm +++ b/src/perlmods/OpenSRF/Transport.pm @@ -3,6 +3,7 @@ use strict; use warnings; use base 'OpenSRF'; use Time::HiRes qw/time/; use OpenSRF::AppSession; +use OpenSRF::Utils::JSON; use OpenSRF::Utils::Logger qw(:level); use OpenSRF::DomainObject::oilsResponse qw/:status/; use OpenSRF::EX qw/:try/; @@ -118,7 +119,7 @@ sub handler { # Create a document from the JSON contained within the message my $doc; - eval { $doc = JSON->JSON2perl($body); }; + eval { $doc = OpenSRF::Utils::JSON->JSON2perl($body); }; if( $@ ) { $logger->transport( "Received bogus JSON: $@", INFO ); diff --git a/src/perlmods/OpenSRF/UnixServer.pm b/src/perlmods/OpenSRF/UnixServer.pm index 120f73c..472bb44 100644 --- a/src/perlmods/OpenSRF/UnixServer.pm +++ b/src/perlmods/OpenSRF/UnixServer.pm @@ -10,7 +10,7 @@ use OpenSRF::DomainObject::oilsResponse qw/:status/; use OpenSRF::System; use OpenSRF::Utils::SettingsClient; use Time::HiRes qw(time); -use JSON; +use OpenSRF::Utils::JSON; use vars qw/@ISA $app/; use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK); use Carp; @@ -208,7 +208,7 @@ sub configure_hook { my $imp = $client->config_value("apps", $app, "implementation"); OpenSRF::Application::server_class($app); OpenSRF::Application->application_implementation( $imp ); - JSON->register_class_hint( name => $imp, hint => $app, type => "hash" ); + OpenSRF::Utils::JSON->register_class_hint( name => $imp, hint => $app, type => "hash" ); OpenSRF::Application->application_implementation->initialize() if (OpenSRF::Application->application_implementation->can('initialize')); diff --git a/src/perlmods/OpenSRF/Utils/Cache.pm b/src/perlmods/OpenSRF/Utils/Cache.pm index ac430bd..635a2b3 100644 --- a/src/perlmods/OpenSRF/Utils/Cache.pm +++ b/src/perlmods/OpenSRF/Utils/Cache.pm @@ -6,7 +6,7 @@ use OpenSRF::Utils::Logger qw/:level/; use OpenSRF::Utils::Config; use OpenSRF::Utils::SettingsClient; use OpenSRF::EX qw(:try); -use JSON; +use OpenSRF::Utils::JSON; my $log = 'OpenSRF::Utils::Logger'; @@ -96,7 +96,7 @@ sub put_cache { my($self, $key, $value, $expiretime ) = @_; return undef unless( defined $key and defined $value ); - $value = JSON->perl2JSON($value); + $value = OpenSRF::Utils::JSON->perl2JSON($value); if($self->{persist}){ _load_methods(); } @@ -148,7 +148,7 @@ sub get_cache { my($self, $key ) = @_; my $val = $self->{memcache}->get( $key ); - return JSON->JSON2perl($val) if defined($val); + return OpenSRF::Utils::JSON->JSON2perl($val) if defined($val); if($self->{persist}){ _load_methods(); } @@ -162,7 +162,7 @@ sub get_cache { } else { $self->{memcache}->set( $key, $val, $max_persist_time); } - return JSON->JSON2perl($val); + return OpenSRF::Utils::JSON->JSON2perl($val); } } return undef; -- 2.11.0