Package com.volantis.mcs.servlet.http

Examples of com.volantis.mcs.servlet.http.HttpRequestStandardizer


            HttpServletRequest request,
            HttpServletResponse response)
            throws IOException, ServletException {

        // Get the project configurations for the specified request.
        HttpRequestStandardizer requestStandardizer =
                new HttpRequestStandardizer(request);

        ProjectDefinition definition =
                getProjectDefinition(requestStandardizer);

        if (definition == null) {
            // A resource server is incorrectly configured without a project
            // configuration file, so send an error if none can be found.
            response.sendError(HttpServletResponse.SC_NOT_FOUND);

        } else {
            // Get the full url to the project's root directory that the client
            // can use to identify the project.
            final String projectURL = definition.getExternalProjectRoot();

            // Always send the header back indicating where to find the project
            // for the resource so that MCS knows that it belongs to a project.
            // Without this MCS will not load the project associated with this
            // policy and therefore may not work as expected.
            response.setHeader(MCS_PROJECT_HEADER, projectURL);

            if (request.getHeader(MCS_PROJECT_HEADER) != null) {

                // The configuration is always sent back as UTF-8.
                response.setContentType("text/xml; charset=utf-8");

                // Write the modified client as a string.
                Writer writer = response.getWriter();
                String clientProject = definition.getClientConfigurationAsXML();
                writer.write(clientProject);
                writer.close();

            } else {
                // The resource belongs to the project so we need to create a
                // path to the resource that is relative to the project.
                String contextRelativePath =
                        requestStandardizer.getContextRelativePathInfo();

                // This is a normal request for a resource in a project.
                InputStream resourceAsStream = getResourceAsStream(
                        definition, contextRelativePath);
                if (resourceAsStream == null) {
View Full Code Here

TOP

Related Classes of com.volantis.mcs.servlet.http.HttpRequestStandardizer

Copyright © 2018 www.massapicom. 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.