use of com.opensymphony.xwork2.ActionContext in project bamboobsc by billchen198318.
the class ActionInfoSupportInterceptor method intercept.
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
/*
ActionInvocation ai=(ActionInvocation)ActionContext.getContext().get(ActionContext.ACTION_INVOCATION);
String action=ai.getProxy().getActionName();
String namespace=ai.getProxy().getNamespace();
*/
HttpServletRequest request = ServletActionContext.getRequest();
ActionContext context = actionInvocation.getInvocationContext();
String action = actionInvocation.getProxy().getActionName();
String namespace = actionInvocation.getProxy().getNamespace();
String remoteAddr = request.getRemoteAddr();
String referer = request.getHeader("referer");
context.getSession().put(Constants.SESS_PAGE_INFO_ACTION_ByInterceptor, action);
context.getSession().put(Constants.SESS_PAGE_INFO_NAMESPACE_ByInterceptor, namespace);
context.getSession().put(Constants.SESS_PAGE_INFO_RemoteAddr_ByInterceptor, remoteAddr);
context.getSession().put(Constants.SESS_PAGE_INFO_Referer_ByInterceptor, referer);
return actionInvocation.invoke();
}
use of com.opensymphony.xwork2.ActionContext in project bamboobsc by billchen198318.
the class JsonOutermostBracketsInterceptor method intercept.
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
ActionContext context = actionInvocation.getInvocationContext();
HttpServletResponse response = (HttpServletResponse) context.get(StrutsStatics.HTTP_RESPONSE);
response.setCharacterEncoding("utf8");
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.print("[");
writer.flush();
String forward = actionInvocation.invoke();
writer.print("]");
writer.flush();
return forward;
}
use of com.opensymphony.xwork2.ActionContext in project entando-core by entando.
the class GuiFragmentResult method doExecute.
/**
* Execute this result, using the specified fragment.
* @param code The code of the fragment
* @param invocation The invocation
*/
@Override
public void doExecute(String code, ActionInvocation invocation) throws Exception {
if (null == code) {
code = conditionalParse(this._code, invocation);
}
if (null == code) {
this.executeDispatcherResult(invocation);
return;
}
ActionContext ctx = invocation.getInvocationContext();
HttpServletRequest req = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
IGuiFragmentManager guiFragmentManager = (IGuiFragmentManager) ApsWebApplicationUtils.getBean(SystemConstants.GUI_FRAGMENT_MANAGER, req);
try {
GuiFragment guiFragment = guiFragmentManager.getGuiFragment(code);
String output = (null != guiFragment) ? guiFragment.getCurrentGui() : null;
if (StringUtils.isBlank(output)) {
_logger.info("The fragment '{}' is not available - Action '{}' - Namespace '{}'", code, invocation.getProxy().getActionName(), invocation.getProxy().getNamespace());
boolean execution = this.executeDispatcherResult(invocation);
if (!execution) {
output = "The fragment '" + code + "' is not available";
} else {
return;
}
}
RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
ExecutorBeanContainer ebc = (ExecutorBeanContainer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_EXECUTOR_BEAN_CONTAINER);
Writer writer = this.getWriter();
Template template = new Template(code, new StringReader(output), ebc.getConfiguration());
template.process(ebc.getTemplateModel(), writer);
} catch (Throwable t) {
_logger.error("Error processing GuiFragment result!", t);
throw new RuntimeException("Error processing GuiFragment result!", t);
}
}
use of com.opensymphony.xwork2.ActionContext in project beetl2.0 by javamonkey.
the class Struts2BeetlActionResult method doExecute.
protected void doExecute(String locationArg, ActionInvocation invocation) throws Exception {
ActionContext ctx = invocation.getInvocationContext();
HttpServletRequest req = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse rsp = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE);
if (!locationArg.startsWith("/")) {
String base = ResourceUtil.getResourceBase(req);
locationArg = base + "/" + locationArg;
}
Object action = invocation.getAction();
Map<String, Object> values = reflectionProvider.getBeanMap(action);
rsp.setContentType(this.pContentType);
WebRender render = new WebRender(groupTemplate) {
protected void modifyTemplate(Template template, String key, HttpServletRequest request, HttpServletResponse response, Object... args) {
Map model = (Map) args[0];
for (Object o : model.entrySet()) {
Entry entry = (Entry) o;
String name = (String) entry.getKey();
Object value = entry.getValue();
template.binding(name, value);
}
}
};
render.render(locationArg, req, rsp, values);
}
use of com.opensymphony.xwork2.ActionContext in project onebusaway-application-modules by camsys.
the class ApiKeyInterceptor method isAllowed.
// package private for unit tests
int isAllowed(ActionInvocation invocation) {
ActionContext context = invocation.getInvocationContext();
Map<String, Object> parameters = context.getParameters();
String[] keys = (String[]) parameters.get("key");
if (keys == null || keys.length == 0) {
// 401: we couldn't find the api key
return HttpServletResponse.SC_UNAUTHORIZED;
}
Status status = _keyService.getPermission(keys[0], "api");
if (status == Status.AUTHORIZED) {
return HttpServletResponse.SC_OK;
}
if (status == Status.RATE_EXCEEDED) {
return RESPONSE_TOO_MANY_REQUESTS;
}
// fall through is 403 Forbidden (we understood the key, but auth failed)
return HttpServletResponse.SC_FORBIDDEN;
}
Aggregations