Package com.volantis.mcs.context

Examples of com.volantis.mcs.context.MarinerRequestContext


            }
        }

        // Get all the mariner stuff from the request
        ServletContext servletContext = getServletContext();
        MarinerRequestContext requestContext;
        Enumeration en;

        requestContext = MarinerServletRequestContext.getCurrent(request);

        if (requestContext == null) {
            try {
                requestContext = new MarinerServletRequestContext(
                        servletContext, request, response);
            } catch (Exception ex) {
                logger.error("servlet-context-creation-error");
                throw new ServletException("Unable to create new " +
                                           "MarinerServletRequestContext");
            }
        }

        MarinerPageContext pageContext =
                ContextInternals.getMarinerPageContext(requestContext);

        // Get the name of the form from the vform parameter
        String formSpecifier = (String) request.getParameter("vform");

        if (formSpecifier == null) {
            logger.error("form-name-missing");
            requestContext.release();
            throw new ServletException("No vform parameter passed.");
        }

        // Determine which URL to go to from which submission
        // button was pressed to get here
        String targetURL = null;

        SessionFormData formData = pageContext.getFormDataManager().
                getSessionFormData(formSpecifier);

        if (request.getParameter(URLConstants.NEXT_FORM_FRAGMENT) != null) {
            targetURL = formData.getFieldValue(URLConstants.NEXT_FORM_FRAGMENT);
        } else if (request.getParameter(URLConstants.PREV_FORM_FRAGMENT) !=
                null) {
            targetURL = formData.getFieldValue(URLConstants.PREV_FORM_FRAGMENT);
        } else if (request.getParameter(URLConstants.RESET_FORM_FRAGMENT) !=
                null) {
            targetURL = formData.getFieldValue(URLConstants.RESET_FORM_FRAGMENT);
        } else {
            targetURL = formData.getFieldValue(URLConstants.ACTION_FORM_FRAGMENT);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Target URL is " + targetURL);
        }

        if (targetURL == null) {
            requestContext.release();
            throw new ServletException("No target URL for dispatch.");
        }

        // Strip the context path from the front of the target URL if it is
        // there
        targetURL = removeContextPath(targetURL, request);

        // Strip the session id from the URL if there is one
        targetURL = removeSession(targetURL);


        // Make sure the target URL starts with a / (required by dispatcher).
        if (!targetURL.startsWith("/")) {
            targetURL = "/" + targetURL;
        }

        // Add the passed form parameters into the session
        en = request.getParameterNames();

        while (en.hasMoreElements()) {
            String pName = (String) en.nextElement();
            if (!(pName.equals(URLConstants.FORM_PARAMETER)) &&
                    !(pName.equals(URLConstants.NEXT_FORM_FRAGMENT)) &&
                    !(pName.equals(URLConstants.PREV_FORM_FRAGMENT)) &&
                    !(pName.equals(URLConstants.ACTION_FORM_FRAGMENT)) &&
                    !(pName.equals(URLConstants.
                                   FORM_FRAGMENTATION_PARAMETER)) &&
                    !(pName.equals(URLConstants.RESET_FORM_FRAGMENT))) {
                String pValue = (String) request.getParameter(pName);

                if (logger.isDebugEnabled()) {
                    logger.debug("Writing attribute " + pName + "=" +
                                 pValue + " to the session context.");
                }

                formData.setFieldValue(pName, pValue);
            }
        }

        // Forward to the appropriate destination
        if (logger.isDebugEnabled()) {
            logger.debug("Dispatching to " + targetURL);
        }

        RequestDispatcher rd = servletContext.getRequestDispatcher(targetURL);
        HttpServletResponse forwardResponse = response;
        CachingResponseWrapper responseWrapper = null;

        if (xdimeRequestProcessor != null) {
            // The response from the forwarded request must be wrapped so that
            // we can perform additional processing if raw XDIME is returned
            responseWrapper = new CachingResponseWrapper(response);
            forwardResponse = responseWrapper;
        }

        // Wrap the request - the wrapper removes IF headers which were causing
        // the dispatcher to report that the resource hadn't changed. However
        // we still need to process it to produce a different result!
        MCSRequestWrapper requestWrapper =  new MCSRequestWrapper(request);
        // Dispatch the request to the "final destination"
        rd.forward(requestWrapper, forwardResponse);

        // Release the request context so that it is not detected as the
        // enclosing request context when processing the XDIME. If it was, it
        // would use the original requets URL
        requestContext.release();
        // See if we need to perform additional processing or not
        if (xdimeRequestProcessor != null) {
            if (xdimeRequestProcessor.isXDIME(
                    responseWrapper.getMimeTypeFromContentType())) {
                // We have found raw XDIME which must be converted into the
                // channelized response, probably because the container doesn't
                // apply filters when invoking RequestDispatcher#forward - this
                // because of an ambiguity in the 2.3 Servlet API spec
                processXDIME(servletContext,
                             request,
                             responseWrapper,
                             targetURL);
            } else {
                // We have found an already channelized response so we simply
                // ensure that the real response is populated from the wrapper
                responseWrapper.writeTo(response);
            }
        }

        requestContext.release();
    }
View Full Code Here


     */
    public void testMenuBuilding() throws Exception {

        // Set up the test "environemnt" to simulate the request
        TestMarinerPageContext pageContext = new TestMarinerPageContext();
        MarinerRequestContext requestContext = new TestMarinerRequestContext();

        // Set up the test-specific renderer locator
        MenuRendererSelectorLocator.setDefaultInstance(new RendererLocator());

        // Set up the protocol (needed for OutputBuffer management)
View Full Code Here

    // a seperate VBM to fix this testcase.  VBM: 2003051304
    public void noTestCreatePackage() throws Exception {
        final MultipartPackageHandler handler =
            new MultipartPackageHandler();
        MarinerPageContext pageContext = createContexts(handler);
        MarinerRequestContext requestContext =
            pageContext.getRequestContext();
        TestEnvironmentContext envContext =
            (TestEnvironmentContext)pageContext.getEnvironmentContext();

        // This asset exists
View Full Code Here

            final String value) throws PAPIException {
        // enable to informally test the claim in the comment above.
        // enableLog4jDebug();
       
        TestMarinerPageContext pageContext = new TestMarinerPageContext();
        MarinerRequestContext requestContext = new TestMarinerRequestContext();
        VolantisProtocol protocol = new VolantisProtocolStub() {
            public void writeOpenAnchor (
                    com.volantis.mcs.protocols.AnchorAttributes attributes) {
                assertEquals( "", value, attributes.getId());
            }
View Full Code Here

     * @throws Exception
     */
    private Element setUpTableAttributesBorderSpacingTests(int borderSpacing)
            throws Exception {
        // Set up the required contexts
        MarinerRequestContext requestContext = new TestMarinerRequestContext();
        TestMarinerPageContext context = new TestMarinerPageContext();
        context.pushRequestContext(requestContext);
        ContextInternals.setMarinerPageContext(requestContext, context);
        testable.setStyleSheetRenderer(CSSStyleSheetRenderer.getSingleton());
        context.setDeviceName("PC-Win32-IE5.5");
View Full Code Here

        outputBufferStack = new Stack();
        metaDataMap = new HashMap();

        final XDIMEContextInternal context = (XDIMEContextInternal)
            XDIMEContextFactory.getDefaultInstance().createXDIMEContext();
        final MarinerRequestContext requestContextMock =
            getMarinerRequestContextMock();

        context.setInitialRequestContext(requestContextMock);

View Full Code Here

     * @throws Exception
     */
    public void testBody() throws Exception {
        initialise();

        MarinerRequestContext marinerRequestContext =
                getMarinerRequestContext();

        XDIMEContextInternal xdimeContext =
                getXdimeContext(marinerRequestContext);

View Full Code Here

                    "arguments.");
        }

        // Extract the mariner request context from the expression context and
        // the page context from there
        MarinerRequestContext requestContext =
                (MarinerRequestContext)expressionContext.getProperty(
                        MarinerRequestContext.class);
        MarinerPageContext pageContext =
                ContextInternals.getMarinerPageContext(requestContext);
View Full Code Here

    }
*/

    // javadoc inherited.
    public void testAddGridAttributes() throws Exception {
        MarinerRequestContext requestContext = new TestMarinerRequestContext();
        Element element = domFactory.createElement();
        element.setName("testElement");

        context = new TestMarinerPageContext();
        context.pushRequestContext(requestContext);
View Full Code Here

    /**
     * Calls the elementStart() method on the appropriate IAPIElement.
     * @throws SAXParseException
     */
    protected void callIAPIElementStart() throws SAXParseException {
        MarinerRequestContext requestContext =
            marlinContext.getInitialRequestContext();

        IAPIElement element = elementStackEntry.getElement();
        IAPIAttributes attributes = elementStackEntry.getAttributes();

View Full Code Here

TOP

Related Classes of com.volantis.mcs.context.MarinerRequestContext

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.