diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-19 05:27:58 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-19 05:27:58 +0000 |
commit | 5f3869c451e46aadc943d00087d6847877dd1c50 (patch) | |
tree | e22baaff1fb9ea42606b7d04af52e032e3bc03bc /java/sca/modules/contribution-namespace | |
parent | 60744a36aae604ac3c4499ed54f1082ab8f5947d (diff) |
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
Diffstat (limited to 'java/sca/modules/contribution-namespace')
3 files changed, 100 insertions, 59 deletions
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<Namespace monitor.problem(problem); } } + + /** + * Report a exception. + * + * @param problems + * @param message + * @param model + */ + private void error(String message, Object model, Exception ex) { + if (monitor != null) { + Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-namespace-validation-messages", Severity.ERROR, model, message, ex); + monitor.problem(problem); + } + } public QName getArtifactType() { return EXPORT; @@ -83,39 +97,45 @@ public class NamespaceExportProcessor implements StAXArtifactProcessor<Namespace /** * Process <export namespace=""/> */ - 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 <export> - 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 <export> + 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<Namespac } } + /** + * Report a exception. + * + * @param problems + * @param message + * @param model + */ + private void error(String message, Object model, Exception ex) { + if (monitor != null) { + Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-namespace-validation-messages", Severity.ERROR, model, message, ex); + monitor.problem(problem); + } + } + public QName getArtifactType() { return IMPORT; } @@ -85,43 +99,49 @@ public class NamespaceImportProcessor implements StAXArtifactProcessor<Namespac /** * Process <import namespace="" location=""/> */ - 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 <import> - 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 <import> + 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} |