polish
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user