You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beehive.apache.org by Eddie O'Neil <ek...@gmail.com> on 2005/09/19 16:35:05 UTC
Re: svn commit: r290172 - in /beehive/trunk/netui: src/pageflow/org/apache/beehive/netui/pageflow/internal/ src/util/org/apache/beehive/netui/util/config/bean/ src/util/org/apache/beehive/netui/util/config/parser/ test/webapps/jsf/ test/webapps/urlTe
Forgot attributions on these; apologies.
BEEHIVE-938 patch from Krista Baker
BEEHIVE-937 patch from Carlin Rogers
Thanks for the help...
On 9/19/05, ekoneil@apache.org <ek...@apache.org> wrote:
> Author: ekoneil
> Date: Mon Sep 19 07:32:36 2005
> New Revision: 290172
>
> URL: http://svn.apache.org/viewcvs?rev=290172&view=rev
> Log:
> Two more NetUI bug fixes and changes to the urlTemplate and jsfWeb webapp builds to start copying XMLBeans.
>
> BEEHIVE-938 PageFlowConfig from beehive-netui-config, max-nesting-stack-depth is set incorrectly
> BEEHIVE-937 Add validation to the beehive-url-template-config.xml file processing
>
> BB: self
> Test: NetUI DRT / urlTemplates / jsfWeb pass
>
>
> Modified:
> beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLTemplatesFactory.java
> beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/PageFlowConfig.java
> beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java
> beehive/trunk/netui/test/webapps/jsf/build.xml
> beehive/trunk/netui/test/webapps/urlTemplates/build.xml
>
> Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLTemplatesFactory.java
> URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLTemplatesFactory.java?rev=290172&r1=290171&r2=290172&view=diff
> ==============================================================================
> --- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLTemplatesFactory.java (original)
> +++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultURLTemplatesFactory.java Mon Sep 19 07:32:36 2005
> @@ -20,9 +20,12 @@
> import org.apache.beehive.netui.core.urltemplates.URLTemplate;
> import org.apache.beehive.netui.core.urltemplates.URLTemplates;
> import org.apache.beehive.netui.core.urltemplates.URLTemplatesFactory;
> -import org.apache.beehive.netui.util.internal.InternalStringBuilder;
> import org.apache.beehive.netui.util.logging.Logger;
> import org.apache.beehive.netui.util.xml.DomUtils;
> +import org.apache.beehive.netui.util.xml.XmlInputStreamResolver;
> +import org.apache.beehive.netui.util.xml.validation.SchemaValidationException;
> +import org.apache.beehive.netui.util.xml.validation.SchemaValidator;
> +import org.apache.beehive.netui.util.xml.validation.SchemaValidatorFactory;
>
> import java.io.InputStream;
> import java.io.IOException;
> @@ -31,6 +34,8 @@
> import javax.servlet.ServletContext;
> import javax.xml.parsers.DocumentBuilder;
> import javax.xml.parsers.DocumentBuilderFactory;
> +import javax.xml.parsers.ParserConfigurationException;
> +
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.xml.sax.SAXException;
> @@ -51,6 +56,18 @@
> private static final String URL_TEMPLATE_REF_GROUP = "url-template-ref-group";
> private static final String VALUE = "value";
>
> + private static final String CONFIG_SCHEMA = "org/apache/beehive/netui/core/urltemplates/schema/url-template-config.xsd";
> +
> + private static final XmlInputStreamResolver SCHEMA_RESOLVER = new XmlInputStreamResolver() {
> + public String getResourcePath() {
> + return CONFIG_SCHEMA;
> + }
> +
> + public InputStream getInputStream() {
> + return DefaultURLTemplatesFactory.class.getClassLoader().getResourceAsStream(getResourcePath());
> + }
> + };
> +
> // The actual URL templates and template ref groups
> private URLTemplates _urlTemplates;
>
> @@ -114,19 +131,35 @@
> public void load( ServletContext servletContext )
> {
> _urlTemplates = new URLTemplates();
> - InputStream stream = null;
> + InputStream xmlInputStream = null;
> + InputStream xsdInputStream = null;
>
> try
> {
> - stream = servletContext.getResourceAsStream( _configFilePath );
> - if ( stream != null )
> + xmlInputStream = servletContext.getResourceAsStream( _configFilePath );
> + if ( xmlInputStream != null )
> {
> + // Validate the XML against the schema
> + xsdInputStream = SCHEMA_RESOLVER.getInputStream();
> + SchemaValidator schemaValidator = SchemaValidatorFactory.getInstance();
> + schemaValidator.validate(xsdInputStream, xmlInputStream);
> + try
> + {
> + if ( xmlInputStream != null )
> + xmlInputStream.close();
> + }
> + catch ( IOException io )
> + {
> + _log.error( "An exception occurred closing the input stream for \"" + _configFilePath + "\"", io );
> + }
> +
> + // Parse, then load the templates and template ref groups
> + xmlInputStream = servletContext.getResourceAsStream( _configFilePath );
> +
> DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
> DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
> - Document document = dBuilder.parse( stream );
> + Document document = dBuilder.parse( xmlInputStream );
> Element root = document.getDocumentElement();
> -
> - // Load the templates and template ref groups
> loadTemplates( root );
> loadTemplateRefGroups( root );
> }
> @@ -134,19 +167,18 @@
> {
> if ( _log.isInfoEnabled() )
> {
> - String contextName = servletContext.getServletContextName();
> - InternalStringBuilder message = new InternalStringBuilder();
> - if ( contextName != null )
> - {
> - message.append( contextName ).append( " - " );
> - }
> -
> - message.append( "Running without URL template descriptor, " );
> - message.append( _configFilePath );
> - _log.info( message.toString() );
> + _log.info( "Running without URL template descriptor, " + _configFilePath );
> }
> }
> }
> + catch ( SchemaValidationException sve )
> + {
> + _log.error("Validation errors occurred parsing the config file \"" + _configFilePath + "\". Cause: " + sve, sve);
> + }
> + catch ( ParserConfigurationException pce )
> + {
> + _log.error( "Problem loading URL template descriptor file " + _configFilePath, pce );
> + }
> catch ( SAXException se )
> {
> _log.error( "Problem parsing URL template descriptor in " + _configFilePath, se );
> @@ -155,23 +187,11 @@
> {
> _log.error( "Problem reading URL template descriptor file " + _configFilePath, ioe );
> }
> - catch ( Exception e )
> - {
> - _log.error( "Problem loading URL template descriptor file " + _configFilePath, e );
> - }
> finally
> {
> - // Close the stream
> - if ( stream != null )
> - {
> - try
> - {
> - stream.close();
> - }
> - catch ( Exception ignore )
> - {
> - }
> - }
> + // Close the streams
> + try { if ( xmlInputStream != null ) xmlInputStream.close(); } catch ( Exception ignore ) {}
> + try { if ( xsdInputStream != null ) xsdInputStream.close(); } catch( IOException ignore ) {}
> }
> }
>
>
> Modified: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/PageFlowConfig.java
> URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/PageFlowConfig.java?rev=290172&r1=290171&r2=290172&view=diff
> ==============================================================================
> --- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/PageFlowConfig.java (original)
> +++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/bean/PageFlowConfig.java Mon Sep 19 07:32:36 2005
> @@ -70,7 +70,7 @@
> if(maxForwardsPerRequest != null)
> _maxForwardsPerRequest = maxForwardsPerRequest.intValue();
> if(maxNestingStackDepth != null)
> - _maxForwardsPerRequest = maxNestingStackDepth.intValue();
> + _maxNestingStackDepth = maxNestingStackDepth.intValue();
> if(multipartHandler != null)
> _multipartHandler = multipartHandler;
> if(preventCache != null)
>
> Modified: beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java
> URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java?rev=290172&r1=290171&r2=290172&view=diff
> ==============================================================================
> --- beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java (original)
> +++ beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/parser/NetUIConfigParser.java Mon Sep 19 07:32:36 2005
> @@ -138,10 +138,12 @@
> xmlInputStream.close();
> }
> catch(IOException io) {
> - throw new ConfigInitializationException("An exception occurred closing the input stream for \"" + theXmlResolver.getResourcePath());
> + throw new ConfigInitializationException("An exception occurred closing the input stream for \"" +
> + theXmlResolver.getResourcePath() + "\"");
> }
>
> - configBean = parse(theXmlResolver.getResourcePath(), theXmlResolver.getInputStream());
> + xmlInputStream = theXmlResolver.getInputStream();
> + configBean = parse(theXmlResolver.getResourcePath(), xmlInputStream);
> }
> finally {
> try {if(xmlInputStream != null) xmlInputStream.close();} catch(IOException ignore) {}
>
> Modified: beehive/trunk/netui/test/webapps/jsf/build.xml
> URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/webapps/jsf/build.xml?rev=290172&r1=290171&r2=290172&view=diff
> ==============================================================================
> --- beehive/trunk/netui/test/webapps/jsf/build.xml (original)
> +++ beehive/trunk/netui/test/webapps/jsf/build.xml Mon Sep 19 07:32:36 2005
> @@ -38,6 +38,12 @@
> tofile="${webapp.dir}/WEB-INF/web.xml"
> overwrite="true" failonerror="true"/>
>
> + <!-- deploy XMLBeans which isn't included in the default webapp template -->
> + <copy todir="${webapp.dir}/WEB-INF/lib">
> + <fileset refid="xbean.fileset"/>
> + <fileset refid="jsr173.fileset"/>
> + </copy>
> +
> <build-webapp webappDir="${webapp.dir}"/>
>
> <!-- Touch all JSPs to ensure that they're compiled. When switching between MyFaces and the JSF RI,
> @@ -120,7 +126,9 @@
> </ant>
> </target>
>
> - <target name="bvt.jsf-ri" description="Run the bvt suite against the JSF Reference Implementation with full server start / stop support." depends="clean,build.jsf-ri">
> + <target name="bvt.jsf-ri"
> + description="Run the bvt suite against the JSF Reference Implementation with full server start / stop support."
> + depends="clean,build.jsf-ri">
> <ant antfile="${test.dir}/ant/testRecorder.xml" inheritAll="false" target="server.test">
> <property name="app.build.file" location="${app.dir}/jsf/build.xml"/>
> <property name="suite.name" value="bvt"/>
> @@ -133,7 +141,9 @@
> </ant>
> </target>
>
> - <target name="bvt.myfaces" description="Run the bvt suite against the MyFaces with full server start / stop support." depends="clean,build.myfaces">
> + <target name="bvt.myfaces"
> + description="Run the bvt suite against the MyFaces with full server start / stop support."
> + depends="clean,build.myfaces">
> <ant antfile="${test.dir}/ant/testRecorder.xml" inheritAll="false" target="server.test">
> <property name="app.build.file" location="${app.dir}/jsf/build.xml"/>
> <property name="suite.name" value="bvt"/>
> @@ -144,6 +154,10 @@
> <property name="formatter.type" value="xml"/>
> <property name="formatter.usefile" value="true"/>
> </ant>
> + </target>
> +
> + <target name="bvt" description="Default JSF + NetUI test webapp">
> + <antcall target="bvt.myfaces"/>
> </target>
>
> <target name="ensure.deployed" description="Deploy webapp">
>
> Modified: beehive/trunk/netui/test/webapps/urlTemplates/build.xml
> URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/webapps/urlTemplates/build.xml?rev=290172&r1=290171&r2=290172&view=diff
> ==============================================================================
> --- beehive/trunk/netui/test/webapps/urlTemplates/build.xml (original)
> +++ beehive/trunk/netui/test/webapps/urlTemplates/build.xml Mon Sep 19 07:32:36 2005
> @@ -52,6 +52,12 @@
> <property name="webapp.file" location="${app.dir}/urlTemplates/testRecorder/config/testRecorder-webapp.xml"/>
> <property name="struts.version" value="${struts.version}"/>
> </ant>
> +
> + <!-- deploy XMLBeans which isn't included in the default webapp template -->
> + <copy todir="${webapp.dir}/WEB-INF/lib">
> + <fileset refid="xbean.fileset"/>
> + <fileset refid="jsr173.fileset"/>
> + </copy>
> </target>
>
> <target name="clean" description="Clean webapp">
>
>
>