This commit is contained in:
Keith Donald
2009-04-06 16:23:41 +00:00
parent bcf469722f
commit 3137ad2fcd
3 changed files with 33 additions and 3 deletions

View File

@@ -238,6 +238,7 @@ public class PortletExternalContext implements ExternalContext {
if (isRenderPhase()) {
throw new IllegalStateException("Redirects are not allowed durring the portlet render phase");
}
assertResponseNotAlreadyCompleted();
flowExecutionRedirectRequested = true;
recordResponseComplete();
}
@@ -246,6 +247,7 @@ public class PortletExternalContext implements ExternalContext {
if (isRenderPhase()) {
throw new IllegalStateException("Redirects are not allowed durring the portlet render phase");
}
assertResponseNotAlreadyCompleted();
flowDefinitionRedirectFlowId = flowId;
flowDefinitionRedirectFlowInput = input;
recordResponseComplete();
@@ -255,6 +257,7 @@ public class PortletExternalContext implements ExternalContext {
if (isRenderPhase()) {
throw new IllegalStateException("Redirects are not allowed durring the portlet render phase");
}
assertResponseNotAlreadyCompleted();
externalRedirectUrl = uri;
recordResponseComplete();
}
@@ -359,4 +362,11 @@ public class PortletExternalContext implements ExternalContext {
}
}
private void assertResponseNotAlreadyCompleted() {
if (responseComplete) {
throw new IllegalStateException(
"The ExternalContext response has already been completed; this would have been done with a previous call to recordResponseComplete, requestFlowExecutionRedirect, requestFlowDefinitionRedirect, or requestExternalRedirect");
}
}
}

View File

@@ -228,16 +228,19 @@ public class ServletExternalContext implements ExternalContext {
}
public void requestFlowExecutionRedirect() {
assertResponseNotAlreadyCompleted();
flowExecutionRedirectRequested = true;
recordResponseComplete();
}
public void requestExternalRedirect(String location) {
assertResponseNotAlreadyCompleted();
externalRedirectUrl = location;
recordResponseComplete();
}
public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) {
assertResponseNotAlreadyCompleted();
flowDefinitionRedirectFlowId = flowId;
flowDefinitionRedirectFlowInput = input;
recordResponseComplete();
@@ -349,4 +352,11 @@ public class ServletExternalContext implements ExternalContext {
this.flowUrlHandler = flowUrlHandler;
}
private void assertResponseNotAlreadyCompleted() {
if (responseComplete) {
throw new IllegalStateException(
"The ExternalContext response has already been completed; this would have been done with a previous call to recordResponseComplete, requestFlowExecutionRedirect, requestFlowDefinitionRedirect, or requestExternalRedirect");
}
}
}

View File

@@ -63,7 +63,7 @@ public class MockExternalContext implements ExternalContext {
private boolean ajaxRequest;
private boolean responseCompleted;
private boolean responseComplete;
private boolean flowExecutionRedirectRequested;
@@ -155,25 +155,28 @@ public class MockExternalContext implements ExternalContext {
}
public boolean isResponseComplete() {
return responseCompleted;
return responseComplete;
}
public void recordResponseComplete() throws IllegalStateException {
responseCompleted = true;
responseComplete = true;
}
public void requestFlowExecutionRedirect() {
assertResponseNotAlreadyCompleted();
flowExecutionRedirectRequested = true;
recordResponseComplete();
}
public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) {
assertResponseNotAlreadyCompleted();
flowDefinitionRedirectFlowId = flowId;
flowDefinitionRedirectFlowInput = input;
recordResponseComplete();
}
public void requestExternalRedirect(String uri) {
assertResponseNotAlreadyCompleted();
externalRedirectUrl = uri;
recordResponseComplete();
}
@@ -397,6 +400,13 @@ public class MockExternalContext implements ExternalContext {
return redirectInPopup;
}
private void assertResponseNotAlreadyCompleted() {
if (responseComplete) {
throw new IllegalStateException(
"The ExternalContext response has already been completed; this would have been done with a previous call to recordResponseComplete, requestFlowExecutionRedirect, requestFlowDefinitionRedirect, or requestExternalRedirect");
}
}
private class MockPrincipal implements Principal {
private String name;