djencks 2004/02/08 23:10:25
Modified: modules/connector/src/java/org/apache/geronimo/connector/deployment AbstractConnectorModule.java Connector_1_0Module.java Connector_1_5Module.java modules/deployment/src/java/org/apache/geronimo/deployment/plugin DeploymentManagerImpl.java Log: add xmlbeans validation Revision Changes Path 1.3 +2 -2 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/AbstractConnectorModule.java Index: AbstractConnectorModule.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/AbstractConnectorModule.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AbstractConnectorModule.java 6 Feb 2004 08:56:42 -0000 1.2 +++ AbstractConnectorModule.java 9 Feb 2004 07:10:25 -0000 1.3 @@ -124,7 +124,7 @@ } } - protected abstract void getConnectorDocument(JarInputStream jarInputStream) throws XmlException, IOException; + protected abstract void getConnectorDocument(JarInputStream jarInputStream) throws XmlException, IOException, DeploymentException; public void complete() { } 1.5 +14 -2 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/Connector_1_0Module.java Index: Connector_1_0Module.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/Connector_1_0Module.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Connector_1_0Module.java 8 Feb 2004 20:21:57 -0000 1.4 +++ Connector_1_0Module.java 9 Feb 2004 07:10:25 -0000 1.5 @@ -61,6 +61,8 @@ import java.io.InputStream; import java.net.URI; import java.util.Collections; +import java.util.Collection; +import java.util.ArrayList; import java.util.jar.JarInputStream; import javax.management.AttributeNotFoundException; @@ -69,6 +71,7 @@ import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.management.ReflectionException; +import javax.enterprise.deploy.shared.CommandType; import org.apache.geronimo.common.propertyeditor.PropertyEditors; import org.apache.geronimo.connector.outbound.ConnectionManagerDeployment; @@ -76,6 +79,7 @@ import org.apache.geronimo.deployment.ConfigurationCallback; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.deployment.DeploymentModule; +import org.apache.geronimo.deployment.plugin.FailedProgressObject; import org.apache.geronimo.deployment.util.UnclosableInputStream; import org.apache.geronimo.gbean.DynamicGAttributeInfo; import org.apache.geronimo.gbean.GBeanInfo; @@ -93,6 +97,7 @@ import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConnectorDocument; import org.apache.geronimo.xbeans.j2ee.connector_1_0.ResourceadapterType; import org.apache.xmlbeans.XmlException; +import org.apache.xmlbeans.XmlOptions; /** * @@ -109,8 +114,15 @@ } - protected void getConnectorDocument(JarInputStream jarInputStream) throws XmlException, IOException { + protected void getConnectorDocument(JarInputStream jarInputStream) throws XmlException, IOException, DeploymentException { connectorDocument = ConnectorDocument.Factory.parse(new UnclosableInputStream(jarInputStream)); + XmlOptions xmlOptions = new XmlOptions(); + xmlOptions.setLoadLineNumbers(); + Collection errors = new ArrayList(); + xmlOptions.setErrorListener(errors); + if (!connectorDocument.validate(xmlOptions)) { + throw new DeploymentException("Invalid deployment descriptor: errors: " + errors); + } } public void defineGBeans(ConfigurationCallback callback, ClassLoader cl) throws DeploymentException { 1.5 +12 -2 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/Connector_1_5Module.java Index: Connector_1_5Module.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/Connector_1_5Module.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Connector_1_5Module.java 8 Feb 2004 20:21:57 -0000 1.4 +++ Connector_1_5Module.java 9 Feb 2004 07:10:25 -0000 1.5 @@ -63,6 +63,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Collection; +import java.util.ArrayList; import java.util.jar.JarInputStream; import javax.management.AttributeNotFoundException; @@ -100,6 +102,7 @@ import org.apache.geronimo.xbeans.j2ee.ConnectorDocument; import org.apache.geronimo.xbeans.j2ee.ResourceadapterType; import org.apache.xmlbeans.XmlException; +import org.apache.xmlbeans.XmlOptions; /** * @@ -116,8 +119,15 @@ } - protected void getConnectorDocument(JarInputStream jarInputStream) throws XmlException, IOException { + protected void getConnectorDocument(JarInputStream jarInputStream) throws XmlException, IOException, DeploymentException { connectorDocument = ConnectorDocument.Factory.parse(new UnclosableInputStream(jarInputStream)); + XmlOptions xmlOptions = new XmlOptions(); + xmlOptions.setLoadLineNumbers(); + Collection errors = new ArrayList(); + xmlOptions.setErrorListener(errors); + if (!connectorDocument.validate(xmlOptions)) { + throw new DeploymentException("Invalid deployment descriptor: errors: " + errors); + } } public void defineGBeans(ConfigurationCallback callback, ClassLoader cl) throws DeploymentException { 1.10 +11 -1 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/DeploymentManagerImpl.java Index: DeploymentManagerImpl.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/DeploymentManagerImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- DeploymentManagerImpl.java 9 Feb 2004 00:01:19 -0000 1.9 +++ DeploymentManagerImpl.java 9 Feb 2004 07:10:25 -0000 1.10 @@ -68,6 +68,7 @@ import java.util.Locale; import java.util.Map; import java.util.Collection; +import java.util.ArrayList; import javax.enterprise.deploy.model.DeployableObject; import javax.enterprise.deploy.shared.CommandType; @@ -98,6 +99,7 @@ import org.apache.xmlbeans.SchemaTypeLoader; import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlObject; +import org.apache.xmlbeans.XmlOptions; import org.w3c.dom.Document; /** @@ -241,6 +243,14 @@ URI configId; try { plan = schemaTypeLoader.parse(deploymentPlan, null, null); + //validate + XmlOptions xmlOptions = new XmlOptions(); + xmlOptions.setLoadLineNumbers(); + Collection errors = new ArrayList(); + xmlOptions.setErrorListener(errors); + if (!plan.validate(xmlOptions)) { + return new FailedProgressObject(CommandType.DISTRIBUTE, "Invalid deployment plan: errors: " + errors); + } configId = getConfigID(null); } catch (org.apache.xmlbeans.XmlException e) { return new FailedProgressObject(CommandType.DISTRIBUTE, "Could not parse deployment plan");