Search in sources :

Example 1 with ExtendedDefaultActionMapper

use of org.entando.entando.aps.internalservlet.system.dispatcher.mapper.ExtendedDefaultActionMapper in project entando-core by entando.

the class Struts2ServletDispatcher method service.

@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try {
        RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
        String currentFrameActionPath = request.getParameter(InternalServletTag.REQUEST_PARAM_FRAMEDEST);
        Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
        Boolean staticAction = (Boolean) reqCtx.getExtraParam(InternalServletTag.EXTRAPAR_STATIC_ACTION);
        boolean executeCustomAction = (null == staticAction || !staticAction) && (null == currentFrameActionPath || Integer.parseInt(currentFrameActionPath) == currentFrame.intValue());
        prepare.createActionContext(request, response);
        prepare.assignDispatcherToThread();
        prepare.setEncodingAndLocale(request, response);
        request = prepare.wrapRequest(request);
        ActionMapper actionMapper = new ExtendedDefaultActionMapper();
        Dispatcher dispatcher = prepare.getDispatcher();
        String entandoActionName = EntandoActionUtils.extractEntandoActionName(request);
        ActionMapping mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager());
        if (mapping != null && null != entandoActionName && executeCustomAction) {
            mapping.setName(entandoActionName);
        }
        if (mapping == null) {
            boolean handled = execute.executeStaticResourceRequest(request, response);
            if (!handled) {
                throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter instead.");
            }
        } else {
            execute.executeAction(request, response, mapping);
        }
    } finally {
        prepare.cleanupRequest(request);
    }
}
Also used : ServletException(javax.servlet.ServletException) ActionMapper(org.apache.struts2.dispatcher.mapper.ActionMapper) ExtendedDefaultActionMapper(org.entando.entando.aps.internalservlet.system.dispatcher.mapper.ExtendedDefaultActionMapper) ActionMapping(org.apache.struts2.dispatcher.mapper.ActionMapping) ExtendedDefaultActionMapper(org.entando.entando.aps.internalservlet.system.dispatcher.mapper.ExtendedDefaultActionMapper) RequestContext(com.agiletec.aps.system.RequestContext) Dispatcher(org.apache.struts2.dispatcher.Dispatcher)

Aggregations

RequestContext (com.agiletec.aps.system.RequestContext)1 ServletException (javax.servlet.ServletException)1 Dispatcher (org.apache.struts2.dispatcher.Dispatcher)1 ActionMapper (org.apache.struts2.dispatcher.mapper.ActionMapper)1 ActionMapping (org.apache.struts2.dispatcher.mapper.ActionMapping)1 ExtendedDefaultActionMapper (org.entando.entando.aps.internalservlet.system.dispatcher.mapper.ExtendedDefaultActionMapper)1