Package org.apache.beehive.netui.pageflow

Examples of org.apache.beehive.netui.pageflow.FlowController


        // check to see if this is a bad action
       
        PageFlowTagUtils.MappingAndController mac = PageFlowTagUtils.getActionMapping(request, _flowController, _state.action);
        if (mac == null) {
            FlowController globalApp = PageFlowUtils.getSharedFlow(InternalConstants.GLOBALAPP_CLASSNAME, request);
            mac = PageFlowTagUtils.getActionMapping(request, globalApp, _state.action);
        }
        if (mac == null) {
            registerTagError(Bundle.getString("Tags_BadAction", _state.action), null);
            return;
View Full Code Here


    public ActionForward handleException( FlowControllerHandlerContext context, Throwable ex,
                                          ActionMapping actionMapping, ActionForm form )
            throws IOException, ServletException
    {
        FlowController flowController = context.getFlowController();
        ServletRequest request = context.getRequest();
        ServletResponse response = context.getResponse();
       
        if ( _log.isInfoEnabled() )
        {
            _log.info( "Handling Throwable " + ex.getClass().getName() );
        }
       
        //
        // If we're already in the process of handling an exception, bail out.
        //
        PageFlowRequestWrapper rw = PageFlowRequestWrapper.get( context.getRequest() );
        Throwable alreadyBeingHandled = rw.getExceptionBeingHandled();
       
        if ( alreadyBeingHandled != null )
        {
            if ( _log.isDebugEnabled() )
            {
                _log.debug( "Already in the process of handling " + alreadyBeingHandled.getClass().getName()
                            + "; bailing out of handling for " + ex.getClass().getName() );
            }
           
            throw new UnhandledException( ex );
        }
       
        rw.setExceptionBeingHandled( ex );
       
       
        // Callback to the event reporter.
        ActionMapping originalActionMapping = actionMapping;
        _eventReporter.exceptionRaised( context, ex, originalActionMapping, form, flowController );
        long startTime = System.currentTimeMillis();
   
        //
        // Look up the ExceptionConfig that's associated with this Throwable.
        //
        Class exClass = ex.getClass();
        ExceptionConfig exceptionConfig = null;
        if ( actionMapping != null )
        {
            exceptionConfig = actionMapping.findException( exClass );
        }
        else
        {
            // If the mapping was null (i.e., the exception happened before we got the action mapping), look for the
            // exception only in the module config.
            exceptionConfig = getExceptionConfig( exClass, flowController.getModuleConfig() );
        }
       
        //
        // If there was no applicable exception handler in the current ModuleConfig, look in Global.app's module.
        //
        if ( exceptionConfig == null )
        {
            FlowController fallbackFC =
                    getFallbackFlowController( flowController, exClass, request, response, getServletContext() );
           
            if ( fallbackFC != null )
            {
                flowController = fallbackFC;
View Full Code Here

    {
        assert context.getRequest() instanceof HttpServletRequest : "don't support ServletRequest currently.";
        assert context.getResponse() instanceof HttpServletResponse : "don't support ServletResponse currently.";
        HttpServletRequest request = ( HttpServletRequest ) context.getRequest();
        HttpServletResponse response = ( HttpServletResponse ) context.getResponse();
        FlowController flowController = context.getFlowController();
        String methodName = exceptionConfig.getHandler();
        Object unwrappedFormBean = InternalUtils.unwrapFormBean( form );
        Method method = getExceptionHandlerMethod( context, methodName, ex, unwrappedFormBean );

        if ( method != null )
        {
            // First see if there's a hard-coded message set.
            String message = exceptionConfig.getDefaultMessage();
            ActionMessage error = null;
           
            if ( message != null )
            {
                error = new ExpressionMessage( message, new Object[]{ ex.getMessage() } );
               
                try
                {
                    // The message may be an expression.  Evaluate it.
                    message = InternalExpressionUtils.evaluateMessage( message, form, request, getServletContext() );
                }
                catch ( ELException e )
                {
                    _log.error( "error while evaluating expression in exception-handler for " + ex.getClass().getName(), e );
                }
            }


            if ( message == null )
            {
                // No hard-coded message.  Get the message based on the message key.
                String messageKey = exceptionConfig.getKey();
                       
                if ( messageKey != null && messageKey.length() > 0 )
                {
                    message = getMessage( context, messageKey, null, null );
                }
            }
           
            //
            // Expose the exception to the errors tag.
            //
            String msgKey = exceptionConfig.getKey();
            if ( error == null ) error = new ActionMessage( msgKey, ex.getMessage() );
            storeException( request, msgKey, error, exceptionConfig.getScope() );
           
            return flowController.invokeExceptionHandler( method, ex, message, unwrappedFormBean,
                                                          form, actionMapping, request, response,
                                                          exceptionConfig.isReadonly() );
        }
        else
        {
            //
            // This shouldn't happen except in out-of-date-class situations.  JpfChecker
            // should prevent this at compilation time.
            //
            String err;
            if ( form != null )
            {
                err= Bundle.getString( "PageFlow_MissingExceptionHandlerWithForm",
                                       new Object[]{ methodName, form.getClass().getName() } );
            }
            else
            {
                err = Bundle.getString( "PageFlow_MissingExceptionHandler", methodName );
            }
                   
            InternalUtils.sendError( "PageFlow_Custom_Error", null, request, response,
                                     new Object[]{ flowController.getDisplayName(), err } );
            return null;
        }       
    }
View Full Code Here

     *             if none matches.
     */
    protected Method getExceptionHandlerMethod( FlowControllerHandlerContext context, String methodName, Throwable ex,
                                                Object formBean )
    {
        FlowController flowController = context.getFlowController();
        String cacheKey = methodName + '/' + ex.getClass().getName();
        ClassLevelCache cache = ClassLevelCache.getCache( flowController.getClass() );
        Method method = ( Method ) cache.get( CACHEID_EXCEPTION_HANDLER_METHODS, cacheKey );
       
        if ( method != null )
        {
            return method;
        }
    
        Class flowControllerClass = flowController.getClass();
        for ( Class exClass = ex.getClass(); exClass != null; exClass = exClass.getSuperclass() )
        {
            Class[] args = new Class[]{ exClass, String.class, String.class, Object.class };
            Method foundMethod = InternalUtils.lookupMethod( flowControllerClass, methodName, args );
           
View Full Code Here

     * @return <code>true</code> if the action is defined in the current page flow
     *         or in a shared flow. Otherwise, return <code>false</code>.
     */
    public static boolean isAction(HttpServletRequest request, String action)
    {
        FlowController flowController = PageFlowUtils.getCurrentPageFlow(request);

        if (flowController != null) {
            if (action.endsWith(PageFlowConstants.ACTION_EXTENSION)) {
                action = action.substring(0, action.length() - PageFlowConstants.ACTION_EXTENSION.length());
            }

            if (getActionMapping(request, flowController, action) != null) return true;
            FlowController globalApp = PageFlowUtils.getSharedFlow(InternalConstants.GLOBALAPP_CLASSNAME, request);
            return getActionMapping(request, globalApp, action) != null;
        }

        return true;
    }
View Full Code Here

     * and checked (and removed) when processing an action with the <code>preventDoubleSubmit</code> attribute
     * set to <code>true</code>.
     */
    public static String getToken(HttpServletRequest request, String action)
    {
        FlowController flowController = PageFlowUtils.getCurrentPageFlow(request);

        if (flowController != null) {
            MappingAndController mac = getActionMapping(request, flowController, action);
            if (mac != null) return getToken(request, mac.mapping);
        }
View Full Code Here

    }

    public static MappingAndController getActionMapping(HttpServletRequest request, FlowController flowController, String action)
    {
        ActionConfig mapping = null;
        FlowController fc = null;

        if (flowController != null) {
            //
            // If there's a '.' delimiter, it's a shared flow action.
            //
            int dot = action.indexOf('.');

            if (dot == -1) {
                //
                // It's an action in the current page flow, or in the (deprecated) Global.app.
                //
                if (action.charAt(0) != '/') action = '/' + action;
                mapping = flowController.getModuleConfig().findActionConfig(action);
                fc = flowController;
               
                //
                // If we don't find it in the current page flow, look in Global.app.
                //
                if (mapping == null) {
                    FlowController globalApp =
                            PageFlowUtils.getSharedFlow(InternalConstants.GLOBALAPP_CLASSNAME, request);
                    if (globalApp != null) {
                        mapping = globalApp.getModuleConfig().findActionConfig(action);
                        fc = globalApp;
                    }
                }
            }
            else if (dot < action.length() - 1) {
                //
                // It's an action in a shared flow.
                //
                String sharedFlowName = action.substring(0, dot);
                if (sharedFlowName.length() > 0 && sharedFlowName.charAt(0) == '/') {
                    sharedFlowName = sharedFlowName.substring(1);
                }

                FlowController sharedFlow = (FlowController) PageFlowUtils.getSharedFlows(request).get(sharedFlowName);

                if (sharedFlow != null) {
                    String actionPath = '/' + action.substring(dot + 1);
                    mapping = sharedFlow.getModuleConfig().findActionConfig(actionPath);
                    fc = sharedFlow;
                }
            }
        }
View Full Code Here

        // check to see if this is a bad action
       
        PageFlowTagUtils.MappingAndController mac = PageFlowTagUtils.getActionMapping(request, _flowController, _state.action);
        if (mac == null) {
            FlowController globalApp = PageFlowUtils.getSharedFlow(InternalConstants.GLOBALAPP_CLASSNAME, request);
            mac = PageFlowTagUtils.getActionMapping(request, globalApp, _state.action);
        }
        if (mac == null) {
            registerTagError(Bundle.getString("Tags_BadAction", _state.action), null);
            return;
View Full Code Here

    public ActionForward handleException( FlowControllerHandlerContext context, Throwable ex,
                                          ActionMapping actionMapping, ActionForm form )
            throws IOException, ServletException
    {
        FlowController flowController = context.getFlowController();
        ServletRequest request = context.getRequest();
        ServletResponse response = context.getResponse();
       
        if ( _log.isInfoEnabled() )
        {
            _log.info( "Handling uncaught Throwable " + ex.getClass().getName() );
        }
       
        // Callback to the event reporter.
        _eventReporter.exceptionRaised( ex, actionMapping, form, flowController, request, response );
        long startTime = System.currentTimeMillis();
   
        //
        // Look up the ExceptionConfig that's associated with this Throwable.
        //
        Class exClass = ex.getClass();
        ExceptionConfig exceptionConfig = null;
        if ( actionMapping != null )
        {
            exceptionConfig = actionMapping.findException( exClass );
        }
        else
        {
            // If the mapping was null (i.e., the exception happened before we got the action mapping), look for the
            // exception only in the module config.
            exceptionConfig = getExceptionConfig( exClass, flowController.getModuleConfig() );
        }
       
        //
        // If there was no applicable exception handler in the current ModuleConfig, look in Global.app's module.
        //
        if ( exceptionConfig == null )
        {
            FlowController fallbackFC =
                    getFallbackFlowController( flowController, exClass, request, response, getServletContext() );
           
            if ( fallbackFC != null )
            {
                flowController = fallbackFC;
View Full Code Here

    {
        assert context.getRequest() instanceof HttpServletRequest : "don't support ServletRequest currently.";
        assert context.getResponse() instanceof HttpServletResponse : "don't support ServletResponse currently.";
        HttpServletRequest request = ( HttpServletRequest ) context.getRequest();
        HttpServletResponse response = ( HttpServletResponse ) context.getResponse();
        FlowController flowController = context.getFlowController();
        String methodName = exceptionConfig.getHandler();
        Object unwrappedFormBean = InternalUtils.unwrapFormBean( form );
        Method method = getExceptionHandlerMethod( context, methodName, ex, unwrappedFormBean );

        if ( method != null )
        {
            // First see if there's a hard-coded message set.
            String message = exceptionConfig.getDefaultMessage();
            ActionMessage error = null;
           
            if ( message != null )
            {
                error = new ExpressionMessage( message, new Object[]{ ex.getMessage() } );
               
                try
                {
                    // The message may be an expression.  Evaluate it.
                    message = InternalExpressionUtils.evaluateMessage( message, form, request, getServletContext() );
                }
                catch ( ELException e )
                {
                    _log.error( "error while evaluating expression in exception-handler for " + ex.getClass().getName(), e );
                }
            }


            if ( message == null )
            {
                // No hard-coded message.  Get the message based on the message key.
                String messageKey = exceptionConfig.getKey();
                       
                if ( messageKey != null && messageKey.length() > 0 )
                {
                    message = getMessage( context, messageKey, null, null );
                }
            }
           
            //
            // Expose the exception to the errors tag.
            //
            String msgKey = exceptionConfig.getKey();
            if ( error == null ) error = new ActionMessage( msgKey, ex.getMessage() );
            storeException( request, msgKey, error, exceptionConfig.getScope() );
           
            return flowController.invokeExceptionHandler( method, ex, message, unwrappedFormBean,
                                                          form, actionMapping, request, response,
                                                          exceptionConfig.isReadonly() );
        }
        else
        {
            //
            // This shouldn't happen except in out-of-date-class situations.  JpfChecker
            // should prevent this at compilation time.
            //
            String err;
            if ( form != null )
            {
                err= Bundle.getString( "PageFlow_MissingExceptionHandlerWithForm",
                                       new Object[]{ methodName, form.getClass().getName() } );
            }
            else
            {
                err = Bundle.getString( "PageFlow_MissingExceptionHandler", methodName );
            }
                   
            InternalUtils.sendError( "PageFlow_Custom_Error", null, request, response,
                                     new Object[]{ flowController.getDisplayName(), err } );
            return null;
        }       
    }
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.pageflow.FlowController

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.