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 --- .../resource/impl/ResourceExportProcessor.java | 76 ++++++++++++-------- .../resource/impl/ResourceImportProcessor.java | 82 ++++++++++++++-------- ...ibution-resource-validation-messages.properties | 1 + 3 files changed, 100 insertions(+), 59 deletions(-) (limited to 'java/sca/modules/contribution-resource') diff --git a/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java b/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java index f5f9fad167..885427e92c 100644 --- a/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java +++ b/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java @@ -71,6 +71,20 @@ public class ResourceExportProcessor implements StAXArtifactProcessor */ - public ResourceExport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + public ResourceExport read(XMLStreamReader reader) throws ContributionReadException { ResourceExport resourceExport = this.factory.createResourceExport(); QName element = null; - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - case START_ELEMENT: - element = reader.getName(); - - // Read - if (EXPORT_RESOURCE.equals(element)) { - String uri = reader.getAttributeValue(null, URI); - if (uri == null) { - error("AttributeURIMissing", reader); - //throw new ContributionReadException("Attribute 'uri' is missing"); - } else - resourceExport.setURI(uri); - } - - break; - case XMLStreamConstants.END_ELEMENT: - if (EXPORT_RESOURCE.equals(reader.getName())) { - return resourceExport; - } - 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_RESOURCE.equals(element)) { + String uri = reader.getAttributeValue(null, URI); + if (uri == null) { + error("AttributeURIMissing", reader); + //throw new ContributionReadException("Attribute 'uri' is missing"); + } else + resourceExport.setURI(uri); + } + + break; + case XMLStreamConstants.END_ELEMENT: + if (EXPORT_RESOURCE.equals(reader.getName())) { + return resourceExport; + } + break; + } + + // Read the next element + if (reader.hasNext()) { + reader.next(); + } } } + catch (XMLStreamException e) { + ContributionReadException ex = new ContributionReadException(e); + error("XMLStreamException", reader, ex); + } return resourceExport; } diff --git a/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java b/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java index 7fdb74e256..865ab8ff25 100644 --- a/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java +++ b/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java @@ -73,6 +73,20 @@ public class ResourceImportProcessor implements StAXArtifactProcessor */ - public ResourceImport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + public ResourceImport read(XMLStreamReader reader) throws ContributionReadException { ResourceImport resourceImport = this.factory.createResourceImport(); QName element; - while (reader.hasNext()) { - int event = reader.getEventType(); - switch (event) { - case START_ELEMENT: - element = reader.getName(); - - // Read - if (IMPORT_RESOURCE.equals(element)) { - String uri = reader.getAttributeValue(null, URI); - if (uri == null) { - error("AttributeURIMissing", reader); - //throw new ContributionReadException("Attribute 'uri' is missing"); - } else - resourceImport.setURI(uri); - - String location = reader.getAttributeValue(null, LOCATION); - if (location != null) { - resourceImport.setLocation(location); + try { + while (reader.hasNext()) { + int event = reader.getEventType(); + switch (event) { + case START_ELEMENT: + element = reader.getName(); + + // Read + if (IMPORT_RESOURCE.equals(element)) { + String uri = reader.getAttributeValue(null, URI); + if (uri == null) { + error("AttributeURIMissing", reader); + //throw new ContributionReadException("Attribute 'uri' is missing"); + } else + resourceImport.setURI(uri); + + String location = reader.getAttributeValue(null, LOCATION); + if (location != null) { + resourceImport.setLocation(location); + } } - } - break; - case XMLStreamConstants.END_ELEMENT: - if (IMPORT_RESOURCE.equals(reader.getName())) { - return resourceImport; - } - break; - } - - // Read the next element - if (reader.hasNext()) { - reader.next(); + break; + case XMLStreamConstants.END_ELEMENT: + if (IMPORT_RESOURCE.equals(reader.getName())) { + return resourceImport; + } + break; + } + + // Read the next element + if (reader.hasNext()) { + reader.next(); + } } } + catch (XMLStreamException e) { + ContributionReadException ex = new ContributionReadException(e); + error("XMLStreamException", reader, ex); + } return resourceImport; } diff --git a/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties b/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties index 58ee8153f8..9df66cce52 100644 --- a/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties +++ b/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties @@ -19,4 +19,5 @@ # # AttributeURIMissing = Attribute 'uri' is missing +XMLStreamException = XMLStreamException occured due to : {0} -- cgit v1.2.3