Search in sources :

Example 16 with ActionContext

use of com.opensymphony.xwork2.ActionContext in project onebusaway-application-modules by camsys.

the class ApiKeyInterceptor method isAllowed.

private ApiKeyPermissionService.Status 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)
        return ApiKeyPermissionService.Status.UNAUTHORIZED;
    return _keyService.getPermission(keys[0], "api");
}
Also used : ActionContext(com.opensymphony.xwork2.ActionContext)

Example 17 with ActionContext

use of com.opensymphony.xwork2.ActionContext 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";
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy) ActionInvocation(com.opensymphony.xwork2.ActionInvocation) ActionContext(com.opensymphony.xwork2.ActionContext)

Example 18 with ActionContext

use of com.opensymphony.xwork2.ActionContext in project onebusaway-application-modules by camsys.

the class NextActionSupport method getNextActionOrSuccess.

protected String getNextActionOrSuccess() {
    List<NextAction> stack = getNextActionStack(false);
    if (stack == null || stack.isEmpty())
        return SUCCESS;
    NextAction next = stack.remove(stack.size() - 1);
    Map<String, String[]> params = next.getParameters();
    if (params != null && !params.isEmpty()) {
        ActionContext context = ActionContext.getContext();
        Map<String, Object> contextParameters = context.getParameters();
        contextParameters.putAll(params);
    }
    return next.getAction();
}
Also used : ActionContext(com.opensymphony.xwork2.ActionContext) NextAction(org.onebusaway.presentation.model.NextAction)

Example 19 with ActionContext

use of com.opensymphony.xwork2.ActionContext in project onebusaway-application-modules by camsys.

the class IntegrationTestingInterceptor method intercept.

@Override
public String intercept(ActionInvocation invocation) throws Exception {
    ActionContext context = invocation.getInvocationContext();
    AgiRequest request = AgiEntryPoint.getAgiRequest(context);
    Map<?, ?> r = request.getRequest();
    /**
     * This interceptor will be called multiple times in the course of
     * processing the actions for a call, so we only check the reset user param
     * once
     */
    Object value = r.remove(RESET_USER);
    if (value != null && value.equals("true"))
        context.getParameters().put(PhoneNumberLoginInterceptor.RESET_USER, Boolean.TRUE);
    return invocation.invoke();
}
Also used : ActionContext(com.opensymphony.xwork2.ActionContext) AgiRequest(org.asteriskjava.fastagi.AgiRequest)

Example 20 with ActionContext

use of com.opensymphony.xwork2.ActionContext in project onebusaway-application-modules by camsys.

the class ArrivalsAndDeparturesTemplate method buildTemplate.

@Override
public void buildTemplate(ActionContext context) {
    ValueStack valueStack = context.getValueStack();
    PhoneArrivalsAndDeparturesModel model = (PhoneArrivalsAndDeparturesModel) valueStack.findValue("model");
    StopsWithArrivalsAndDeparturesBean result = model.getResult();
    buildPredictedArrivalsTemplate(result.getArrivalsAndDepartures());
    addMessage(Messages.ARRIVAL_INFO_ON_SPECIFIC_ROUTE);
    AgiActionName byRouteAction = addActionWithParameterFromMatch("1(\\d+)#", "/stop/arrivalsAndDeparturesForRoute", "route", 1);
    byRouteAction.putParam("model", model);
    addMessage(Messages.ARRIVAL_INFO_BOOKMARK_THIS_LOCATION);
    AgiActionName bookmarkAction = addAction("2", "/stop/bookmark");
    bookmarkAction.putParam("stops", result.getStops());
    addMessage(Messages.ARRIVAL_INFO_RETURN_TO_MAIN_MENU);
    addAction("3", "/index");
    addAction("(#|[04-9]|1.*\\*)", "/repeat");
    addMessage(Messages.HOW_TO_GO_BACK);
    addAction("\\*", "/back");
    addMessage(Messages.TO_REPEAT);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) StopsWithArrivalsAndDeparturesBean(org.onebusaway.transit_data.model.StopsWithArrivalsAndDeparturesBean) PhoneArrivalsAndDeparturesModel(org.onebusaway.phone.impl.PhoneArrivalsAndDeparturesModel) AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Aggregations

ActionContext (com.opensymphony.xwork2.ActionContext)32 ValueStack (com.opensymphony.xwork2.util.ValueStack)15 AgiActionName (org.onebusaway.probablecalls.AgiActionName)7 ActionProxy (com.opensymphony.xwork2.ActionProxy)6 ServletActionContext (org.apache.struts2.ServletActionContext)6 ActionInvocation (com.opensymphony.xwork2.ActionInvocation)5 List (java.util.List)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 HashMap (java.util.HashMap)4 Locale (java.util.Locale)4 Map (java.util.Map)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 XWorkRequestAttributes (org.onebusaway.presentation.impl.users.XWorkRequestAttributes)3 StopBean (org.onebusaway.transit_data.model.StopBean)3 IOException (java.io.IOException)2 SessionAware (org.apache.struts2.interceptor.SessionAware)2 Test (org.junit.Test)2 BookmarkWithStopsBean (org.onebusaway.presentation.model.BookmarkWithStopsBean)2 NameBean (org.onebusaway.transit_data.model.NameBean)2 RouteBean (org.onebusaway.transit_data.model.RouteBean)2