You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2008/10/31 10:45:00 UTC
svn commit: r709372 [2/2] - in /tuscany/java/sca:
itest/validation/src/main/resources/contribution/xml/MultipleCompositeErrors/
itest/validation/src/test/java/binding/jms/
itest/validation/src/test/java/contribution/xml/
itest/validation/src/test/java/...
Modified: tuscany/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java Fri Oct 31 02:44:57 2008
@@ -74,6 +74,20 @@
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-java-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
public QName getArtifactType() {
return EXPORT_JAVA;
@@ -86,38 +100,44 @@
/**
* Process <export package=""/>
*/
- public JavaExport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ public JavaExport read(XMLStreamReader reader) throws ContributionReadException {
JavaExport javaExport = this.factory.createJavaExport();
QName element = null;
- while (reader.hasNext()) {
- int event = reader.getEventType();
- switch (event) {
- case START_ELEMENT:
- element = reader.getName();
-
- // Read <export.java>
- if (EXPORT_JAVA.equals(element)) {
- String packageName = reader.getAttributeValue(null, PACKAGE);
- if (packageName == null) {
- error("AttributePackageMissing", reader);
- //throw new ContributionReadException("Attribute 'package' is missing");
- } else
- javaExport.setPackage(packageName);
- }
- break;
- case XMLStreamConstants.END_ELEMENT:
- if (EXPORT_JAVA.equals(reader.getName())) {
- return javaExport;
- }
- 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.java>
+ if (EXPORT_JAVA.equals(element)) {
+ String packageName = reader.getAttributeValue(null, PACKAGE);
+ if (packageName == null) {
+ error("AttributePackageMissing", reader);
+ //throw new ContributionReadException("Attribute 'package' is missing");
+ } else
+ javaExport.setPackage(packageName);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (EXPORT_JAVA.equals(reader.getName())) {
+ return javaExport;
+ }
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
}
}
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error("XMLStreamException", reader, ex);
+ }
return javaExport;
}
Modified: tuscany/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-java/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java Fri Oct 31 02:44:57 2008
@@ -75,6 +75,20 @@
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-java-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
public QName getArtifactType() {
return IMPORT_JAVA;
@@ -87,41 +101,47 @@
/**
* Process <import.java package="" location=""/>
*/
- public JavaImport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ public JavaImport read(XMLStreamReader reader) throws ContributionReadException {
JavaImport javaImport = this.factory.createJavaImport();
QName element = null;
- while (reader.hasNext()) {
- int event = reader.getEventType();
- switch (event) {
- case START_ELEMENT:
- element = reader.getName();
-
- // Read <import.java>
- if (IMPORT_JAVA.equals(element)) {
- String packageName = reader.getAttributeValue(null, PACKAGE);
- if (packageName == null) {
- error("AttributePackageMissing", reader);
- //throw new ContributionReadException("Attribute 'package' is missing");
- } else
- javaImport.setPackage(packageName);
-
- String location = reader.getAttributeValue(null, LOCATION);
- javaImport.setLocation(location);
- }
- break;
- case XMLStreamConstants.END_ELEMENT:
- if (IMPORT_JAVA.equals(reader.getName())) {
- return javaImport;
- }
- 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 <import.java>
+ if (IMPORT_JAVA.equals(element)) {
+ String packageName = reader.getAttributeValue(null, PACKAGE);
+ if (packageName == null) {
+ error("AttributePackageMissing", reader);
+ //throw new ContributionReadException("Attribute 'package' is missing");
+ } else
+ javaImport.setPackage(packageName);
+
+ String location = reader.getAttributeValue(null, LOCATION);
+ javaImport.setLocation(location);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (IMPORT_JAVA.equals(reader.getName())) {
+ return javaImport;
+ }
+ break;
+ }
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
}
}
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error("XMLStreamException", reader, ex);
+ }
return javaImport;
}
Modified: tuscany/java/sca/modules/contribution-java/src/main/resources/contribution-java-validation-messages.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-java/src/main/resources/contribution-java-validation-messages.properties?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-java/src/main/resources/contribution-java-validation-messages.properties (original)
+++ tuscany/java/sca/modules/contribution-java/src/main/resources/contribution-java-validation-messages.properties Fri Oct 31 02:44:57 2008
@@ -19,4 +19,5 @@
#
#
AttributePackageMissing = Attribute 'package' is missing
+XMLStreamException = XMLStreamException occured due to : {0}
Modified: tuscany/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java Fri Oct 31 02:44:57 2008
@@ -72,6 +72,20 @@
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;
@@ -84,39 +98,45 @@
/**
* 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;
}
Modified: tuscany/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java Fri Oct 31 02:44:57 2008
@@ -75,6 +75,20 @@
}
}
+ /**
+ * 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;
}
@@ -86,43 +100,49 @@
/**
* 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;
}
Modified: tuscany/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties (original)
+++ tuscany/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties Fri Oct 31 02:44:57 2008
@@ -19,4 +19,5 @@
#
#
AttributeNameSpaceMissing = Attribute 'namespace' is missing
+XMLStreamException = XMLStreamException occured due to : {0}
Modified: tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java Fri Oct 31 02:44:57 2008
@@ -68,10 +68,24 @@
*/
private void error(String message, Object model, Object... messageParameters) {
if (monitor != null) {
- Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-resource-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
+ Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-resource-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ 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-resource-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
public QName getArtifactType() {
return EXPORT_RESOURCE;
@@ -84,39 +98,45 @@
/**
* Process <export.resource uri=""/>
*/
- 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 <export.resource>
- 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 <export.resource>
+ 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;
}
Modified: tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java Fri Oct 31 02:44:57 2008
@@ -74,6 +74,20 @@
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-resource-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
public QName getArtifactType() {
return IMPORT_RESOURCE;
@@ -86,43 +100,49 @@
/**
* Process <import.resource uri="" location=""/>
*/
- 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 <import>
- 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 <import>
+ 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;
}
Modified: tuscany/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties (original)
+++ tuscany/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties Fri Oct 31 02:44:57 2008
@@ -19,4 +19,5 @@
#
#
AttributeURIMissing = Attribute 'uri' is missing
+XMLStreamException = XMLStreamException occured due to : {0}
Modified: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java Fri Oct 31 02:44:57 2008
@@ -33,6 +33,7 @@
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.contribution.service.ContributionReadException;
import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
@@ -61,7 +62,7 @@
public ContributionMetadataDocumentProcessor(ModelFactoryExtensionPoint modelFactories,
StAXArtifactProcessor staxProcessor,
Monitor monitor) {
- this.inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
this.staxProcessor = staxProcessor;
this.monitor = monitor;
}
Modified: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java Fri Oct 31 02:44:57 2008
@@ -88,6 +88,20 @@
}
}
+ /**
+ * 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-xml-validation-messages", Severity.ERROR, model, message, ex);
+ monitor.problem(problem);
+ }
+ }
+
public ContributionMetadataProcessor(ModelFactoryExtensionPoint modelFactories,
StAXArtifactProcessor<Object> extensionProcessor,
Monitor monitor) {
@@ -106,63 +120,69 @@
return ContributionMetadata.class;
}
- public ContributionMetadata read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ public ContributionMetadata read(XMLStreamReader reader) throws ContributionReadException {
ContributionMetadata contribution = null;
QName name = null;
- while (reader.hasNext()) {
- int event = reader.getEventType();
- switch (event) {
- case START_ELEMENT:
- name = reader.getName();
-
- if (CONTRIBUTION_QNAME.equals(name)) {
-
- // Read <contribution>
- contribution = this.contributionFactory.createContributionMetadata();
- contribution.setUnresolved(true);
+ try {
+ while (reader.hasNext()) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
- } else if (DEPLOYABLE_QNAME.equals(name)) {
-
- // Read <deployable>
- QName compositeName = getQName(reader, "composite");
- if (compositeName == null) {
- error("AttributeCompositeMissing", reader);
- //throw new ContributionReadException("Attribute 'composite' is missing");
+ if (CONTRIBUTION_QNAME.equals(name)) {
+
+ // Read <contribution>
+ contribution = this.contributionFactory.createContributionMetadata();
+ contribution.setUnresolved(true);
+
+ } else if (DEPLOYABLE_QNAME.equals(name)) {
+
+ // Read <deployable>
+ QName compositeName = getQName(reader, "composite");
+ if (compositeName == null) {
+ error("AttributeCompositeMissing", reader);
+ //throw new ContributionReadException("Attribute 'composite' is missing");
+ } else {
+ if (contribution != null) {
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(compositeName);
+ composite.setUnresolved(true);
+ contribution.getDeployables().add(composite);
+ }
+ }
} else {
- if (contribution != null) {
- Composite composite = assemblyFactory.createComposite();
- composite.setName(compositeName);
- composite.setUnresolved(true);
- contribution.getDeployables().add(composite);
+
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader);
+ if (extension != null && contribution != null) {
+ if (extension instanceof Import) {
+ contribution.getImports().add((Import)extension);
+ } else if (extension instanceof Export) {
+ contribution.getExports().add((Export)extension);
+ }
}
}
- } else {
-
- // Read an extension element
- Object extension = extensionProcessor.read(reader);
- if (extension != null && contribution != null) {
- if (extension instanceof Import) {
- contribution.getImports().add((Import)extension);
- } else if (extension instanceof Export) {
- contribution.getExports().add((Export)extension);
- }
+ break;
+
+ case XMLStreamConstants.END_ELEMENT:
+ if (CONTRIBUTION_QNAME.equals(reader.getName())) {
+ return contribution;
}
- }
- break;
-
- case XMLStreamConstants.END_ELEMENT:
- if (CONTRIBUTION_QNAME.equals(reader.getName())) {
- return contribution;
- }
- break;
- }
-
- //Read the next element
- if (reader.hasNext()) {
- reader.next();
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
}
}
+ catch (XMLStreamException e) {
+ ContributionReadException ex = new ContributionReadException(e);
+ error("XMLStreamException", reader, ex);
+ }
return contribution;
}
Modified: tuscany/java/sca/modules/contribution-xml/src/main/resources/contribution-xml-validation-messages.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-xml/src/main/resources/contribution-xml-validation-messages.properties?rev=709372&r1=709371&r2=709372&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-xml/src/main/resources/contribution-xml-validation-messages.properties (original)
+++ tuscany/java/sca/modules/contribution-xml/src/main/resources/contribution-xml-validation-messages.properties Fri Oct 31 02:44:57 2008
@@ -18,6 +18,7 @@
# under the License.
#
#
-XMLStreamException = XMLStreamException occured due to:
-IOException = IOException occured due to:
-AttributeCompositeMissing = Attribute 'composite' is missing
\ No newline at end of file
+XMLStreamException = XMLStreamException occured due to : {0}
+IOException = IOException occured due to : {0}
+AttributeCompositeMissing = Attribute 'composite' is missing
+