diff options
Diffstat (limited to 'branches')
7 files changed, 88 insertions, 26 deletions
diff --git a/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java index 15b58e499c..860daa647d 100644 --- a/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java +++ b/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java @@ -46,6 +46,7 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionRuntimeException; import org.apache.tuscany.sca.contribution.service.ContributionWriteException; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; @@ -97,9 +98,9 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ /** * Report a warning. * - * @param problems - * @param message + * @param problem * @param model + * @param message data */ private void warning(String message, Object model, Object... messageParameters) { if (monitor != null) { @@ -109,11 +110,11 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ } /** - * Report a error. + * Report an error. * - * @param problems - * @param message + * @param problem * @param model + * @param message data */ private void error(String message, Object model, Object... messageParameters) { if (monitor != null) { @@ -122,6 +123,20 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ } } + /** + * Report an exception. + * + * @param problem + * @param model + * @param exception + */ + private void error(String message, Object model, Exception ex) { + if (monitor != null) { + Problem problem = new ProblemImpl(this.getClass().getName(), "binding-wsxml-validation-messages", Severity.ERROR, model, message, ex); + monitor.problem(problem); + } + } + public WebServiceBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { // Read a <binding.ws> @@ -322,7 +337,14 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition(); wsdlDefinition.setUnresolved(true); wsdlDefinition.setNamespace(model.getNamespace()); - WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition); + WSDLDefinition resolved = null; + try { + resolved = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition); + } catch (ContributionRuntimeException e) { + ContributionResolveException ce = new ContributionResolveException(e.getCause()); + error("ContributionResolveException", wsdlDefinition, ce); + throw ce; + } if (!resolved.isUnresolved()) { wsdlDefinition.setDefinition(resolved.getDefinition()); diff --git a/branches/sca-java-1.x/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties b/branches/sca-java-1.x/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties index 2dfa5e6133..9e2ff5830d 100644 --- a/branches/sca-java-1.x/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties +++ b/branches/sca-java-1.x/modules/binding-ws-xml/src/main/resources/binding-wsxml-validation-messages.properties @@ -24,5 +24,4 @@ InvalidInterfaceException = Exception creating interface from WSDL for binding: WsdlBindingDoesNotMatch = The #wsdl.binding({0}) does not match with the WSDL Definitions WsdlServiceDoesNotMatch = The #wsdl.service({0}) does not match with the WSDL Definitions WsdlPortTypeDoesNotMatch = The #wsdl.port({0}) does not match with the WSDL Definitions - - +ContributionResolveException = Error in contribution: {0} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java b/branches/sca-java-1.x/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java index a7f148cdda..bb8b8ad0e0 100644 --- a/branches/sca-java-1.x/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java +++ b/branches/sca-java-1.x/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/SCADomain.java @@ -214,6 +214,8 @@ public abstract class SCADomain { return domain; + } catch (ServiceRuntimeException e) { + throw e; } catch (Exception e) { throw new ServiceRuntimeException(e); } diff --git a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java index e04a4d6743..14f7d4ff5c 100644 --- a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java +++ b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java @@ -34,6 +34,7 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionRuntimeException; import org.apache.tuscany.sca.contribution.service.ContributionWriteException; import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; @@ -62,9 +63,9 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa /** * Report a warning. * - * @param problems - * @param message + * @param problem * @param model + * @param message data */ private void warning(String message, Object model, Object... messageParameters) { if (monitor != null) { @@ -74,11 +75,11 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa } /** - * Report a error. + * Report an error. * - * @param problems - * @param message + * @param problem * @param model + * @param message data */ private void error(String message, Object model, Object... messageParameters) { if (monitor != null) { @@ -88,11 +89,11 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa } /** - * Report a exception. + * Report an exception. * - * @param problems - * @param message + * @param problem * @param model + * @param exception */ private void error(String message, Object model, Exception ex) { if (monitor != null) { @@ -217,9 +218,12 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa wsdlInterface = wsdlFactory.createWSDLInterface(portType.getElement(), wsdlDefinition, resolver); wsdlInterface.setWsdlDefinition(wsdlDefinition); resolver.addModel(wsdlInterface); + } catch (ContributionRuntimeException e) { + ContributionResolveException ce = new ContributionResolveException(e.getCause()); + error("ContributionResolveException", wsdlDefinition, ce); } catch (InvalidInterfaceException e) { ContributionResolveException ce = new ContributionResolveException(e); - error("ContributionResolveException", wsdlFactory, ce); + error("ContributionResolveException", wsdlDefinition, ce); //throw ce; } } diff --git a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/resources/interface-wsdlxml-validation-messages.properties b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/resources/interface-wsdlxml-validation-messages.properties index 2f8c3e0500..7355d3390d 100644 --- a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/resources/interface-wsdlxml-validation-messages.properties +++ b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/resources/interface-wsdlxml-validation-messages.properties @@ -19,6 +19,6 @@ # # ContributionReadException = ContributionReadException occured due to : -ContributionResolveException = ContributionResolveException occured due to : +ContributionResolveException = Error in contribution: {0} InvalidWSDLInterfaceAttr = Invalid WSDL interface attribute: {0} -WsdlInterfaceDoesNotMatch = The #wsdl.interface({0}) specified does not match with WSDL Definitions
\ No newline at end of file +WsdlInterfaceDoesNotMatch = The #wsdl.interface({0}) specified does not match with WSDL Definitions diff --git a/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index 457790522b..2103ca9d0f 100644 --- a/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -165,6 +165,8 @@ public class NodeImpl implements SCANode, SCAClient { ConfiguredNodeImplementation config = findNodeConfiguration(compositeURI, classLoader); configureNode(config); + } catch (ServiceRuntimeException e) { + throw e; } catch (Throwable e) { throw new ServiceRuntimeException(e); } diff --git a/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java b/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java index 3e22b49d31..f05a2e4cbe 100644 --- a/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java +++ b/branches/sca-java-1.x/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java @@ -156,7 +156,17 @@ public class XSDModelResolver implements ModelResolver { if (definition.getLocation() != null) { uri = definition.getLocation().toString(); } - XmlSchema schema = schemaCollection.read(definition.getDocument(), uri, null); + XmlSchema schema = null; + try { + schema = schemaCollection.read(definition.getDocument(), uri, null); + } catch (RuntimeException e) { + // find original cause of the problem + Throwable cause = e; + while (cause.getCause() != null) { + cause = cause.getCause(); + } + throw new ContributionRuntimeException(cause); + } definition.setSchemaCollection(schemaCollection); definition.setSchema(schema); definition.setUnresolved(false); @@ -168,17 +178,35 @@ public class XSDModelResolver implements ModelResolver { // Read an XSD document InputSource xsd = XMLDocumentHelper.getInputSource(definition.getLocation().toURL()); for (XmlSchema d : schemaCollection.getXmlSchemas()) { - if (d.getTargetNamespace().equals(definition.getNamespace())) { + if (isSameNamespace(d.getTargetNamespace(), definition.getNamespace())) { if (d.getSourceURI().equals(definition.getLocation().toString())) return; } } - XmlSchema schema = schemaCollection.read(xsd, null); + XmlSchema schema = null; + try { + schema = schemaCollection.read(xsd, null); + } catch (RuntimeException e) { + // find original cause of the problem + Throwable cause = e; + while (cause.getCause() != null) { + cause = cause.getCause(); + } + throw new ContributionRuntimeException(cause); + } definition.setSchemaCollection(schemaCollection); definition.setSchema(schema); } } + private boolean isSameNamespace(String ns1, String ns2) { + if (ns1 == null) { + return ns2 == null; + } else { + return ns1.equals(ns2); + } + } + /** * Create a facade XmlSchema which includes all the definitions * @@ -249,9 +277,7 @@ public class XSDModelResolver implements ModelResolver { this.contribution = contribution; } - public org.xml.sax.InputSource resolveEntity(java.lang.String targetNamespace, - java.lang.String schemaLocation, - java.lang.String baseUri) { + public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) { try { if (schemaLocation == null) { return null; @@ -266,12 +292,19 @@ public class XSDModelResolver implements ModelResolver { break; } } + if (url == null) { + // URI not found in the contribution; return a default InputSource + // so that the XmlSchema code will produce a useful diagnostic + return new InputSource(schemaLocation); + } } else { url = new URL(new URL(baseUri), schemaLocation); } return XMLDocumentHelper.getInputSource(url); } catch (IOException e) { - return null; + // Invalid URI; return a default InputSource so that the + // XmlSchema code will produce a useful diagnostic + return new InputSource(schemaLocation); } } } |