Author: ekoneil Date: Wed Dec 29 11:36:07 2004 New Revision: 123670 URL: http://svn.apache.org/viewcvs?view=rev&rev=123670 Log: Fix a bug in ImplicitObjectUtil that surfaces in webapps that don't have any Global.app or SharedFlow.jpfs files.
There was a null check and exception being thrown when neither of these source artifacts appeared, and this isn't an error condition. BB: self DRT: NetUI pass BVT: NetUI pass (11 failures) Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java?view=diff&rev=123670&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java&r1=123669&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java&r2=123670 ============================================================================== --- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java (original) +++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/script/common/ImplicitObjectUtil.java Wed Dec 29 11:36:07 2004 @@ -30,7 +30,11 @@ import javax.servlet.jsp.PageContext; import javax.servlet.jsp.el.VariableResolver; -import org.apache.beehive.netui.pageflow.*; +import org.apache.beehive.netui.pageflow.FacesBackingBean; +import org.apache.beehive.netui.pageflow.GlobalApp; +import org.apache.beehive.netui.pageflow.PageFlowController; +import org.apache.beehive.netui.pageflow.PageFlowUtils; +import org.apache.beehive.netui.pageflow.SharedFlowController; import org.apache.beehive.netui.pageflow.internal.AnyBeanActionForm; import org.apache.beehive.netui.pageflow.internal.InternalUtils; import org.apache.beehive.netui.pageflow.internal.FacesBackingBeanFactory; @@ -42,15 +46,12 @@ import org.apache.beehive.netui.util.logging.Logger; import org.apache.beehive.netui.script.el.NetUIUpdateVariableResolver; -import org.apache.struts.action.ActionForm; - /** * */ public class ImplicitObjectUtil { - private static final Logger _logger = Logger.getInstance(ImplicitObjectUtil.class); - + private static final Logger LOGGER = Logger.getInstance(ImplicitObjectUtil.class); private static final String PAGE_FLOW_IMPLICIT_OBJECT_KEY = "pageFlow"; private static final String SHARED_FLOW_IMPLICIT_OBJECT_KEY = "sharedFlow"; private static final String GLOBAL_APP_IMPLICIT_OBJECT_KEY = "globalApp"; @@ -103,8 +104,8 @@ public static final Object unwrapForm(Object form) { - if(_logger.isDebugEnabled() && form instanceof AnyBeanActionForm) - _logger.debug("using form of type: " + ((AnyBeanActionForm)form != null ? ((AnyBeanActionForm)form).getClass().getName() : "null")); + if(LOGGER.isDebugEnabled() && form instanceof AnyBeanActionForm) + LOGGER.debug("using form of type: " + ((AnyBeanActionForm)form != null ? ((AnyBeanActionForm)form).getClass().getName() : "null")); if(form instanceof AnyBeanActionForm) return ((AnyBeanActionForm)form).getBean(); @@ -113,19 +114,7 @@ public static final Map<String, SharedFlowController> getSharedFlow(ServletRequest request) { - assert request instanceof HttpServletRequest; - - Map<String, SharedFlowController> sharedFlows = (Map<String, SharedFlowController>) request.getAttribute(SHARED_FLOW_IMPLICIT_OBJECT_KEY); - if(sharedFlows == null) - { - // @todo: i18n - RuntimeException re = new RuntimeException("Can not create the sharedFlow binding context; the SharedFlow map is null."); - if(_logger.isErrorEnabled()) - _logger.error("", re); - - throw re; - } - else return sharedFlows; + return (Map<String, SharedFlowController>)request.getAttribute(SHARED_FLOW_IMPLICIT_OBJECT_KEY); } public static final PageFlowController getPageFlow(ServletRequest request, ServletResponse response) @@ -135,11 +124,11 @@ PageFlowController jpf = PageFlowUtils.getCurrentPageFlow((HttpServletRequest)request); if(jpf != null) return jpf; - else + else { // @todo: i18n RuntimeException re = new RuntimeException("There is no current PageFlow for the expression."); - if(_logger.isErrorEnabled()) _logger.error("", re); + if(LOGGER.isErrorEnabled()) LOGGER.error("", re); throw re; } } @@ -149,15 +138,15 @@ assert request instanceof HttpServletRequest; GlobalApp ga = PageFlowUtils.getGlobalApp((HttpServletRequest)request); - - if(ga == null) + + if(ga == null) { // @todo: i18n RuntimeException re = new RuntimeException("Can not create the globalApp binding context; the GlobalApp object is null."); - if(_logger.isErrorEnabled()) _logger.error("", re); + if(LOGGER.isErrorEnabled()) LOGGER.error("", re); throw re; } - + return ga; } @@ -176,7 +165,7 @@ { // @todo: i18n String msg = "Could not resolve ContextFactory for binding context named \"" + name + "\""; - if(_logger.isErrorEnabled()) _logger.error(msg); + if(LOGGER.isErrorEnabled()) LOGGER.error(msg); throw new RuntimeException(msg); } @@ -247,29 +236,29 @@ } catch(ClassNotFoundException cnf) { - if(_logger.isWarnEnabled()) - _logger.warn("Could not create a ContextFactory for type \"" + className + "\" because the ContextFactory implementation class could not be found."); + if(LOGGER.isWarnEnabled()) + LOGGER.warn("Could not create a ContextFactory for type \"" + className + "\" because the ContextFactory implementation class could not be found."); continue; } catch(Exception ex) { - if(_logger.isWarnEnabled()) - _logger.warn("Could not create a ContextFactory for type \"" + className + + if(LOGGER.isWarnEnabled()) + LOGGER.warn("Could not create a ContextFactory for type \"" + className + "\" because an error occurred creating the factory. Cause: " + ex, ex); continue; } if(map.containsKey(name)) { - if(_logger.isWarnEnabled()) - _logger.warn("Overwriting a previously defined ContextFactory named \"" + name + + if(LOGGER.isWarnEnabled()) + LOGGER.warn("Overwriting a previously defined ContextFactory named \"" + name + "\" with a new ContextFactory of type \"" + className + "\""); } else { - if(_logger.isInfoEnabled()) - _logger.info("Adding a ContextFactory named \"" + name + "\" with implementation \"" + className + "\""); + if(LOGGER.isInfoEnabled()) + LOGGER.info("Adding a ContextFactory named \"" + name + "\" with implementation \"" + className + "\""); } map.put(name, factory);
