Search in sources :

Example 1 with ActionMapping

use of org.apache.struts2.dispatcher.mapper.ActionMapping in project entando-core by entando.

the class ExtendedDefaultActionMapper method getMapping.

@Override
public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) {
    ActionMapping mapping = new ActionMapping();
    String uri = this.getUri(request);
    int indexOfSemicolon = uri.indexOf(";");
    uri = (indexOfSemicolon > -1) ? uri.substring(0, indexOfSemicolon) : uri;
    uri = super.dropExtension(uri, mapping);
    if (uri == null) {
        return null;
    }
    super.parseNameAndNamespace(uri, mapping, configManager);
    super.handleSpecialParameters(request, mapping);
    return super.parseActionName(mapping);
}
Also used : ActionMapping(org.apache.struts2.dispatcher.mapper.ActionMapping)

Example 2 with ActionMapping

use of org.apache.struts2.dispatcher.mapper.ActionMapping 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)

Example 3 with ActionMapping

use of org.apache.struts2.dispatcher.mapper.ActionMapping in project entando-core by entando.

the class PrepareOperations method findActionMapping.

@Override
public ActionMapping findActionMapping(HttpServletRequest request, HttpServletResponse response, boolean forceLookup) {
    ActionMapping mapping = (ActionMapping) request.getAttribute(STRUTS_ACTION_MAPPING_KEY);
    if (mapping == null || forceLookup) {
        try {
            Container container = this._dispatcher.getContainer();
            ActionMapper mapper = container.getInstance(ActionMapper.class);
            String entandoActionName = EntandoActionUtils.extractEntandoActionName(request);
            mapping = mapper.getMapping(request, this._dispatcher.getConfigurationManager());
            if (null != entandoActionName) {
                mapping.setName(entandoActionName);
            }
            if (mapping != null) {
                request.setAttribute(STRUTS_ACTION_MAPPING_KEY, mapping);
            }
        } catch (Exception ex) {
            this._dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex);
        }
    }
    return mapping;
}
Also used : ActionMapping(org.apache.struts2.dispatcher.mapper.ActionMapping) Container(com.opensymphony.xwork2.inject.Container) ActionMapper(org.apache.struts2.dispatcher.mapper.ActionMapper)

Example 4 with ActionMapping

use of org.apache.struts2.dispatcher.mapper.ActionMapping in project entando-core by entando.

the class Submit method evaluateExtraParams.

@Override
public void evaluateExtraParams() {
    super.evaluateExtraParams();
    /*
		if (align == null) {
			align = "right";
		}
		*/
    String submitType = BUTTONTYPE_INPUT;
    if (type != null && (BUTTONTYPE_BUTTON.equalsIgnoreCase(type) || (supportsImageType() && BUTTONTYPE_IMAGE.equalsIgnoreCase(type)))) {
        submitType = type;
    }
    this.addParameter("type", submitType);
    if (!BUTTONTYPE_INPUT.equals(submitType) && (label == null)) {
        this.addParameter("label", getParameters().get("nameValue"));
    }
    if (action != null || method != null) {
        String name;
        if (action != null) {
            ActionMapping mapping = new ActionMapping();
            mapping.setName(findString(action));
            if (method != null) {
                mapping.setMethod(findString(method));
            }
            mapping.setExtension("");
            name = ApsRequestParamsUtil.ENTANDO_ACTION_PREFIX + actionMapper.getUriFromActionMapping(mapping);
        } else {
            name = "method:" + findString(method);
        }
        addParameter("name", name);
    }
// addParameter("align", findString(align));
}
Also used : ActionMapping(org.apache.struts2.dispatcher.mapper.ActionMapping)

Aggregations

ActionMapping (org.apache.struts2.dispatcher.mapper.ActionMapping)4 ActionMapper (org.apache.struts2.dispatcher.mapper.ActionMapper)2 RequestContext (com.agiletec.aps.system.RequestContext)1 Container (com.opensymphony.xwork2.inject.Container)1 ServletException (javax.servlet.ServletException)1 Dispatcher (org.apache.struts2.dispatcher.Dispatcher)1 ExtendedDefaultActionMapper (org.entando.entando.aps.internalservlet.system.dispatcher.mapper.ExtendedDefaultActionMapper)1