use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class PostbackResultTest method testPassingNullInvocation.
public void testPassingNullInvocation() throws Exception {
Result result = new PostbackResult();
try {
result.execute(null);
fail("Exception should be thrown!");
} catch (IllegalArgumentException e) {
assertEquals("Invocation cannot be null!", e.getMessage());
}
}
use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class ServletRedirectResultTest method testPassingNullInvocation.
public void testPassingNullInvocation() throws Exception {
Result result = new ServletRedirectResult();
try {
result.execute(null);
fail("Exception should be thrown!");
} catch (IllegalArgumentException e) {
assertEquals("Invocation cannot be null!", e.getMessage());
}
}
use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class StrutsResultFactory method buildResult.
public Result buildResult(ResultConfig resultConfig, Map<String, Object> extraContext) throws Exception {
String resultClassName = resultConfig.getClassName();
Result result = null;
if (resultClassName != null) {
result = (Result) objectFactory.buildBean(resultClassName, extraContext);
Map<String, String> params = resultConfig.getParams();
if (params != null) {
setParameters(extraContext, result, params);
}
}
return result;
}
use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class TokenSessionStoreInterceptor method handleInvalidToken.
/**
* Handles processing of invalid tokens. If a previously stored invocation is
* available, the method will attempt to return and render its result. Otherwise
* it will return INVALID_TOKEN_CODE.
*
* Note: Because a stored (previously completed) invocation's PageContext will be closed,
* this method must replace the stored PageContext with the current invocation's one (or a null).
* See {@link org.apache.struts2.util.InvocationSessionStore#loadInvocation(String key, String token)} for details.
*
* @param invocation
*
* @return
* @throws Exception
*/
@Override
protected String handleInvalidToken(ActionInvocation invocation) throws Exception {
ActionContext ac = invocation.getInvocationContext();
HttpServletRequest request = ac.getServletRequest();
HttpServletResponse response = ac.getServletResponse();
String tokenName = TokenHelper.getTokenName();
String token = TokenHelper.getToken(tokenName);
if ((tokenName != null) && (token != null)) {
HttpParameters params = ac.getParameters();
params.remove(tokenName);
params.remove(TokenHelper.TOKEN_NAME_FIELD);
String sessionTokenName = TokenHelper.buildTokenSessionAttributeName(tokenName);
ActionInvocation savedInvocation = InvocationSessionStore.loadInvocation(sessionTokenName, token);
if (savedInvocation != null) {
// set the savedInvocation's valuestack to the request scope
ValueStack stack = savedInvocation.getStack();
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
ActionContext savedContext = savedInvocation.getInvocationContext();
savedContext.getContextMap().put(ServletActionContext.HTTP_REQUEST, request);
savedContext.getContextMap().put(ServletActionContext.HTTP_RESPONSE, response);
Result result = savedInvocation.getResult();
if ((result != null) && (savedInvocation.getProxy().getExecuteResult())) {
result.execute(savedInvocation);
}
// turn off execution of this invocations result
invocation.getProxy().setExecuteResult(false);
return savedInvocation.getResultCode();
}
}
return INVALID_TOKEN_CODE;
}
use of com.walmartlabs.concord.plugins.s3.Result in project struts by apache.
the class SpringObjectFactoryTest method testObtainResultBySpringName.
public void testObtainResultBySpringName() throws Exception {
// TODO: Does this need to be a prototype?
sac.registerPrototype("chaining-result", ActionChainResult.class, new MutablePropertyValues());
ResultConfig rConfig = new ResultConfig.Builder(Action.SUCCESS, "chaining-result").build();
Result result = objectFactory.buildResult(rConfig, ActionContext.getContext().getContextMap());
assertEquals(ActionChainResult.class, result.getClass());
}
Aggregations