Changeset 1127
- Timestamp:
- 12/02/08 12:49:15 (3 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
-
EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin/Core.pm (modified) (1 diff)
-
TWikiCompatibilityPlugin/lib/TWiki/OopsException.pm (modified) (1 diff)
-
UnitTestContrib/test/unit/ExceptionTests.pm (modified) (3 diffs)
-
WorkflowPlugin/data/Sandbox/ControlledDocument.txt (modified) (2 diffs)
-
WorkflowPlugin/data/Sandbox/DocumentApprovalWorkflow.txt (modified) (1 diff)
-
WorkflowPlugin/lib/TWiki/Plugins/WorkflowPlugin.pm (modified) (2 diffs)
-
core/lib/Foswiki.pm (modified) (1 diff)
-
core/lib/Foswiki/Engine/CGI.pm (modified) (1 diff)
-
core/lib/Foswiki/OopsException.pm (modified) (4 diffs)
-
core/lib/Foswiki/Store.pm (modified) (1 diff)
-
core/lib/Foswiki/UI.pm (modified) (5 diffs)
-
core/lib/Foswiki/UI/Edit.pm (modified) (2 diffs)
-
core/lib/Foswiki/UI/Manage.pm (modified) (4 diffs)
-
core/lib/Foswiki/UI/Register.pm (modified) (7 diffs)
-
core/lib/Foswiki/UI/Save.pm (modified) (2 diffs)
-
core/lib/Foswiki/UI/Search.pm (modified) (1 diff)
-
core/lib/Foswiki/UI/Upload.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin/Core.pm
r1086 r1127 1441 1441 # user has no permission to change the topic 1442 1442 throw Foswiki::OopsException( 1443 'accessdenied', 1443 'accessdenied', status => 403, 1444 1444 def => 'topic_access', 1445 1445 web => $theWeb, -
trunk/TWikiCompatibilityPlugin/lib/TWiki/OopsException.pm
r1038 r1127 1 1 package TWiki::OopsException; 2 use Error; 3 use Assert; 4 use base 'Error'; 5 6 use Foswiki::OopsException; 2 use base 'Foswiki::OopsException'; 7 3 8 4 sub new { 9 shift;10 return new Foswiki::OopsException(@_);5 my $class = shift; 6 return $class->SUPER::new(@_); 11 7 } 12 8 -
trunk/UnitTestContrib/test/unit/ExceptionTests.pm
r816 r1127 1 1 package ExceptionTests; 2 use base FoswikiTestCase;2 use base 'FoswikiTestCase'; 3 3 4 4 use strict; … … 6 6 use Error qw( :try ); 7 7 use Foswiki::OopsException; 8 use Foswiki::AccessControlException; 8 9 use Foswiki::UI::Oops; 9 10 … … 64 65 } 65 66 67 # Test for DEPRECATED redirect 66 68 sub test_redirectOopsException { 67 69 my $this = shift; -
trunk/WorkflowPlugin/data/Sandbox/ControlledDocument.txt
r580 r1127 1 %META:TOPICINFO{author="SimianApe" date="1228219811" format="1.1" version="1.3"}% 1 2 %WORKFLOWNOTICE% 2 3 … … 12 13 13 14 Workflow history: %WORKFLOWHISTORY% 15 16 %META:FORM{name="InProcessForm"}% 17 %META:WORKFLOWHISTORY{value="<br>WAITINGFORQM -- 02 Dec 2008 - 12:10"}% 18 %META:WORKFLOW{name="WAITINGFORQM" LASTTIME_WAITINGFORQM="02 Dec 2008 - 12:10" LASTVERSION_WAITINGFORQM=""}% -
trunk/WorkflowPlugin/data/Sandbox/DocumentApprovalWorkflow.txt
r440 r1127 30 30 | WAITINGFORCTO | nobody | This document is waiting for approval by the CTO.| 31 31 ---++ Transitions 32 | *State* | *Action* | *Next State* | *Allowed* | *Form* |33 | APPROVED | revise | UNDERREVISION | | ApprovedForm |34 | UNDERREVISION | ready for approval | WAITINGFORQM | | InProcessForm |35 | WAITINGFORQM | approve | WAITINGFORCTO | | |36 | WAITINGFORQM | reject | UNDERREVISION | | |37 | WAITINGFORCTO | approve | APPROVED | | ApprovedForm |38 | WAITINGFORCTO | reject | UNDERREVISION | | |32 | *State* | *Action* | *Next State* | *Allowed* | *Form* | 33 | APPROVED | revise | UNDERREVISION | | ApprovedForm | 34 | UNDERREVISION | ready for approval | WAITINGFORQM | | InProcessForm | 35 | WAITINGFORQM | approve | WAITINGFORCTO | | | 36 | WAITINGFORQM | reject | UNDERREVISION | | | 37 | WAITINGFORCTO | approve | APPROVED | | ApprovedForm | 38 | WAITINGFORCTO | reject | UNDERREVISION | | | -
trunk/WorkflowPlugin/lib/TWiki/Plugins/WorkflowPlugin.pm
r1090 r1127 241 241 if ( !$query->param('INWORKFLOWSEQUENCE') && !$TOPIC->canEdit() ) { 242 242 throw TWiki::OopsException( 243 'accessdenied', 243 'accessdenied', status => 403, 244 244 def => 'topic_access', 245 245 web => $_[2], … … 285 285 286 286 try { 287 $query->param('INWORKFLOWSEQUENCE' => 1); 288 $TOPIC->changeState($action); 289 if ($newForm) { 290 291 # If there is a form with the new state, and it's not the same 292 # form as previously, we need to kick into edit mode to support 293 # form field changes. 294 $url = TWiki::Func::getScriptUrl( 295 $web, $topic, 'edit', 296 INWORKFLOWSEQUENCE => time()); 287 try { 288 $query->param('INWORKFLOWSEQUENCE' => 1); 289 if ($newForm) { 290 # If there is a form with the new state, and it's not 291 # the same form as previously, we need to kick into edit 292 # mode to support form field changes. 293 $url = TWiki::Func::getScriptUrl( 294 $web, $topic, 'edit', 295 INWORKFLOWSEQUENCE => time()); 296 } 297 else { 298 $url = TWiki::Func::getScriptUrl( $web, $topic, 'view' ); 299 } 300 # SMELL: don't do this until the edit is over 301 $TOPIC->changeState($action); 302 TWiki::Func::redirectCgiQuery( undef, $url ); 303 } catch Error::Simple with { 304 my $error = shift; 305 throw TWiki::OopsException( 306 'oopssaveerr', 307 web => $web, topic => $topic, 308 params => [ $error || '?' ]); 309 }; 310 } catch TWiki::OopsException with { 311 my $e = shift; 312 if ($e->can('generate')) { 313 $e->generate( $session ); 314 } else { 315 # Deprecated, TWiki compatibility only 316 $e->redirect( $session ); 297 317 } 298 else {299 $url = TWiki::Func::getScriptUrl( $web, $topic, 'view' );300 }301 }302 catch Error::Simple with {303 my $error = shift;304 $url = TWiki::Func::getScriptUrl(305 $web, $topic, 'oops',306 template => "oopssaveerr",307 param1 => $error308 );309 }310 catch TWiki::OopsException with {311 shift->redirect( $session );312 318 313 319 }; 314 320 } 315 TWiki::Func::redirectCgiQuery( undef, $url );316 321 return undef; 317 322 } -
trunk/core/lib/Foswiki.pm
r1115 r1127 723 723 # add cookie(s) 724 724 $this->{users}->{loginManager}->modifyHeader($hopts); 725 726 725 $this->{response}->headers($hopts); 727 726 } -
trunk/core/lib/Foswiki/Engine/CGI.pm
r1078 r1127 177 177 178 178 $this->SUPER::finalizeHeaders( $res, $req ); 179 # make sure we always generate a status for the response 180 print 'Status: '.$res->status() 181 if ($res->status() && !defined($res->headers->{status})); 179 182 foreach my $header ( keys %{ $res->headers } ) { 180 183 print $header . ': ' . $_ . $this->CRLF -
trunk/core/lib/Foswiki/OopsException.pm
r1050 r1127 24 24 25 25 throw Foswiki::OopsException( 'bathplugin', 26 status => 418, 26 27 def => 'toestuck', 27 28 web => $web, … … 84 85 my $class = shift; 85 86 my $template = shift; 86 my $this = bless( $class->SUPER::new(), $class);87 my $this = $class->SUPER::new(); 87 88 $this->{template} = $template; 88 89 ASSERT( scalar(@_) % 2 == 0, join( ";", map { $_ || 'undef' } @_ ) ) … … 146 147 } 147 148 148 =begin TML 149 150 ---++ ObjectMethod redirect( $twiki ) 151 152 Generate a redirect to an 'oops' script for this exception. 153 154 If the 'keep' parameter is set in the 155 exception, it saves parameter values into the query as well. This is needed 156 if the query string might get lost during a passthrough, due to a POST 157 being redirected to a GET. 158 159 =cut 160 149 # Generate a redirect to an 'oops' script for this exception. 150 # 151 # If the 'keep' parameter is set in the 152 # exception, it saves parameter values into the query as well. This is needed 153 # if the query string might get lost during a passthrough, due to a POST 154 # being redirected to a GET. 155 # This redirect has been replaced by the generate function below and should 156 # not be called in new code. 161 157 sub redirect { 162 158 my ( $this, $session ) = @_; 163 159 my @p = $this->_prepareResponse($session); 160 my $url = 161 $session->getScriptUrl( 1, 'oops', $this->{web}, $this->{topic}, @p ); 162 $session->redirect( $url, 1 ); 163 } 164 165 =begin TML 166 167 ---++ ObjectMethod generate( $session ) 168 169 Generate an error page for the exception. This will output the error page 170 to the browser. The default HTTP Status for an Oops exception is 500. This 171 can be overridden using the 'status => ' parameter to the constructor. 172 173 =cut 174 175 sub generate { 176 my ($this, $session ) = @_; 177 178 my @p = $this->_prepareResponse( $session ); 179 $session->{response}->status( $this->{status} || 500 ); 180 require Foswiki::UI::Oops; 181 Foswiki::UI::Oops::oops($session, $this->{web}, $this->{topic}, 182 $session->{request}, 0); 183 } 184 185 sub _prepareResponse { 186 my ($this, $session ) = @_; 164 187 my @p = (); 165 188 … … 170 193 my $n = 1; 171 194 push( @p, map { 'param' . ( $n++ ) => $_ } @{ $this->{params} } ); 172 my $url =173 $session->getScriptUrl( 1, 'oops', $this->{web}, $this->{topic}, @p );174 195 while ( my $p = shift(@p) ) { 175 196 $session->{request}->param( -name => $p, -value => shift(@p) ); 176 197 } 177 $session->redirect( $url, 1 );198 return @p; 178 199 } 179 200 -
trunk/core/lib/Foswiki/Store.pm
r1050 r1127 1404 1404 $web =~ s#\.#/#go; 1405 1405 ASSERT( defined($topic) ) if DEBUG; 1406 if (DEBUG) { 1407 my ( $webTest, $topicTest ) = 1408 $this->{session}->normalizeWebTopicName( $web, $topic ); 1409 ASSERT( $topic eq $topicTest ); 1410 ASSERT( $web eq $webTest ); 1411 } 1406 # This test is invalid. This intent is good, but this function may 1407 # be called with a deliberately undef web or topic. 1408 #if (DEBUG) { 1409 # my ( $webTest, $topicTest ) = 1410 # $this->{session}->normalizeWebTopicName( $web, $topic ); 1411 # ASSERT( $topic eq $topicTest ); 1412 # ASSERT( $web eq $webTest ); 1413 #} 1412 1414 return 0 unless $topic; 1413 1415 -
trunk/core/lib/Foswiki/UI.pm
r1078 r1127 183 183 # we are already authenticated. 184 184 my $exception = new Foswiki::OopsException( 185 'accessdenied', 185 'accessdenied', status => 403, 186 186 web => $e->{web}, 187 187 topic => $e->{topic}, … … 190 190 ); 191 191 192 $exception-> redirect($session);192 $exception->generate($session); 193 193 } 194 194 } 195 195 catch Foswiki::OopsException with { 196 shift-> redirect($session);196 shift->generate($session); 197 197 } 198 198 catch Error::Simple with { … … 277 277 unless ( $session->{store}->webExists($webName) ) { 278 278 throw Foswiki::OopsException( 279 'accessdenied', 279 'accessdenied', status => 403, 280 280 def => 'no_such_web', 281 281 web => $webName, … … 301 301 unless ( $session->{store}->topicExists( $webName, $topic ) ) { 302 302 throw Foswiki::OopsException( 303 'accessdenied', 303 'accessdenied', status => 403, 304 304 def => 'no_such_topic', 305 305 web => $webName, … … 352 352 { 353 353 throw Foswiki::OopsException( 354 'accessdenied', 354 'accessdenied', status => 403, 355 355 def => 'topic_access', 356 356 web => $web, -
trunk/core/lib/Foswiki/UI/Edit.pm
r1050 r1127 183 183 if ( $saveCmd && !$session->{users}->isAdmin( $session->{user} ) ) { 184 184 throw Foswiki::OopsException( 185 'accessdenied', 185 'accessdenied', status => 403, 186 186 def => 'only_group', 187 187 web => $webName, … … 236 236 unless ( $store->topicExists( $templateWeb, $templateTopic ) ) { 237 237 throw Foswiki::OopsException( 238 'accessdenied', 238 'accessdenied', status => 403, 239 239 def => 'no_such_topic_template', 240 240 web => $templateWeb, -
trunk/core/lib/Foswiki/UI/Manage.pm
r1090 r1127 137 137 138 138 throw Foswiki::OopsException( 139 'attention', 139 'attention', status => 200, 140 140 def => 'remove_user_done', 141 141 web => $webName, … … 238 238 # everything OK, redirect to last message 239 239 throw Foswiki::OopsException( 240 'attention', 240 'attention', status => 200, 241 241 web => $newWeb, 242 242 topic => $newTopic, … … 313 313 { 314 314 throw Foswiki::OopsException( 315 'accessdenied', 315 'accessdenied', status => 403, 316 316 def => 'no_such_topic_rename', 317 317 web => $oldWeb, … … 1625 1625 # user has no permission to change the topic 1626 1626 throw Foswiki::OopsException( 1627 'accessdenied', 1627 'accessdenied', status => 403, 1628 1628 def => 'topic_access', 1629 1629 web => $web, -
trunk/core/lib/Foswiki/UI/Register.pm
r1050 r1127 136 136 unless ( $session->{users}->isAdmin($user) ) { 137 137 throw Foswiki::OopsException( 138 'accessdenied', 138 'accessdenied', status => 403, 139 139 def => 'only_group', 140 140 web => $web, … … 421 421 throw Foswiki::OopsException( 422 422 'attention', 423 status => 200, 423 424 def => 'confirm', 424 425 web => $data->{webName}, … … 470 471 unless ( $session->{users}->isAdmin($user) ) { 471 472 throw Foswiki::OopsException( 472 'accessdenied', 473 'accessdenied', status => 403, 473 474 def => 'only_group', 474 475 web => $web, … … 508 509 throw Foswiki::OopsException( 509 510 'attention', 511 status => 200, 510 512 topic => $Foswiki::cfg{HomeTopicName}, 511 513 def => 'reset_ok', … … 737 739 throw Foswiki::OopsException( 738 740 'attention', 741 status => 200, 739 742 web => $webName, 740 743 topic => $topic, … … 746 749 throw Foswiki::OopsException( 747 750 'attention', 751 status => 200, 748 752 web => $webName, 749 753 topic => $topic, … … 894 898 throw Foswiki::OopsException( 895 899 'attention', 900 status => 200, 896 901 web => $Foswiki::cfg{UsersWebName}, 897 902 topic => $data->{WikiName}, -
trunk/core/lib/Foswiki/UI/Save.pm
r1050 r1127 521 521 if ( $saveCmd && !$session->{users}->isAdmin( $session->{user} ) ) { 522 522 throw Foswiki::OopsException( 523 'accessdenied', 523 'accessdenied', status => 403, 524 524 def => 'only_group', 525 525 web => $web, … … 612 612 if ($merged) { 613 613 throw Foswiki::OopsException( 614 'attention', 614 'attention', status => 200, 615 615 def => 'merge_notice', 616 616 web => $web, -
trunk/core/lib/Foswiki/UI/Search.pm
r1050 r1127 59 59 require Foswiki::OopsException; 60 60 throw Foswiki::OopsException( 61 'accessdenied', 61 'accessdenied', status => 403, 62 62 def => 'no_such_web', 63 63 web => $webName, -
trunk/core/lib/Foswiki/UI/Upload.pm
r1050 r1127 259 259 throw Foswiki::OopsException( 260 260 'attention', 261 status => 200, 261 262 def => 'upload_name_changed', 262 263 web => $webName,
Note: See TracChangeset
for help on using the changeset viewer.
