Examples of TurbineRunData


Examples of com.alibaba.citrus.turbine.TurbineRunData

    public static TurbineRunData getTurbineRunData(HttpServletRequest request) {
        return getTurbineRunData(request, false);
    }

    public static TurbineRunData getTurbineRunData(HttpServletRequest request, boolean create) {
        TurbineRunData rundata = (TurbineRunData) request.getAttribute(TURBINE_RUNDATA_KEY);

        if (rundata == null && create) {
            Context context = (Context) request.getAttribute(TURBINE_RUNDATA_CONTEXT_KEY);

            rundata = new TurbineRunDataImpl(request, context);
View Full Code Here

Examples of com.alibaba.citrus.turbine.TurbineRunData

    /**
     * ���csrf���������ض��򵽳���ҳ�档
     */
    public void invoke(PipelineContext pipelineContext) throws Exception {
        TurbineRunData rundata = getTurbineRunData(request);

        // ��ȡrequest�е�csrfֵ
        String tokenFromRequest = StringUtil.trimToNull(rundata.getParameters().getString(tokenKey));

        if (tokenFromRequest != null) {
            HttpSession session = rundata.getRequest().getSession();

            // �ȼ��longLiveToken�����ƥ�䣬���ü��uniqueToken�ˡ�
            if (!tokenFromRequest.equals(CsrfToken.getLongLiveTokenInSession(session))) {
                List<String> tokensInSession = CsrfToken.getTokensInSession(session, tokenKey);

View Full Code Here

Examples of com.alibaba.citrus.turbine.TurbineRunData

    @Autowired
    private ModuleLoaderService moduleLoaderService;

    public void invoke(PipelineContext pipelineContext) throws Exception {
        TurbineRunData rundata = getTurbineRunData(request);

        // ����ض����־��������ض�������Ҫ��ҳ�������
        if (!rundata.isRedirected()) {
            String action = rundata.getAction();

            // ����ҵ�action����ִ��֮��
            if (!StringUtil.isEmpty(action)) {
                String actionKey = "_action_" + action;

                // ��ֹ�ظ�ִ��ͬһ��action��
                if (rundata.getRequest().getAttribute(actionKey) == null) {
                    rundata.getRequest().setAttribute(actionKey, "executed");

                    try {
                        moduleLoaderService.getModule(ACTION_MODULE, action).execute();
                    } catch (ModuleLoaderException e) {
                        throw new PipelineException("Could not load action module: " + action, e);
View Full Code Here

Examples of com.alibaba.citrus.turbine.TurbineRunData

    protected void init() throws Exception {
        substName = defaultIfNull(substName, DEFAULT_SUBSTITUTION_NAME);
    }

    public void invoke(PipelineContext pipelineContext) throws Exception {
        TurbineRunData rundata = getTurbineRunData(request);
        Substitution subst = getSubstitution(pipelineContext);

        String resourceName;

        if (subst != null && this.resourceName != null) {
            resourceName = trimToNull(subst.substitute(this.resourceName));
        } else {
            resourceName = ServletUtil.getResourcePath(rundata.getRequest());
        }

        try {
            resourceName = URI.create(resourceName).normalize().toString();

            if (resourceName.contains("../")) {
                resourceName = null;
            }
        } catch (IllegalArgumentException e) {
            resourceName = null;
        }

        Resource resource = null;

        if (resourceName != null) {
            resource = loader.getResource(resourceName);
        }

        if (resource == null || !resource.exists()) {
            throw new com.alibaba.citrus.webx.ResourceNotFoundException("Could not find resource: " + resourceName);
        }

        InputStream istream = null;
        OutputStream ostream = null;

        try {
            URLConnection connection = resource.getURL().openConnection();
            String contentType = connection.getContentType();

            if (contentType != null) {
                rundata.getResponse().setContentType(contentType);
            }

            istream = connection.getInputStream();

            // �����Ѿ�ȡ������������ʼ�����
            bufferedRequestContext.setBuffering(false);

            ostream = rundata.getResponse().getOutputStream();

            StreamUtil.io(istream, ostream, true, false);
        } catch (IOException e) {
            throw new PipelineException("Failed reading resource: " + resource);
        } finally {
View Full Code Here

Examples of com.alibaba.citrus.turbine.TurbineRunData

            callback = new DefaultCallback();
        }
    }

    public void invoke(PipelineContext pipelineContext) throws Exception {
        TurbineRunData rundata = getTurbineRunData(request);

        @SuppressWarnings("unchecked")
        Callback<Object> cb = (Callback<Object>) callback;

        Object status = cb.onStart(rundata);

        String userName = cb.getUserName(status);
        String[] roleNames = cb.getRoleNames(status);

        String target = rundata.getTarget();
        String action = rundata.getAction();
        String event = capitalize(rundata.getActionEvent());

        // ȡ�õ�ǰ�����actions�����������֣�
        // 1. screen
        // 2. action.*.event - �����������action�����Ļ�
        // 3. callback���صĶ���actions
View Full Code Here

Examples of com.alibaba.citrus.turbine.TurbineRunData

    private void doWriteTo(String templateName, TemplateContext templateContext, Object out) throws TemplateException, IOException {
        try {
            String path = getTemplatePath(templateName);
            ContextMap map = new ContextMap(templateContext);
            TurbineRunData rundata = (TurbineRunData) templateContext.get("rundata");
            if (rundata != null) {
                HttpServletRequest request = rundata.getRequest();
                HttpServletResponse response = rundata.getResponse();
                if (rundata.getRequest() != null && rundata.getResponse() != null) {
                    WebEngine.setRequestAndResponse(request, response);
                    WebEngine.getEngine().getTemplate(path, request.getLocale(), templateEncoding, map).render(map, out);
                    return;
                }
            }
View Full Code Here

Examples of org.apache.turbine.services.rundata.TurbineRunData

                tryRunDataService = false;
            }
        }

        // Failed, create a default implementation using the Pool Service.
        TurbineRunData data =
                (TurbineRunData) TurbinePool.getInstance(DefaultTurbineRunData.class);

        // Cache some information that will be used elsewhere.
        data.setRequest(req);
        data.setResponse(res);

        // Let the implementation to create messages on demand.
        // data.setMessages(new FormMessages());

        // data.context = this.getServletContext();

        // Don't set this because if we want to output via
        // res.getOutputStream() then we will get an
        // IllegalStateException (already called getWriter()).  The
        // solution is to only do this if data.getOut() is called and
        // data.out is null. -jss

        // data.setOut(data.getResponse().getWriter());

        String contextPath = req.getContextPath();

        String scriptName = contextPath + data.getRequest().getServletPath();

        // Sets the default cookie parser.
        data.setCookieParser(new DefaultCookieParser());

        // Contains all of the GET/POST parameters.
        data.setParameterParser(new DefaultParameterParser());

        // Get the HttpSession object.
        data.setSession(data.getRequest().getSession(true));

        // Set the servlet configuration in RunData for use in loading
        // other servlets.
        data.setServletConfig(config);

        // Now set the ServerData.
        data.setServerData(new ServerData(data.getRequest().getServerName(),
                data.getRequest().getServerPort(),
                data.getRequest().getScheme(),
                scriptName,
                contextPath));
        return (RunData) data;
    }
View Full Code Here

Examples of org.apache.turbine.services.rundata.TurbineRunData

                tryRunDataService = false;
            }
        }

        // Failed, create a default implementation using the Pool Service.
        TurbineRunData data =
                (TurbineRunData) TurbinePool.getInstance(DefaultTurbineRunData.class);

        // Cache some information that will be used elsewhere.
        data.setRequest(req);
        data.setResponse(res);

        // Let the implementation to create messages on demand.
        // data.setMessages(new FormMessages());

        // data.context = this.getServletContext();

        // Don't set this because if we want to output via
        // res.getOutputStream() then we will get an
        // IllegalStateException (already called getWriter()).  The
        // solution is to only do this if data.getOut() is called and
        // data.out is null. -jss

        // data.setOut(data.getResponse().getWriter());

        String contextPath = req.getContextPath();

        String scriptName = contextPath + data.getRequest().getServletPath();

        // Sets the default cookie parser.
        data.setCookieParser(new DefaultCookieParser());

        // Contains all of the GET/POST parameters.
        data.setParameterParser(new DefaultParameterParser());

        // Get the HttpSession object.
        data.setSession(data.getRequest().getSession(true));

        // Set the servlet configuration in RunData for use in loading
        // other servlets.
        data.setServletConfig(config);

        // Now set the ServerData.
        data.setServerData(new ServerData(data.getRequest().getServerName(),
                data.getRequest().getServerPort(),
                data.getRequest().getScheme(),
                scriptName,
                contextPath));
        return (RunData) data;
    }
View Full Code Here

Examples of org.apache.turbine.services.rundata.TurbineRunData

        }

        // Failed, create a default implementation using the Pool Service.
        PoolService pool = (PoolService)
            TurbineServices.getInstance().getService(PoolService.SERVICE_NAME);
        TurbineRunData data = (TurbineRunData)
            pool.getInstance(DefaultTurbineRunData.class);

        // Cache some information that will be used elsewhere.
        data.setRequest(req);
        data.setResponse(res);
       
        // Let the implementation to create messages on demand.
        // data.setMessages(new FormMessages());

        // data.context = this.getServletContext();

        // Don't set this because if we want to output via
        // res.getOutputStream() then we will get an
        // IllegalStateException (already called getWriter()).  The
        // solution is to only do this if data.getOut() is called and
        // data.out is null. -jss

        // data.setOut(data.getResponse().getWriter());

        // Allow Turbine to work with both 2.2 (and 2.1) and 2.0
        // Servlet API.
        String contextPath = null;
        Class jsdkClass = HttpServletRequest.class;
        try
        {
            java.lang.reflect.Method meth =
                jsdkClass.getDeclaredMethod("getContextPath", null);
            contextPath = (String) meth.invoke(req, null);
        }
        catch (Exception ex)
        {
            // Ignore a NoSuchMethodException because it means we are
            // using Servlet API 2.0.  Make sure scriptName is not
            // null.
            contextPath = "";
        }

        String scriptName = contextPath + data.getRequest().getServletPath();

        // Sets the default cookie parser.
        data.setCookieParser(new DefaultCookieParser());

        // Contains all of the GET/POST parameters.
        data.setParameterParser(new DefaultParameterParser());

        // Get the HttpSession object.
        data.setSession( data.getRequest().getSession(true) );

        // Set the servlet configuration in RunData for use in loading
        // other servlets.
        data.setServletConfig(config);

        // Now set the ServerData.
        data.setServerData( new ServerData( data.getRequest().getServerName(),
                                data.getRequest().getServerPort(),
                                data.getRequest().getScheme(),
                                scriptName,
                                contextPath ) );
        return (RunData) data;
    }
View Full Code Here

Examples of org.apache.turbine.services.rundata.TurbineRunData

        }

        // Failed, create a default implementation using the Pool Service.
        PoolService pool = (PoolService)
            TurbineServices.getInstance().getService(PoolService.SERVICE_NAME);
        TurbineRunData data = (TurbineRunData)
            pool.getInstance(DefaultTurbineRunData.class);

        // Cache some information that will be used elsewhere.
        data.setRequest(req);
        data.setResponse(res);
       
        // Let the implementation to create messages on demand.
        // data.setMessages(new FormMessages());

        // data.context = this.getServletContext();

        // Don't set this because if we want to output via
        // res.getOutputStream() then we will get an
        // IllegalStateException (already called getWriter()).  The
        // solution is to only do this if data.getOut() is called and
        // data.out is null. -jss

        // data.setOut(data.getResponse().getWriter());

        // Allow Turbine to work with both 2.2 (and 2.1) and 2.0
        // Servlet API.
        String contextPath = null;
        Class jsdkClass = HttpServletRequest.class;
        try
        {
            java.lang.reflect.Method meth =
                jsdkClass.getDeclaredMethod("getContextPath", null);
            contextPath = (String) meth.invoke(req, null);
        }
        catch (Exception ex)
        {
            // Ignore a NoSuchMethodException because it means we are
            // using Servlet API 2.0.  Make sure scriptName is not
            // null.
            contextPath = "";
        }

        String scriptName = contextPath + data.getRequest().getServletPath();

        // Sets the default cookie parser.
        data.setCookieParser(new DefaultCookieParser());

        // Contains all of the GET/POST parameters.
        data.setParameterParser(new DefaultParameterParser());

        // Get the HttpSession object.
        data.setSession( data.getRequest().getSession(true) );

        // Set the servlet configuration in RunData for use in loading
        // other servlets.
        data.setServletConfig(config);

        // Now set the ServerData.
        data.setServerData( new ServerData( data.getRequest().getServerName(),
                                data.getRequest().getServerPort(),
                                data.getRequest().getScheme(),
                                scriptName,
                                contextPath ) );
        return (RunData) data;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.