From dab177324d4c889d781adcb2a0caa9e3b2270ce6 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 21 May 2010 13:37:06 -0700 Subject: [PATCH] Change from encode/decode to to/from in JSON, and call them explicitly. Exception handling for AJAX methods in the GalleryAlbum. --- lib/WebGUI/Asset/Wobject/GalleryAlbum.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm index b2fc69c27..325049eff 100644 --- a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm +++ b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm @@ -47,7 +47,7 @@ use Carp qw( croak ); use File::Find; use File::Spec; use File::Temp qw{ tempdir }; -use JSON (); +use JSON qw(); use WebGUI::International; use WebGUI::HTML; use WebGUI::ProgressBar; @@ -1171,7 +1171,7 @@ sub www_ajax { my $result; # Get arguments encoded in json format - my $args = decode_json($form->get("args")); + my $args = JSON::from_json($form->get("args")); # Log some debug information $session->log->debug("Ajax service called with args=" . $form->get("args")); @@ -1198,7 +1198,7 @@ sub www_ajax { $result->{ err } = -1 if $result->{ errMessage }; # Return results encoded in json format - return encode_json( $result ); + return JSON::to_json( $result ); } @@ -1266,10 +1266,10 @@ sub _moveFileAjaxRequest { # Instantiate file with ID in before/after argument $destId = $args->{before} ? $args->{before} : $args->{after}; - $dest = WebGUI::Asset->newById( $session, $destId ); + $dest = eval { WebGUI::Asset->newById( $session, $destId ); }; # Return if destination file could not be instantiated - if ( Expeption::Class->caught() ) { + if ( Exception::Class->caught() ) { $session->log->error("Couldn't move file '$targetId' before/after file '$destId' because we couldn't instantiate the latter."); $result{ errMessage } = "ID in before/after argument seems to be invalid."; return \%result;