You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2015/06/09 18:04:36 UTC
[1/3] ode git commit: fixes ODE-1019.
Repository: ode
Updated Branches:
refs/heads/master 1f3f429a8 -> 7812077ce
refs/heads/ode-1.3.x eb46426e7 -> f82281446
fixes ODE-1019.
Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/7812077c
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/7812077c
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/7812077c
Branch: refs/heads/master
Commit: 7812077ce9df8a0e440d203de30282d415169cb3
Parents: 1f3f429
Author: Tammo van Lessen <tv...@gmail.com>
Authored: Tue Jun 9 15:36:47 2015 +0200
Committer: Tammo van Lessen <tv...@gmail.com>
Committed: Tue Jun 9 15:36:47 2015 +0200
----------------------------------------------------------------------
.../java/org/apache/ode/utils/xsd/XSUtils.java | 58 +++++++++++--
.../org/apache/ode/utils/xsd/XsdException.java | 5 ++
.../org/apache/ode/utils/xsd/XsdMessages.java | 4 +
.../apache/ode/utils/xsd/SchemaCaptureTest.java | 86 +++++++++++++-------
4 files changed, 115 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ode/blob/7812077c/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java b/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
index 841bf00..0c2cc26 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
@@ -18,25 +18,28 @@
*/
package org.apache.ode.utils.xsd;
+import java.io.ByteArrayInputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.utils.msg.MessageBundle;
import org.apache.xerces.dom.DOMInputImpl;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.xs.XMLSchemaLoader;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLErrorHandler;
import org.apache.xerces.xni.parser.XMLParseException;
import org.apache.xerces.xs.XSModel;
+import org.w3c.dom.DOMError;
+import org.w3c.dom.DOMErrorHandler;
import org.w3c.dom.ls.LSInput;
-import java.io.ByteArrayInputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* Various utility methods related to XML Schema processing.
@@ -93,6 +96,9 @@ public class XSUtils {
LoggingXmlErrorHandler eh = new LoggingXmlErrorHandler(__log);
schemaLoader.setErrorHandler(eh);
+ LoggingDOMErrorHandler deh = new LoggingDOMErrorHandler(__log);
+ schemaLoader.setParameter(Constants.DOM_ERROR_HANDLER, deh);
+
XSModel model = schemaLoader.load(input);
// The following mess is due to XMLSchemaLoaders funkyness in error
@@ -103,15 +109,26 @@ public class XSUtils {
* Someone inside Xerces will have eaten this exception, for no good
* reason.
*/
+ XsdException ex = null;
+
List<XMLParseException> errors = eh.getErrors();
if (errors.size() != 0) {
__log.error("captureSchema: XMLParseException(s) in " + input);
- XsdException ex = null;
for (XMLParseException xpe : errors) {
ex = new XsdException(ex, xpe.getMessage(), xpe.getLineNumber(), xpe.getColumnNumber(),
xpe.getLiteralSystemId());
}
+ }
+
+ List<Exception> exceptions = deh.getExceptions();
+ if (exceptions.size() != 0) {
+ for (Exception e : exceptions) {
+ ex = new XsdException(ex, e.getMessage());
+ }
+ }
+
+ if (ex != null) {
throw ex;
}
@@ -188,4 +205,29 @@ public class XSUtils {
throw new XNIException("Unknown XSD error state; domain=" + domain + ", key=" +key);
}
}
+
+ static class LoggingDOMErrorHandler implements DOMErrorHandler {
+
+ private ArrayList<Exception> _exceptions = new ArrayList<Exception>();
+ private Log _log;
+
+ public LoggingDOMErrorHandler(Log log) {
+ assert log != null;
+ _log = log;
+ }
+
+ public boolean handleError(DOMError error) {
+ if (_log.isDebugEnabled()) {
+ _log.debug("Exception occurred during parsing schema: " + error.getMessage());
+ }
+ if (error != null) {
+ _exceptions.add((Exception) error.getRelatedException());
+ }
+ return false;
+ }
+
+ public ArrayList<Exception> getExceptions() {
+ return _exceptions;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ode/blob/7812077c/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java b/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java
index ad7e16b..e82cab3 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java
@@ -58,6 +58,11 @@ public class XsdException extends Exception {
_systemId = literalSystemId;
_previous = previous;
}
+
+ public XsdException(XsdException previous, String message) {
+ super(__msgs.msgXsdExceptionMessage(message));
+ _message = message;
+ }
public String getDetailMessage() {
return _message;
http://git-wip-us.apache.org/repos/asf/ode/blob/7812077c/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java b/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java
index f91a396..a3051ac 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java
@@ -100,6 +100,10 @@ public class XsdMessages extends MessageBundle {
systemId, lineNumber, columnNumber);
}
+ public String msgXsdExceptionMessage(String message) {
+ return this.format("Unable to process XML Schema: {0}", message);
+ }
+
/** An unknown error occured processing schema at {0}" */
public String msgXsdUnknownError(String systemId) {
return this.format("An unknown error occured processing schema at {0}", systemId);
http://git-wip-us.apache.org/repos/asf/ode/blob/7812077c/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
----------------------------------------------------------------------
diff --git a/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java b/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
index c0ff13d..aa09424 100644
--- a/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
+++ b/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
@@ -18,14 +18,7 @@
*/
package org.apache.ode.utils.xsd;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.utils.StreamUtils;
-import org.apache.ode.utils.TestResources;
-import org.apache.xerces.xni.XMLResourceIdentifier;
-import org.apache.xerces.xni.XNIException;
-import org.apache.xerces.xni.parser.XMLEntityResolver;
-import org.apache.xerces.xni.parser.XMLInputSource;
+import static org.junit.Assert.*;
import java.io.FileInputStream;
import java.io.IOException;
@@ -35,37 +28,70 @@ import java.util.Map;
import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.utils.StreamUtils;
+import org.apache.ode.utils.TestResources;
+import org.apache.xerces.xni.XMLResourceIdentifier;
+import org.apache.xerces.xni.XNIException;
+import org.apache.xerces.xni.parser.XMLEntityResolver;
+import org.apache.xerces.xni.parser.XMLInputSource;
+import org.junit.Test;
+
/**
* Test schema capture functionality.
*/
-public class SchemaCaptureTest extends TestCase {
+public class SchemaCaptureTest {
private static Log __log = LogFactory.getLog(SchemaCaptureTest.class);
- public void testSchemaCapture() throws Exception {
- __log.debug("GETTING RESOURCE " + TestResources.getRetailerSchema());
- InputStream xsdStream = TestResources.getRetailerSchema().openStream();
- byte[] data;
- try {
- data = StreamUtils.read(xsdStream);
- } finally {
- xsdStream.close();
- }
+ @Test
+ public void testSchemaCapture() throws Exception {
+ __log.debug("GETTING RESOURCE " + TestResources.getRetailerSchema());
+ InputStream xsdStream = TestResources.getRetailerSchema().openStream();
+ byte[] data;
+ try {
+ data = StreamUtils.read(xsdStream);
+ } finally {
+ xsdStream.close();
+ }
+
+ Map<URI, byte[]> s = XSUtils.captureSchema(URI.create("schema.xsd"), data, new XMLEntityResolver() {
+ public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
+ XMLInputSource src = new XMLInputSource(resourceIdentifier);
+ String literalUri = resourceIdentifier.getLiteralSystemId();
- Map<URI, byte[]> s = XSUtils.captureSchema(URI.create("schema.xsd"), data, new XMLEntityResolver() {
- public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
- XMLInputSource src = new XMLInputSource(resourceIdentifier);
- String literalUri = resourceIdentifier.getLiteralSystemId();
+ if (literalUri != null) {
+ src.setByteStream(getClass().getClassLoader().getResourceAsStream(literalUri));
+ }
- if (literalUri != null) {
- src.setByteStream(getClass().getClassLoader().getResourceAsStream(literalUri));
+ return src;
}
+ }, 0);
+ // we expect the root schema and three includes
+ __log.debug("loaded " + s.keySet());
+ assertEquals(5, s.size());
+ }
- return src;
+ /**
+ * Test for ODE-1019, provided by Igor Vorobiov
+ */
+ @Test(expected = Exception.class)
+ public void testSchemaCaptureException() throws Exception {
+ InputStream xsdStream = new FileInputStream(TestResources.getRetailerSchema().getFile());
+ byte[] data;
+ try {
+ data = StreamUtils.read(xsdStream);
+ } finally {
+ xsdStream.close();
}
- }, 0);
- // we expect the root schema and three includes
- __log.debug("loaded " + s.keySet());
- assertEquals(5, s.size());
- }
+ XSUtils.captureSchema(URI.create("schema.xsd"), data, new XMLEntityResolver() {
+ public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
+ // !!! cause NullPointerException
+ return null;
+ }
+ }, 0);
+
+ __log.error("mustn't reach this place");
+ }
}
[2/3] ode git commit: Undefined XSD element (test + fix)
Posted by va...@apache.org.
Undefined XSD element (test + fix)
Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/274a89c0
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/274a89c0
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/274a89c0
Branch: refs/heads/ode-1.3.x
Commit: 274a89c0c388fe9255c84312191a4d6848f45591
Parents: eb46426
Author: Rafal Konrad Rusin <rr...@apache.org>
Authored: Thu Jul 22 07:22:14 2010 +0000
Committer: Tammo van Lessen <tv...@gmail.com>
Committed: Tue Jun 9 17:56:04 2015 +0200
----------------------------------------------------------------------
Rakefile | 1 +
.../apache/ode/bpel/compiler/BpelCompiler.java | 2 +-
.../apache/ode/bpel/compiler/WSDLRegistry.java | 11 ++++-
.../ode/bpel/compiler_2_0/GoodCompileTest.java | 4 +-
.../bpel/compiler/MultipleEmbeddedSchemas.bpel | 33 +++++++++++++
.../bpel/compiler/MultipleEmbeddedSchemas.wsdl | 49 ++++++++++++++++++++
.../apache/ode/utils/xsd/SchemaModelImpl.java | 2 +
.../java/org/apache/ode/utils/xsd/XSUtils.java | 6 ++-
.../apache/ode/utils/xsd/SchemaCaptureTest.java | 2 +-
9 files changed, 102 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/Rakefile
----------------------------------------------------------------------
diff --git a/Rakefile b/Rakefile
index 7996ef0..3736586 100644
--- a/Rakefile
+++ b/Rakefile
@@ -180,6 +180,7 @@ define "ode" do
compile.with projects("bpel-api", "bpel-obj", "bpel-schemas", "utils"),
COMMONS.logging, JAVAX.stream, JAXEN, SAXON, WSDL4J, XALAN, XERCES, COMMONS.collections
test.resources { filter(project("bpel-scripts").path_to("src/main/resources")).into(test.resources.target).run }
+ test.with LOG4J
package :jar
test.with SLF4J, LOG4J
end
http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
----------------------------------------------------------------------
diff --git a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
index bf42c2e..e8b20bb 100644
--- a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
+++ b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
@@ -226,7 +226,7 @@ public abstract class BpelCompiler implements CompilerContext {
xsdStream.close();
}
- Map<URI, byte[]> schemas = XSUtils.captureSchema(resFrom, data, resolver);
+ Map<URI, byte[]> schemas = XSUtils.captureSchema(resFrom, data, resolver, 0);
_wsdlRegistry.addSchemas(schemas);
} catch (XsdException e) {
CompilationException ce = new CompilationException(__cmsgs.errInvalidImport(location.toString()));
http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
----------------------------------------------------------------------
diff --git a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
index b7e9077..319666d 100644
--- a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
+++ b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
@@ -213,6 +213,7 @@ class WSDLRegistry {
Types types = def.getTypes();
if (types != null) {
+ int localSchemaId = 0;
for (Iterator<ExtensibilityElement> iter =
((List<ExtensibilityElement>)def.getTypes().getExtensibilityElements()).iterator();
iter.hasNext();) {
@@ -222,8 +223,13 @@ class WSDLRegistry {
byte[] schema = ((XMLSchemaType)ee).getXMLSchema();
WsdlFinderXMLEntityResolver resolver = new WsdlFinderXMLEntityResolver(rf, defuri, _internalSchemas, false);
try {
- Map<URI, byte[]> capture = XSUtils.captureSchema(defuri, schema, resolver);
- _schemas.putAll(capture);
+ Map<URI, byte[]> capture = XSUtils.captureSchema(defuri, schema, resolver, localSchemaId);
+ for (URI uri : capture.keySet()) {
+ if (!_schemas.containsKey(uri)) {
+ _schemas.put(uri, capture.get(uri));
+ }
+ }
+// _schemas.putAll(capture);
try {
Document doc = DOMUtils.parse(new InputSource(new ByteArrayInputStream(schema)));
@@ -258,6 +264,7 @@ class WSDLRegistry {
// invalidate model
_model = null;
+ localSchemaId ++;
}
}
}
http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
----------------------------------------------------------------------
diff --git a/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java b/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
index 785d2be..4f53b2b 100644
--- a/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
+++ b/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
@@ -78,8 +78,8 @@ public class GoodCompileTest extends TestCase {
suite.addTest(new GoodCompileTCase("/2.0/good/xpath20-func/GetVariableData4-xp2.0.bpel"));
suite.addTest(new GoodCompileTCase("/2.0/good/xpath20-func/GetVariableProperty1-xp2.0.bpel"));
suite.addTest(new GoodCompileTCase("/2.0/good/xsd-import/helloworld-Server.bpel"));
-
+ suite.addTest(new GoodCompileTCase("/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel"));
+
return suite;
}
-
}
http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel
----------------------------------------------------------------------
diff --git a/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel b/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel
new file mode 100644
index 0000000..0c87d15
--- /dev/null
+++ b/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel
@@ -0,0 +1,33 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<process
+ name="InvalidBpelFunction" suppressJoinFailure="yes"
+ targetNamespace="http://ode/test/compile"
+ xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+ xmlns:tns="http://ode/test/compile"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:test="http://ode/test/compile.wsdl">
+ <import namespace="http://ode/test/compile.wsdl" location="MultipleEmbeddedSchemas.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
+ <variables>
+ <variable name="var1" messageType="test:TestMessage" />
+ </variables>
+ <empty/>
+</process>
http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.wsdl
----------------------------------------------------------------------
diff --git a/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.wsdl b/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.wsdl
new file mode 100644
index 0000000..593592c
--- /dev/null
+++ b/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.wsdl
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ode/test/compile.wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:t1="http://mytest1" xmlns:t2="http://mytest2" targetNamespace="http://ode/test/compile.wsdl">
+ <wsdl:types>
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://mytest1">
+ <xsd:complexType name="MyBean1">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" name="bubble" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://mytest2">
+ <xsd:complexType name="MyBean2">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" name="bubble" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="TestMessage">
+ <wsdl:part name="TestPart" type="xsd:string"/>
+ <wsdl:part name="TestPart2" type="t1:MyBean1"/>
+ <wsdl:part name="TestPart3" type="t2:MyBean2"/>
+ </wsdl:message>
+ <wsdl:portType name="TestPortType">
+ <wsdl:operation name="testOperation">
+ <wsdl:input message="tns:TestMessage" name="TestIn"/>
+ <wsdl:output message="tns:TestMessage" name="TestOut"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <bpws:property name="testProp" type="xsd:string"/>
+</wsdl:definitions>
http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java b/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java
index eb12d49..6a04057 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java
@@ -193,6 +193,8 @@ public class SchemaModelImpl implements SchemaModel {
location = resourceIdentifier.getLiteralSystemId();
else if (resourceIdentifier.getExpandedSystemId() != null && _schemas.get(resourceIdentifier.getExpandedSystemId()) != null)
location = resourceIdentifier.getExpandedSystemId();
+ else if (resourceIdentifier.getBaseSystemId() != null && _schemas.get(resourceIdentifier.getBaseSystemId()) != null)
+ location = resourceIdentifier.getBaseSystemId();
else {
if (__log.isDebugEnabled()) {
__log.debug("Available schemas " + _schemas.keySet());
http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java b/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
index 3bec8bc..841bf00 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
@@ -58,7 +58,7 @@ public class XSUtils {
* @return
*/
public static Map<URI, byte[]> captureSchema(URI systemURI, byte[] schemaData,
- XMLEntityResolver resolver) throws XsdException {
+ XMLEntityResolver resolver, int localSchemaId) throws XsdException {
if (__log.isDebugEnabled())
__log.debug("captureSchema(URI,Text,...): systemURI=" + systemURI);
@@ -67,7 +67,9 @@ public class XSUtils {
input.setByteStream(new ByteArrayInputStream(schemaData));
Map<URI, byte[]> ret = captureSchema(input, resolver);
- ret.put(systemURI, schemaData);
+
+ URI localURI = localSchemaId == 0 ? systemURI : URI.create(systemURI.toString() + '.' + localSchemaId);
+ ret.put(localURI, schemaData);
return ret;
}
http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
----------------------------------------------------------------------
diff --git a/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java b/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
index bdd20d4..be1f953 100644
--- a/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
+++ b/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
@@ -62,7 +62,7 @@ public class SchemaCaptureTest extends TestCase {
return src;
}
- });
+ }, 0);
// we expect the root schema and three includes
__log.debug("loaded " + s.keySet());
assertEquals(5, s.size());
[3/3] ode git commit: fixes ODE-1019.
Posted by va...@apache.org.
fixes ODE-1019.
Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/f8228144
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/f8228144
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/f8228144
Branch: refs/heads/ode-1.3.x
Commit: f822814461c3cf0c4c506eb0b20c0afab36634db
Parents: 274a89c
Author: Tammo van Lessen <tv...@gmail.com>
Authored: Tue Jun 9 15:36:47 2015 +0200
Committer: Tammo van Lessen <tv...@gmail.com>
Committed: Tue Jun 9 18:04:07 2015 +0200
----------------------------------------------------------------------
.../java/org/apache/ode/utils/xsd/XSUtils.java | 58 +++++++++++--
.../org/apache/ode/utils/xsd/XsdException.java | 5 ++
.../org/apache/ode/utils/xsd/XsdMessages.java | 4 +
.../apache/ode/utils/xsd/SchemaCaptureTest.java | 87 +++++++++++++-------
4 files changed, 114 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ode/blob/f8228144/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java b/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
index 841bf00..0c2cc26 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
@@ -18,25 +18,28 @@
*/
package org.apache.ode.utils.xsd;
+import java.io.ByteArrayInputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.utils.msg.MessageBundle;
import org.apache.xerces.dom.DOMInputImpl;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.xs.XMLSchemaLoader;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLErrorHandler;
import org.apache.xerces.xni.parser.XMLParseException;
import org.apache.xerces.xs.XSModel;
+import org.w3c.dom.DOMError;
+import org.w3c.dom.DOMErrorHandler;
import org.w3c.dom.ls.LSInput;
-import java.io.ByteArrayInputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* Various utility methods related to XML Schema processing.
@@ -93,6 +96,9 @@ public class XSUtils {
LoggingXmlErrorHandler eh = new LoggingXmlErrorHandler(__log);
schemaLoader.setErrorHandler(eh);
+ LoggingDOMErrorHandler deh = new LoggingDOMErrorHandler(__log);
+ schemaLoader.setParameter(Constants.DOM_ERROR_HANDLER, deh);
+
XSModel model = schemaLoader.load(input);
// The following mess is due to XMLSchemaLoaders funkyness in error
@@ -103,15 +109,26 @@ public class XSUtils {
* Someone inside Xerces will have eaten this exception, for no good
* reason.
*/
+ XsdException ex = null;
+
List<XMLParseException> errors = eh.getErrors();
if (errors.size() != 0) {
__log.error("captureSchema: XMLParseException(s) in " + input);
- XsdException ex = null;
for (XMLParseException xpe : errors) {
ex = new XsdException(ex, xpe.getMessage(), xpe.getLineNumber(), xpe.getColumnNumber(),
xpe.getLiteralSystemId());
}
+ }
+
+ List<Exception> exceptions = deh.getExceptions();
+ if (exceptions.size() != 0) {
+ for (Exception e : exceptions) {
+ ex = new XsdException(ex, e.getMessage());
+ }
+ }
+
+ if (ex != null) {
throw ex;
}
@@ -188,4 +205,29 @@ public class XSUtils {
throw new XNIException("Unknown XSD error state; domain=" + domain + ", key=" +key);
}
}
+
+ static class LoggingDOMErrorHandler implements DOMErrorHandler {
+
+ private ArrayList<Exception> _exceptions = new ArrayList<Exception>();
+ private Log _log;
+
+ public LoggingDOMErrorHandler(Log log) {
+ assert log != null;
+ _log = log;
+ }
+
+ public boolean handleError(DOMError error) {
+ if (_log.isDebugEnabled()) {
+ _log.debug("Exception occurred during parsing schema: " + error.getMessage());
+ }
+ if (error != null) {
+ _exceptions.add((Exception) error.getRelatedException());
+ }
+ return false;
+ }
+
+ public ArrayList<Exception> getExceptions() {
+ return _exceptions;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ode/blob/f8228144/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java b/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java
index ad7e16b..e82cab3 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/XsdException.java
@@ -58,6 +58,11 @@ public class XsdException extends Exception {
_systemId = literalSystemId;
_previous = previous;
}
+
+ public XsdException(XsdException previous, String message) {
+ super(__msgs.msgXsdExceptionMessage(message));
+ _message = message;
+ }
public String getDetailMessage() {
return _message;
http://git-wip-us.apache.org/repos/asf/ode/blob/f8228144/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java b/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java
index 19dd3f0..ccac792 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/XsdMessages.java
@@ -100,6 +100,10 @@ public class XsdMessages extends MessageBundle {
systemId, lineNumber, columnNumber);
}
+ public String msgXsdExceptionMessage(String message) {
+ return this.format("Unable to process XML Schema: {0}", message);
+ }
+
/** An unknown error occured processing schema at {0}" */
public String msgXsdUnknownError(String systemId) {
return this.format("An unknown error occured processing schema at {0}", systemId);
http://git-wip-us.apache.org/repos/asf/ode/blob/f8228144/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
----------------------------------------------------------------------
diff --git a/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java b/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
index be1f953..2a2acd9 100644
--- a/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
+++ b/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
@@ -18,6 +18,14 @@
*/
package org.apache.ode.utils.xsd;
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Map;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.utils.StreamUtils;
@@ -26,46 +34,61 @@ import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLInputSource;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Map;
-
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Test schema capture functionality.
*/
-public class SchemaCaptureTest extends TestCase {
+public class SchemaCaptureTest {
private static Log __log = LogFactory.getLog(SchemaCaptureTest.class);
- public void testSchemaCapture() throws Exception {
- __log.debug("GETTING RESOURCE " + TestResources.getRetailerSchema());
- InputStream xsdStream = new FileInputStream(TestResources.getRetailerSchema().getFile());
- byte[] data;
- try {
- data = StreamUtils.read(xsdStream);
- } finally {
- xsdStream.close();
- }
+ @Test
+ public void testSchemaCapture() throws Exception {
+ __log.debug("GETTING RESOURCE " + TestResources.getRetailerSchema());
+ InputStream xsdStream = TestResources.getRetailerSchema().openStream();
+ byte[] data;
+ try {
+ data = StreamUtils.read(xsdStream);
+ } finally {
+ xsdStream.close();
+ }
+
+ Map<URI, byte[]> s = XSUtils.captureSchema(URI.create("schema.xsd"), data, new XMLEntityResolver() {
+ public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
+ XMLInputSource src = new XMLInputSource(resourceIdentifier);
+ String literalUri = resourceIdentifier.getLiteralSystemId();
- Map<URI, byte[]> s = XSUtils.captureSchema(URI.create("schema.xsd"), data, new XMLEntityResolver() {
- public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
- XMLInputSource src = new XMLInputSource(resourceIdentifier);
- String literalUri = resourceIdentifier.getLiteralSystemId();
-
- if (literalUri != null) {
- src.setByteStream(getClass().getClassLoader().getResourceAsStream(literalUri));
+ if (literalUri != null) {
+ src.setByteStream(getClass().getClassLoader().getResourceAsStream(literalUri));
+ }
+
+ return src;
}
-
- return src;
+ }, 0);
+ // we expect the root schema and three includes
+ __log.debug("loaded " + s.keySet());
+ assertEquals(5, s.size());
+ }
+
+ /**
+ * Test for ODE-1019, provided by Igor Vorobiov
+ */
+ @Test(expected = Exception.class)
+ public void testSchemaCaptureException() throws Exception {
+ InputStream xsdStream = new FileInputStream(TestResources.getRetailerSchema().getFile());
+ byte[] data;
+ try {
+ data = StreamUtils.read(xsdStream);
+ } finally {
+ xsdStream.close();
}
- }, 0);
- // we expect the root schema and three includes
- __log.debug("loaded " + s.keySet());
- assertEquals(5, s.size());
+ XSUtils.captureSchema(URI.create("schema.xsd"), data, new XMLEntityResolver() {
+ public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
+ // !!! cause NullPointerException
+ return null;
+ }
+ }, 0);
+
+ __log.error("mustn't reach this place");
}
-
}