You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by bo...@apache.org on 2007/07/06 00:20:36 UTC
svn commit: r553662 - in /incubator/ode/trunk:
bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/
utils/src/main/java/org/apache/ode/utils/xsd/
Author: boisvert
Date: Thu Jul 5 15:20:34 2007
New Revision: 553662
URL: http://svn.apache.org/viewvc?view=rev&rev=553662
Log:
1) Don't fail if unable to resolve a schema import during capture;
this allows interdependent schemas to load properly
2) Don't try to interpret schema namespace as URL during resolution; rely on schemaLocation attribute only
Modified:
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java?view=diff&rev=553662&r1=553661&r2=553662
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java Thu Jul 5 15:20:34 2007
@@ -201,7 +201,7 @@
String schema = ((XMLSchemaType)ee).getXMLSchema();
Map<URI, byte[]> capture = null;
- WsdlFinderXMLEntityResolver resolver = new WsdlFinderXMLEntityResolver(rf, defuri, _internalSchemas);
+ WsdlFinderXMLEntityResolver resolver = new WsdlFinderXMLEntityResolver(rf, defuri, _internalSchemas, false);
try {
capture = XSUtils.captureSchema(defuri, schema, resolver);
_schemas.putAll(capture);
Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java?view=diff&rev=553662&r1=553661&r2=553662
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java Thu Jul 5 15:20:34 2007
@@ -18,21 +18,20 @@
*/
package org.apache.ode.bpel.compiler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-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.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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;
+
/**
* Xerces {@link XMLEntityResolver} implementation that defers to our own
* {@link ResourceFinder} interface for loading resources. This class is
@@ -65,10 +64,12 @@
* typically this is the system URI of the WSDL containing an
* embedded schema
*/
- public WsdlFinderXMLEntityResolver(ResourceFinder finder, URI baseURI, Map<URI, String> internalSchemas) {
+ public WsdlFinderXMLEntityResolver(ResourceFinder finder, URI baseURI, Map<URI, String> internalSchemas,
+ boolean failIfNotFound) {
_wsdlFinder = finder;
_baseURI = baseURI;
_internalSchemas = internalSchemas;
+ _failIfNotFound = failIfNotFound;
}
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
@@ -80,23 +81,15 @@
XMLInputSource src = new XMLInputSource(resourceIdentifier);
URI location;
- try {
- // Note: if the systemId is not specified then what we have is
- // an import without a schemaLocation. In this case we use the
- // namespace to stand in for the location. If we have an
- // expandedsystemId, then we must use that, since schemas that
- // are imported by other schemas will have their relative
- // locations encoded here. If we only have a literal system id,
- // then it is going to be realative to our baseURI.
- if (resourceIdentifier.getLiteralSystemId() == null)
- location = new URI(resourceIdentifier.getNamespace());
- else if (resourceIdentifier.getExpandedSystemId() != null)
- location = _baseURI.resolve(resourceIdentifier.getExpandedSystemId());
- else
- location = _baseURI.resolve(resourceIdentifier.getLiteralSystemId());
- } catch (URISyntaxException e) {
- __log.debug("resolveEntity: URI syntax error", e);
- throw new IOException(e.getMessage());
+ if (resourceIdentifier.getLiteralSystemId() == null) {
+ // import without schemaLocation
+ if (__log.isDebugEnabled()) __log.debug("resolveEntity: no schema location for "+resourceIdentifier.getNamespace());
+ return null;
+ } else if (resourceIdentifier.getExpandedSystemId() != null) {
+ // schema imported by other schema
+ location = _baseURI.resolve(resourceIdentifier.getExpandedSystemId());
+ } else {
+ location = _baseURI.resolve(resourceIdentifier.getLiteralSystemId());
}
if (__log.isDebugEnabled())
@@ -120,17 +113,15 @@
__log.debug("resolveEntity: IOException opening " + location,ioex);
if (_failIfNotFound) {
- __log.debug("resolveEntity: failIfNotFound set, rethrowing...");
+ __log.debug("resolveEntity: failIfNotFound is true, rethrowing...");
throw ioex;
}
-
- __log.debug("resolveEntity: failIfNotFound NOT set, returning NULL");
+ __log.debug("resolveEntity: failIfNotFound is false, returning null");
return null;
} catch (Exception ex) {
__log.debug("resolveEntity: unexpected error: " + location);
throw new IOException("Unexpected error loading resource: " + location);
}
-
return src;
}
Modified: incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java?view=diff&rev=553662&r1=553661&r2=553662
==============================================================================
--- incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java (original)
+++ incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java Thu Jul 5 15:20:34 2007
@@ -55,7 +55,7 @@
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
throws XNIException, IOException {
- if (__log.isTraceEnabled()) {
+ if (__log.isDebugEnabled()) {
StringBuffer buf = new StringBuffer("resolveEntity: base=");
buf.append(resourceIdentifier.getBaseSystemId());
buf.append(", literal=");
@@ -66,7 +66,7 @@
buf.append(resourceIdentifier.getNamespace());
buf.append(", publicId=");
buf.append(resourceIdentifier.getPublicId());
- __log.trace(buf.toString());
+ __log.debug(buf.toString());
}
XMLInputSource src = _resolver.resolveEntity(resourceIdentifier);
@@ -89,6 +89,7 @@
FileUtils.encodePath(resourceIdentifier.getLiteralSystemId() == null ? resourceIdentifier
.getNamespace() : resourceIdentifier.getLiteralSystemId()));
+ __log.debug("Captured: "+systemId);
_capture.put(systemId, data);
} catch (URISyntaxException use) {
__log.error("Invalid URI: " + resourceIdentifier.getLiteralSystemId());
Modified: incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java?view=diff&rev=553662&r1=553661&r2=553662
==============================================================================
--- incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java (original)
+++ incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java Thu Jul 5 15:20:34 2007
@@ -129,22 +129,18 @@
*/
List<XMLParseException> errors = eh.getErrors();
if (errors.size() != 0) {
- if (__log.isDebugEnabled())
- __log.debug("captureSchema: XMLParseException(s) in " + input);
+ __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());
}
- assert ex != null;
throw ex;
}
if (__log.isDebugEnabled())
__log.debug("captureSchema: NULL model (unknown error) for " + input.getSystemId());
-
- throw new XsdException(null, __msgs.msgXsdUnknownError(input.getSystemId()), 0, 0, input.getSystemId());
}
return captured;