From 5f3869c451e46aadc943d00087d6847877dd1c50 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 19 Nov 2008 05:27:58 +0000 Subject: Merging the 1.x delta on top of the equinox based modules git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@718858 13f79535-47bb-0310-9956-ffa450edef68 --- .../namespace/impl/NamespaceExportProcessor.java | 76 ++++++++++++-------- .../namespace/impl/NamespaceImportProcessor.java | 82 ++++++++++++++-------- ...bution-namespace-validation-messages.properties | 1 + 3 files changed, 100 insertions(+), 59 deletions(-) (limited to 'java/sca/modules/contribution-namespace') diff --git a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java index 6bf7c8f1d7..97f98adddc 100644 --- a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java +++ b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java @@ -71,6 +71,20 @@ public class NamespaceExportProcessor implements StAXArtifactProcessor */ - public NamespaceExport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + public NamespaceExport read(XMLStreamReader reader) throws ContributionReadException { NamespaceExport namespaceExport = this.factory.createNamespaceExport(); QName element = null; - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - case START_ELEMENT: - element = reader.getName(); - - // Read - if (EXPORT.equals(element)) { - String ns = reader.getAttributeValue(null, NAMESPACE); - if (ns == null) { - error("AttributeNameSpaceMissing", reader); - //throw new ContributionReadException("Attribute 'namespace' is missing"); - } else - namespaceExport.setNamespace(ns); - } - - break; - case XMLStreamConstants.END_ELEMENT: - if (EXPORT.equals(reader.getName())) { - return namespaceExport; - } - break; - } - - // Read the next element - if (reader.hasNext()) { - reader.next(); + try { + while (reader.hasNext()) { + int event = reader.getEventType(); + switch (event) { + case START_ELEMENT: + element = reader.getName(); + + // Read + if (EXPORT.equals(element)) { + String ns = reader.getAttributeValue(null, NAMESPACE); + if (ns == null) { + error("AttributeNameSpaceMissing", reader); + //throw new ContributionReadException("Attribute 'namespace' is missing"); + } else + namespaceExport.setNamespace(ns); + } + + break; + case XMLStreamConstants.END_ELEMENT: + if (EXPORT.equals(reader.getName())) { + return namespaceExport; + } + break; + } + + // Read the next element + if (reader.hasNext()) { + reader.next(); + } } } + catch (XMLStreamException e) { + ContributionReadException ex = new ContributionReadException(e); + error("XMLStreamException", reader, ex); + } return namespaceExport; } diff --git a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java index e258dcf874..bfd61a2d95 100644 --- a/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java +++ b/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java @@ -74,6 +74,20 @@ public class NamespaceImportProcessor implements StAXArtifactProcessor */ - public NamespaceImport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + public NamespaceImport read(XMLStreamReader reader) throws ContributionReadException { NamespaceImport namespaceImport = this.factory.createNamespaceImport(); QName element; - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - case START_ELEMENT: - element = reader.getName(); - - // Read - if (IMPORT.equals(element)) { - String ns = reader.getAttributeValue(null, NAMESPACE); - if (ns == null) { - error("AttributeNameSpaceMissing", reader); - //throw new ContributionReadException("Attribute 'namespace' is missing"); - } else - namespaceImport.setNamespace(ns); - - String location = reader.getAttributeValue(null, LOCATION); - if (location != null) { - namespaceImport.setLocation(location); + try { + while (reader.hasNext()) { + int event = reader.getEventType(); + switch (event) { + case START_ELEMENT: + element = reader.getName(); + + // Read + if (IMPORT.equals(element)) { + String ns = reader.getAttributeValue(null, NAMESPACE); + if (ns == null) { + error("AttributeNameSpaceMissing", reader); + //throw new ContributionReadException("Attribute 'namespace' is missing"); + } else + namespaceImport.setNamespace(ns); + + String location = reader.getAttributeValue(null, LOCATION); + if (location != null) { + namespaceImport.setLocation(location); + } } - } - break; - case XMLStreamConstants.END_ELEMENT: - if (IMPORT.equals(reader.getName())) { - return namespaceImport; - } - break; - } - - // Read the next element - if (reader.hasNext()) { - reader.next(); + break; + case XMLStreamConstants.END_ELEMENT: + if (IMPORT.equals(reader.getName())) { + return namespaceImport; + } + break; + } + + // Read the next element + if (reader.hasNext()) { + reader.next(); + } } } + catch (XMLStreamException e) { + ContributionReadException ex = new ContributionReadException(e); + error("XMLStreamException", reader, ex); + } return namespaceImport; } diff --git a/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties b/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties index c7ddba3c3d..c1cbd06e7f 100644 --- a/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties +++ b/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties @@ -19,4 +19,5 @@ # # AttributeNameSpaceMissing = Attribute 'namespace' is missing +XMLStreamException = XMLStreamException occured due to : {0} -- cgit v1.2.3