Package org.apache.beehive.netui.pageflow.internal

Examples of org.apache.beehive.netui.pageflow.internal.PageFlowRequestWrapper


        throws IOException, ServletException
    {
        //
        // First check to see if we're already in a forwarded fallback request.  If so, just bail.
        //
        PageFlowRequestWrapper rw = PageFlowRequestWrapper.get( request );
        if ( rw.getOriginalServletPath() != null ) return false;      
       
        SharedFlowController sharedFlowToTry = null;
        String uriBaseName = ServletUtils.getBaseName( uri );
        int firstDot = uriBaseName.indexOf( '.' );
        int lastDot = uriBaseName.lastIndexOf( '.' );
       
        if ( firstDot != -1 && firstDot != lastDot )
        {
            String sharedFlowName = uriBaseName.substring( 0, firstDot );
           
            try
            {
                RequestContext rc = new RequestContext( request, response );
                Map defaultSharedFlows = FlowControllerFactory.get( getServletContext() ).getDefaultSharedFlows( rc );
               
                if ( defaultSharedFlows != null )
                {
                    sharedFlowToTry = ( SharedFlowController ) defaultSharedFlows.get( sharedFlowName );
                    uriBaseName = uriBaseName.substring( firstDot + 1 );
                }
            }
            catch ( ClassNotFoundException e )
            {
                throw new ServletException( e );
            }
            catch ( InstantiationException e )
            {
                throw new ServletException( e );
            }
            catch ( IllegalAccessException e )
            {
                throw new ServletException( e );
            }
        }
        else
        {
            sharedFlowToTry = FlowControllerFactory.getGlobalApp( request, response, getServletContext() );
        }
       
        //
        // If we couldn't find an appropriate module, try raising the action on the (deprecated) Global.app.
        //
       
        if ( sharedFlowToTry != null )
        {
            InternalStringBuilder sfActionURI = new InternalStringBuilder( sharedFlowToTry.getModulePath() );
            sfActionURI.append( '/' );
            sfActionURI.append( uriBaseName );
            rw.setOriginalServletPath( uri );
            ForwardRedirectHandler frh = _handlers.getForwardRedirectHandler();
            FlowControllerHandlerContext context = new FlowControllerHandlerContext( request, response, null );
            frh.forward( context, sfActionURI.toString() );
            return true;
        }
View Full Code Here


            //
            // Register the default URLRewriter
            //
            URLRewriterService.registerURLRewriter( 0, request, new DefaultURLRewriter() );

            PageFlowRequestWrapper rw = PageFlowRequestWrapper.unwrap( request );
            boolean isForwardedRequest = rw != null && rw.isForwardedRequest();
           
            try
            {
                ModuleConfig prevModuleConfig = RequestUtils.getRequestModuleConfig( httpRequest );
                MessageResources prevMessageResources = ( MessageResources ) request.getAttribute( Globals.MESSAGES_KEY );
                if ( rw == null || ! rw.isStayInCurrentModule() ) initializeModule( httpRequest, httpResponse );
               
                try
                {
                    //
                    // Initialize shared flows for the current request.
                    //
                    Map/*< String, SharedFlowController >*/ sharedFlows =
                            _flowControllerFactory.getSharedFlowsForRequest( requestContext );
                    ImplicitObjectUtil.loadSharedFlow( request, sharedFlows );
                    ImplicitObjectUtil.loadGlobalApp( request, PageFlowUtils.getGlobalApp( httpRequest ) );
                   
                    //
                    // Make sure that the current PageFlowController is set up for this request.
                    //
                    PageFlowController curJpf;
                    if ( rw != null && rw.isStayInCurrentModule() )
                    {
                        rw.setStayInCurrentModule( false );
                        curJpf = PageFlowUtils.getCurrentPageFlow( httpRequest, _servletContext );
                    }
                    else
                    {
                        curJpf = _flowControllerFactory.getPageFlowForRequest( requestContext );
View Full Code Here

        scopedRequest.setForwardedURI( null );
       
        //
        // Now process the request.  We create a PageFlowRequestWrapper for pageflow-specific request-scoped info.
        //
        PageFlowRequestWrapper wrappedRequest = PageFlowRequestWrapper.wrapRequest( ( HttpServletRequest ) request );
        as.doGet( wrappedRequest, scopedResponse )// this just calls process() -- same as doPost()

        String returnURI;

        if ( ! scopedResponse.didRedirect() )
View Full Code Here

        if ( mapping.getMultipartClass() != null )
        {
            request.setAttribute( Globals.MULTIPART_KEY, mapping.getMultipartClass() );
        }

        PageFlowRequestWrapper requestWrapper = PageFlowRequestWrapper.get( request );
        boolean alreadyCalledInRequest = requestWrapper.isProcessPopulateAlreadyCalled();
        if ( ! alreadyCalledInRequest ) requestWrapper.setProcessPopulateAlreadyCalled( true );

        //
        // If this is a forwarded request and the form-bean is null, don't call to ProcessPopulate.
        // We don't want to expose errors due to parameters from the original request, which won't
        // apply to a forwarded action that doesn't take a form.
        //
        if ( !alreadyCalledInRequest || form != null )
        {
            //
            // If this request was forwarded by a button-override of the main form action, then ensure that there are
            // no databinding errors when the override action does not use a form bean.
            //
            if ( form == null && requestWrapper.isForwardedByButton() ) form = NULL_ACTION_FORM;

            ProcessPopulate.populate( request, response, form, alreadyCalledInRequest );
        }
    }
View Full Code Here

    {
        // Only make this check if this is an initial (non-forwarded) request.
        //
        // TODO: performance?
        //
        PageFlowRequestWrapper wrapper = PageFlowRequestWrapper.get( request );
        if ( ! wrapper.isForwardedByButton() && ! wrapper.isForwardedRequest() )
        {
            //
            // First, since we need access to request parameters here, process a multipart request
            // if that's what we have.  This puts the parameters (each in a MIME part) behind an
            // interface that makes them look like normal request parameters.
            //
            HttpServletRequest multipartAwareRequest = processMultipart( request );

            for ( Enumeration e = multipartAwareRequest.getParameterNames(); e.hasMoreElements(); )
            {
                String paramName = ( String ) e.nextElement();

                if ( paramName.startsWith( ACTION_OVERRIDE_PARAM_PREFIX ) )
                {
                    String actionPath = paramName.substring( ACTION_OVERRIDE_PARAM_PREFIX_LEN );
                    ServletContext servletContext = getServletContext();

                    String qualifiedAction = InternalUtils.qualifyAction( servletContext,actionPath );
                    actionPath = InternalUtils.createActionPath(request, qualifiedAction );

                    if ( _log.isDebugEnabled() )
                    {
                        _log.debug( "A request parameter overrode the action.  Forwarding to: " + actionPath );
                    }

                    wrapper.setForwardedByButton( true );
                    doForward( actionPath, request, response );
                    return true;
                }
            }
        }
View Full Code Here

        //
        // Register the default URLRewriter
        //
        URLRewriterService.registerURLRewriter( 0, request, new DefaultURLRewriter() );

        PageFlowRequestWrapper rw = PageFlowRequestWrapper.unwrap( request );
        boolean isForwardedRequest = rw != null && rw.isForwardedRequest();

        try
        {
            processInternal( request, response );
        }
View Full Code Here

        if ( ! "POST".equalsIgnoreCase( request.getMethod() ) ) return request;

        String contentType = request.getContentType();
        if ( contentType != null && contentType.startsWith( "multipart/form-data" ) )
        {
            PageFlowRequestWrapper pageFlowRequestWrapper = PageFlowRequestWrapper.get( request );

            //
            // We may have already gotten a multipart wrapper during process().  If so, use that.
            //
            MultipartRequestWrapper cachedWrapper = pageFlowRequestWrapper.getMultipartRequestWrapper();

            if ( cachedWrapper != null && cachedWrapper.getRequest() == request ) return cachedWrapper;

            try
            {
                //
                // First, pre-handle the multipart request.  This parses the stream and caches a single
                // MultipartRequestHandler in the outer request, so we can create new wrappers around it at will.
                //
                MultipartRequestUtils.preHandleMultipartRequest( request );
            }
            catch ( ServletException e )
            {
                _log.error( "Could not parse multipart request.", e.getRootCause() );
                return request;
            }

            MultipartRequestWrapper ret = new RehydratedMultipartRequestWrapper( request );
            pageFlowRequestWrapper.setMultipartRequestWrapper( ret );
            return ret;
        }
        else
        {
            return request;
View Full Code Here

    {
        //
        // First wrap the request with an object that contains request-scoped values that our runtime uses.  This
        // is faster than sticking everything into attributes on the request (then basically reading from a HashMap).
        //
        PageFlowRequestWrapper requestWrapper = PageFlowRequestWrapper.wrapRequest( request );
        request = requestWrapper;
       
        ServletContext servletContext = getServletContext();
        String modulePath = PageFlowUtils.getModulePathForRelativeURI( InternalUtils.getDecodedServletPath( request ) );
        ModuleConfig registeredApp;
       
        //
        // Get the registered Struts module for the request.
        //
        registeredApp = getModuleConfig( modulePath, request, response );
       
        //
        // If we've dynamically registered a module, then we need to override the base process() behavior to select the
        // module.  Note that we don't want to synchronize the call to process().
        //
        if ( registeredApp != null )
        {
            //
            // Try to select the appropriate Struts module and delegate to its RequestProcessor.
            //
            ModuleConfig moduleConfig = InternalUtils.selectModule( modulePath, request, servletContext );
            RequestProcessor requestProcessor = getRequestProcessor( moduleConfig );
            requestProcessor.process( request, response );
        }
        else
        {
           
            //
            // This is the same as the base process() behavior, but it checks for a missing module-configuration.
            //
            ModuleConfig moduleConfig = null;
           
            if ( InternalUtils.getModuleConfig( RequestUtils.getModuleName( request, servletContext ), servletContext ) != null )
            {
                String modulePrefix = RequestUtils.getModuleName( request, servletContext );
                moduleConfig = InternalUtils.selectModule( modulePrefix, request, servletContext );
            }
           
            String servletPath = InternalUtils.getDecodedServletPath( request );
            RequestProcessor rp = moduleConfig != null ? getRequestProcessor( moduleConfig ) : null;
           
            if ( rp != null && moduleCanHandlePath( moduleConfig, rp, servletPath ) )
            {
                rp.process( request, response );
            }
            else
            {
                //
                // Initialize the ServletContext in the request.  Often, we need access to the ServletContext when we only
                // have a ServletRequest.
                //
                InternalUtils.setServletContext( request, getServletContext() );
               
                if ( processUnhandledAction( request, response, servletPath ) ) return;
               
                String originalServletPath = requestWrapper.getOriginalServletPath();
                if ( originalServletPath != null )
                {
                    servletPath = originalServletPath;
                    modulePath = PageFlowUtils.getModulePathForRelativeURI( originalServletPath );
                }
View Full Code Here

        if ( mapping.getMultipartClass() != null )
        {
            request.setAttribute( Globals.MULTIPART_KEY, mapping.getMultipartClass() );
        }

        PageFlowRequestWrapper requestWrapper = PageFlowRequestWrapper.get( request );
        boolean alreadyCalledInRequest = requestWrapper.isProcessPopulateAlreadyCalled();
        if ( ! alreadyCalledInRequest ) requestWrapper.setProcessPopulateAlreadyCalled( true );
       
        //
        // If this is a forwarded request and the form-bean is null, don't call to ProcessPopulate.
        // We don't want to expose errors due to parameters from the original request, which won't
        // apply to a forwarded action that doesn't take a form.
View Full Code Here

    {
        // Only make this check if this is an initial (non-forwarded) request.
        //
        // TODO: performance?
        //
        PageFlowRequestWrapper wrapper = PageFlowRequestWrapper.get( request );
        if ( ! wrapper.isForwardedByButton() )
        {
            wrapper.setForwardedByButton( true );
           
            //
            // First, since we need access to request parameters here, process a multipart request
            // if that's what we have.  This puts the parameters (each in a MIME part) behind an
            // interface that makes them look like normal request parameters.
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.pageflow.internal.PageFlowRequestWrapper

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.