use of com.opensymphony.xwork2.inject.Context in project KeyBox by skavanagh.
the class HTTPStrictTransportSecurityInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext context = invocation.getInvocationContext();
HttpServletResponse response = (HttpServletResponse) context.get(StrutsStatics.HTTP_RESPONSE);
String headerValue = MAX_AGE + ONE_YEAR;
response.addHeader(HEADER, headerValue);
return invocation.invoke();
}
use of com.opensymphony.xwork2.inject.Context in project bamboobsc by billchen198318.
the class NoCacheHeaderInterceptor method intercept.
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
ActionContext context = actionInvocation.getInvocationContext();
HttpServletResponse response = (HttpServletResponse) context.get(StrutsStatics.HTTP_RESPONSE);
if (response != null) {
response.setHeader("Cache-control", "no-cache, no-store");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "0");
}
return actionInvocation.invoke();
}
use of com.opensymphony.xwork2.inject.Context in project onebusaway-application-modules by camsys.
the class TextmarksSessionInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
processGoogleAnalytics();
ActionContext context = invocation.getInvocationContext();
Map<String, Object> parameters = context.getParameters();
Object phoneNumber = parameters.get(_phoneNumberParameterName);
if (phoneNumber == null)
return invocation.invoke();
if (phoneNumber instanceof String[]) {
String[] values = (String[]) phoneNumber;
if (values.length == 0)
return invocation.invoke();
phoneNumber = values[0];
}
String sessionId = phoneNumber.toString();
Map<String, Object> persistentSession = _sessionManager.getContext(sessionId);
Map<String, Object> originalSession = context.getSession();
context.setSession(persistentSession);
XWorkRequestAttributes attributes = new XWorkRequestAttributes(context, sessionId);
RequestAttributes originalAttributes = RequestContextHolder.getRequestAttributes();
RequestContextHolder.setRequestAttributes(attributes);
Object action = invocation.getAction();
if (action instanceof SessionAware)
((SessionAware) action).setSession(persistentSession);
try {
return invocation.invoke();
} finally {
RequestContextHolder.setRequestAttributes(originalAttributes);
context.setSession(originalSession);
}
}
use of com.opensymphony.xwork2.inject.Context in project onebusaway-application-modules by camsys.
the class TwilioInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext context = invocation.getInvocationContext();
Map<String, Object> parameters = context.getParameters();
/* Stringify parameters for debugging output */
String paramString = "";
for (Entry<String, Object> entry : parameters.entrySet()) {
paramString += entry.getKey() + "=";
Object val = entry.getValue();
if (val instanceof String[]) {
paramString += Arrays.toString((String[]) val);
} else {
paramString += val.toString();
}
paramString += ", ";
}
int idx = paramString.lastIndexOf(',');
if (idx >= 0) {
paramString = paramString.substring(0, idx);
}
_log.debug("in with params={" + paramString + "} and session=" + context.getSession());
Object phoneNumber = parameters.get(_phoneNumberParameterName);
if (phoneNumber == null) {
return invocation.invoke();
}
if (phoneNumber instanceof String[]) {
String[] values = (String[]) phoneNumber;
if (values.length == 0)
return invocation.invoke();
phoneNumber = values[0];
}
String sessionId = phoneNumber.toString();
// Strip off leading '+', if any
sessionId = sessionId.replaceFirst("\\+", "");
Map<String, Object> persistentSession = _sessionManager.getContext(sessionId);
_log.debug("remapping sesssionId " + sessionId + " to " + persistentSession);
Map<String, Object> originalSession = context.getSession();
context.setSession(persistentSession);
XWorkRequestAttributes attributes = new XWorkRequestAttributes(context, sessionId);
RequestAttributes originalAttributes = RequestContextHolder.getRequestAttributes();
RequestContextHolder.setRequestAttributes(attributes);
Object action = invocation.getAction();
if (action instanceof SessionAware)
((SessionAware) action).setSession(persistentSession);
try {
return invocation.invoke();
} finally {
RequestContextHolder.setRequestAttributes(originalAttributes);
context.setSession(originalSession);
}
}
use of com.opensymphony.xwork2.inject.Context in project onebusaway-application-modules by camsys.
the class MultipleRoutesFoundAction method execute.
@Override
public String execute() throws Exception {
Integer navState = (Integer) sessionMap.get("navState");
if (navState == null) {
navState = DISPLAY_DATA;
}
_log.debug("MultipleRoutesFound, navState: " + navState);
if (navState == DISPLAY_DATA) {
ActionContext context = ActionContext.getContext();
ValueStack vs = context.getValueStack();
List<RouteBean> routes = (List<RouteBean>) vs.findValue("routes");
int index = 1;
addMessage(Messages.MULTIPLE_ROUTES_WERE_FOUND);
// Keep a map of key options and their corresponding route beans
Map<Integer, RouteBean> keyMapping = new HashMap<Integer, RouteBean>();
for (RouteBean route : routes) {
addMessage(Messages.FOR);
addMessage(Messages.ROUTE);
String routeNumber = route.getShortName();
addText(_routeNumberPronunciation.modify(routeNumber));
addMessage(Messages.OPERATED_BY);
addText(route.getAgency().getName());
addMessage(Messages.PLEASE_PRESS);
String key = Integer.toString(index++);
addText(key);
keyMapping.put(new Integer(index - 1), route);
}
addMessage(Messages.HOW_TO_GO_BACK);
// addAction("\\*", "/back");
addMessage(Messages.TO_REPEAT);
sessionMap.put("keyMapping", keyMapping);
navState = DO_ROUTING;
sessionMap.put("navState", navState);
setNextAction("search/multiple-routes-found");
} else {
// Do the routing, matching the key pressed with the correct route bean.
_log.debug("Handling selection of choice of routes.");
// Handle "back" request ('*' key pressed)
if (PREVIOUS_MENU_ITEM.equals(getInput())) {
return "back";
}
int key = Integer.parseInt(getInput());
Map<Integer, RouteBean> keyMapping = (Map<Integer, RouteBean>) sessionMap.get("keyMapping");
_route = (RouteBean) keyMapping.get(key);
navState = DISPLAY_DATA;
sessionMap.put("navState", navState);
_log.debug("Key " + key + " entered for route: " + _route.getId());
return "route-selected";
}
return SUCCESS;
}
Aggregations