use of com.opensymphony.xwork2.ActionProxy in project onebusaway-application-modules by camsys.
the class Debug method execute.
@Override
public String execute() throws Exception {
ActionContext context = ActionContext.getContext();
ActionInvocation invocation = context.getActionInvocation();
ActionProxy proxy = invocation.getProxy();
String name = proxy.getActionName().toLowerCase();
String namespace = proxy.getNamespace().toLowerCase();
// return the 404 message if so. There has to be a better way than this?
if ((name.equals("") || name.equals("index") || name.equals("debug")) && (namespace.equals("") || namespace.equals("/"))) {
return SUCCESS;
}
return "NotFound";
}
use of com.opensymphony.xwork2.ActionProxy in project onebusaway-application-modules by camsys.
the class IndexActionTest method test404.
@Test
public void test404() throws Exception {
ActionProxy proxy = Mockito.mock(ActionProxy.class);
Mockito.when(proxy.getActionName()).thenReturn("something-else");
Mockito.when(proxy.getNamespace()).thenReturn("/");
ActionInvocation invocation = Mockito.mock(ActionInvocation.class);
Mockito.when(invocation.getProxy()).thenReturn(proxy);
Map<String, Object> c = new HashMap<String, Object>();
ActionContext ac = new ActionContext(c);
ac.setActionInvocation(invocation);
ActionContext.setContext(ac);
IndexAction action = new IndexAction();
String response = action.execute();
assertEquals("404 response", "NotFound", response);
}
use of com.opensymphony.xwork2.ActionProxy in project onebusaway-application-modules by camsys.
the class CacheControlInterceptor method getCacheControlAnnotation.
private CacheControl getCacheControlAnnotation(ActionInvocation invocation) {
Object action = invocation.getAction();
Class<? extends Object> actionClass = action.getClass();
ActionProxy proxy = invocation.getProxy();
String methodName = proxy.getMethod();
if (methodName != null) {
try {
Method m = actionClass.getMethod(methodName);
if (m != null) {
CacheControl methodCacheControl = m.getAnnotation(CacheControl.class);
if (methodCacheControl != null)
return methodCacheControl;
}
} catch (Exception ex) {
_log.warn("error searching for action method=\"" + methodName + "\" on action class=\"" + actionClass.getName() + "\"", ex);
}
}
return actionClass.getAnnotation(CacheControl.class);
}
use of com.opensymphony.xwork2.ActionProxy in project onebusaway-application-modules by camsys.
the class VehicleStatusMapAction method execute.
@Override
public String execute() {
ActionContext context = ActionContext.getContext();
ActionInvocation invocation = context.getActionInvocation();
ActionProxy proxy = invocation.getProxy();
String name = proxy.getActionName().toLowerCase();
String namespace = proxy.getNamespace().toLowerCase();
// return the 404 message if so. There has to be a better way than this?
if ((name.equals("") || name.equals("index")) && (namespace.equals("") || namespace.equals("/"))) {
return SUCCESS;
}
return "NotFound";
}
use of com.opensymphony.xwork2.ActionProxy in project onebusaway-application-modules by camsys.
the class IndexAction method execute.
@Override
public String execute() throws Exception {
ActionContext context = ActionContext.getContext();
ActionInvocation invocation = context.getActionInvocation();
ActionProxy proxy = invocation.getProxy();
String name = proxy.getActionName().toLowerCase();
String namespace = proxy.getNamespace().toLowerCase();
// return the 404 message if so. There has to be a better way than this?
if ((name.equals("") || name.equals("index")) && (namespace.equals("") || namespace.equals("/"))) {
return SUCCESS;
}
return "NotFound";
}
Aggregations