From: Tara L Andrews Date: Tue, 11 Sep 2012 08:10:13 +0000 (+0200) Subject: Merge branch 'master' of github.com:tla/stemmatology X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmaweb.git;a=commitdiff_plain;h=f761f9a7802815a5e3aa1068cd7aa17dd83ff8e5;hp=-c Merge branch 'master' of github.com:tla/stemmatology Conflicts: stemmaweb/lib/stemmaweb/Controller/Root.pm --- f761f9a7802815a5e3aa1068cd7aa17dd83ff8e5 diff --combined lib/stemmaweb/Controller/Root.pm index 5decf72,070f7d8..5ab5e92 --- a/lib/stemmaweb/Controller/Root.pm +++ b/lib/stemmaweb/Controller/Root.pm @@@ -141,7 -141,7 +141,7 @@@ sub newtradition :Local :Args(0) } } else { # Error unless we have a recognized filename extension - return _json_error( $c, 500, "Unrecognized file type extension $ext" ); + return _json_error( $c, 403, "Unrecognized file type extension $ext" ); } # Save the tradition if we have it, and return its data or else the @@@ -177,7 -177,7 +177,7 @@@ sub textinfo :Local :Args(1) my( $self, $c, $textid ) = @_; my $tradition = $c->model('Directory')->tradition( $textid ); unless( $tradition ) { - return _json_error( $c, 500, "No tradition with ID $textid" ); + return _json_error( $c, 404, "No tradition with ID $textid" ); } my $ok = _check_permission( $c, $tradition ); return unless $ok; @@@ -279,7 -279,7 +279,7 @@@ sub variantgraph :Local :Args(1) my( $self, $c, $textid ) = @_; my $tradition = $c->model('Directory')->tradition( $textid ); unless( $tradition ) { - return _json_error( $c, 500, "No tradition with ID $textid" ); + return _json_error( $c, 404, "No tradition with ID $textid" ); } my $ok = _check_permission( $c, $tradition ); return unless $ok; @@@ -306,7 -306,7 +306,7 @@@ sub stemma :Local :Args(2) my $m = $c->model('Directory'); my $tradition = $m->tradition( $textid ); unless( $tradition ) { - return _json_error( $c, 500, "No tradition with ID $textid" ); + return _json_error( $c, 404, "No tradition with ID $textid" ); } my $ok = _check_permission( $c, $tradition ); return unless $ok; @@@ -319,17 -319,15 +319,17 @@@ try { if( $stemmaid eq 'n' ) { # We are adding a new stemma. + $stemmaid = $tradition->stemma_count; $stemma = $tradition->add_stemma( 'dot' => $dot ); - $stemmaid = $tradition->stemma_count - 1; + } elsif( $stemmaid !~ /^\d+$/ ) { + return _json_error( $c, 403, "Invalid stemma ID specification $stemmaid" ); } elsif( $stemmaid < $tradition->stemma_count ) { # We are updating an existing stemma. $stemma = $tradition->stemma( $stemmaid ); $stemma->alter_graph( $dot ); } else { # Unrecognized stemma ID - return _json_error( $c, 500, "No stemma at index $stemmaid, cannot update" ); + return _json_error( $c, 404, "No stemma at index $stemmaid, cannot update" ); } } catch ( Text::Tradition::Error $e ) { return _json_error( $c, 500, $e->message ); @@@ -385,13 -383,13 +385,13 @@@ sub stemmadot :Local :Args(2) my $m = $c->model('Directory'); my $tradition = $m->tradition( $textid ); unless( $tradition ) { - return _json_error( $c, 500, "No tradition with ID $textid" ); + return _json_error( $c, 404, "No tradition with ID $textid" ); } my $ok = _check_permission( $c, $tradition ); return unless $ok; my $stemma = $tradition->stemma( $stemmaid ); unless( $stemma ) { - return _json_error( $c, 500, "Tradition $textid has no stemma ID $stemmaid" ); + return _json_error( $c, 404, "Tradition $textid has no stemma ID $stemmaid" ); } # Get the dot and transmute its line breaks to literal '|n' $c->stash->{'result'} = { 'dot' => $stemma->editable( { linesep => '|n' } ) };