Author: jkaputin
Date: Mon Aug 6 07:53:26 2007
New Revision: 563158
URL: http://svn.apache.org/viewvc?view=rev&rev=563158
Log:
WODEN-141
Added factory method DescriptionElement.addTypesElement()
and changed getTypesElement() to return null if no
wsdl:types element is present. Thanks to Dan Harvey
for contributing the fix.
Modified:
incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java
incubator/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java
incubator/woden/trunk/java/src/org/apache/woden/internal/Messages.properties
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/DescriptionElement.java
incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptiontElementTest.java
Modified:
incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java
URL:
http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java?view=diff&rev=563158&r1=563157&r2=563158
==============================================================================
---
incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java
(original)
+++
incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java
Mon Aug 6 07:53:26 2007
@@ -546,7 +546,7 @@
DescriptionElement desc)
throws WSDLException {
- TypesElement types = desc.getTypesElement();
+ TypesElement types = desc.addTypesElement();
//TODO for now set to W3 XML Schema. Later, add support for non-XML
Schema type systems
types.setTypeSystem(Constants.TYPE_XSD_2001);
@@ -1606,7 +1606,7 @@
* model programmatically.
* This method should be reevaluated at a later point.
*/
- protected void parseSchemaForXMLSchema(DescriptionElement desc) {
+ protected void parseSchemaForXMLSchema(DescriptionElement desc) throws
WSDLException{
//This method is subject to reevaluation and a different approach,
//so the default implementation is empty.
//Subclasses can override this to do something useful.
Modified:
incubator/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL:
http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java?view=diff&rev=563158&r1=563157&r2=563158
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java
(original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java
Mon Aug 6 07:53:26 2007
@@ -530,7 +530,7 @@
}
}
- protected void parseSchemaForXMLSchema(DescriptionElement desc) {
+ protected void parseSchemaForXMLSchema(DescriptionElement desc) throws
WSDLException {
// Parse the schema for schema to include the built in schema types in
the Woden model.
// TODO: As there are a finite number of built in schema types it may
be better to create
@@ -541,10 +541,14 @@
// model programmatically.
// This method should be reevaluated at a later point.
TypesElement types = desc.getTypesElement();
+ if (types == null) {
+ types = desc.addTypesElement();
+ }
if (types.getTypeSystem() == null)
{
types.setTypeSystem(Constants.TYPE_XSD_2001);
}
+
try
{
Document schemaDoc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Modified:
incubator/woden/trunk/java/src/org/apache/woden/internal/Messages.properties
URL:
http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/Messages.properties?view=diff&rev=563158&r1=563157&r2=563158
==============================================================================
---
incubator/woden/trunk/java/src/org/apache/woden/internal/Messages.properties
(original)
+++
incubator/woden/trunk/java/src/org/apache/woden/internal/Messages.properties
Mon Aug 6 07:53:26 2007
@@ -77,6 +77,7 @@
WSDL522=Could not parse a schema imported from URL "{0}".
WSDL523=The QName of an extension attribute must not be null.
WSDL524=URI resolution failed on URI "{0}".
+WSDL523=Cannot add a new TypesElement as one already exists in the
DescriptionElement.
# ------------ TODO determine if these errors are needed -------------------
Modified:
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java
URL:
http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java?view=diff&rev=563158&r1=563157&r2=563158
==============================================================================
---
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java
(original)
+++
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java
Mon Aug 6 07:53:26 2007
@@ -25,6 +25,8 @@
import javax.xml.namespace.QName;
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.MessageFormatter;
import org.apache.woden.internal.util.ComponentModelBuilder;
import org.apache.woden.wsdl20.Binding;
import org.apache.woden.wsdl20.Description;
@@ -438,11 +440,21 @@
public TypesElement getTypesElement()
{
+ return fTypesElement;
+ }
+
+ public TypesElement addTypesElement() throws WSDLException {
if (fTypesElement == null) {
fTypesElement = new TypesImpl();
fTypesElement.setParentElement(this);
+ return fTypesElement;
+ } else {
+ String msg = new MessageFormatter().formatMessage(
+ null,
+ "WSDL523",
+ new Object[] {});
+ throw new WSDLException(WSDLException.OTHER_ERROR, msg);
}
- return fTypesElement;
}
public InterfaceElement[] getInterfaceElements()
Modified:
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/DescriptionElement.java
URL:
http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/DescriptionElement.java?view=diff&rev=563158&r1=563157&r2=563158
==============================================================================
---
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/DescriptionElement.java
(original)
+++
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/DescriptionElement.java
Mon Aug 6 07:53:26 2007
@@ -19,6 +19,7 @@
import java.net.URI;
import java.util.Map;
+import org.apache.woden.WSDLException;
import org.apache.woden.wsdl20.Description;
import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
@@ -198,13 +199,21 @@
/**
* Return the TypesElement within this DescriptionElement.
* This corresponds to the <types> element within the
<description> element.
- * If no TypesElement exists, one will be created with this
DescriptionElement as its parent.
- * <p>
- * TODO modify this behaviour to return null if none exists and define a
new factory method called createTypesElement() WODEN-141
+ * If no TypesElement exists, this method will return null.
*
* @return the TypesElement
*/
public TypesElement getTypesElement();
+
+ /**
+ * Create a TypesElement with this DescriptionElement as its parent and
+ * return a reference to it.
+ * If a TypesElement already exists for this DescriptionElement a
WSDLException will be thrown.
+ *
+ * @return the TypesElement
+ */
+ public TypesElement addTypesElement() throws WSDLException;
+
/**
* Return the set of InterfaceElements within this DescriptionElement.
Modified:
incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
URL:
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java?view=diff&rev=563158&r1=563157&r2=563158
==============================================================================
---
incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
(original)
+++
incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
Mon Aug 6 07:53:26 2007
@@ -1006,7 +1006,7 @@
schemaNS = new URI("http://www.sample.org");
schema.setSchemaDefinition(xs1);
schema.setNamespace(schemaNS);
- TypesElement types = new DescriptionImpl().getTypesElement();
+ TypesElement types = new DescriptionImpl().addTypesElement();
types.addSchema(schema);
}
catch(Exception e)
@@ -1019,7 +1019,7 @@
try
{
DescriptionElement descElem = new DescriptionImpl();
- TypesElement types = descElem.getTypesElement();
+ TypesElement types = descElem.addTypesElement();
types.addSchema(schema);
if(!val.testAssertionSchema1066(descElem, null, reporter))
@@ -1038,7 +1038,7 @@
try
{
DescriptionElement descElem = new DescriptionImpl();
- TypesElement types = descElem.getTypesElement();
+ TypesElement types = descElem.addTypesElement();
types.addSchema(schema);
if(!val.testAssertionSchema1066(descElem, new
QName("http://www.sample.org", "myElement"), reporter))
@@ -1057,7 +1057,7 @@
try
{
DescriptionElement descElem = new DescriptionImpl();
- TypesElement typesImported = descElem.getTypesElement();
+ TypesElement typesImported = descElem.addTypesElement();
ImportedSchema importedSchema = new ImportedSchemaImpl();
importedSchema.setSchemaDefinition(xs1);
importedSchema.setNamespace(schemaNS);
@@ -1115,7 +1115,7 @@
try
{
DescriptionElement descElem = new DescriptionImpl();
- TypesElement typesImported = descElem.getTypesElement();
+ TypesElement typesImported = descElem.addTypesElement();
InlinedSchema inlinedSchema = new InlinedSchemaImpl();
typesImported.addSchema(inlinedSchema);
InlinedSchema inlinedSchema2 = new InlinedSchemaImpl();
Modified:
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java
URL:
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java?view=diff&rev=563158&r1=563157&r2=563158
==============================================================================
---
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java
(original)
+++
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java
Mon Aug 6 07:53:26 2007
@@ -62,7 +62,7 @@
fInterfaceElement.setName(new NCName("interfaceName"));
fServiceElement = fDescriptionElement.addServiceElement();
fServiceElement.setName(new NCName("serviceName"));
- fDescriptionElement.getTypesElement(); // create a TypesElement
+ fDescriptionElement.addTypesElement(); // create a TypesElement
// TODO check the following are not too contrived...
// 1:
Modified:
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptiontElementTest.java
URL:
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptiontElementTest.java?view=diff&rev=563158&r1=563157&r2=563158
==============================================================================
---
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptiontElementTest.java
(original)
+++
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptiontElementTest.java
Mon Aug 6 07:53:26 2007
@@ -26,6 +26,7 @@
import org.apache.woden.internal.wsdl20.DescriptionImpl;
import org.apache.woden.wsdl20.Description;
import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+import org.apache.woden.WSDLException;
/**
* Unit tests for the DescriptionElement class.
@@ -154,6 +155,14 @@
public void testGetTypesElement() {
// check first getTypesElement invocation...
TypesElement typesElement =
fDescriptionElement.getTypesElement();
+ assertNull("Method returned TypesElement but expected null",
typesElement);
+
+ // now create a new TypesElement
+ try {
+ typesElement = fDescriptionElement.addTypesElement();
+ } catch (WSDLException e) {
+ fail("Method could not create a new TypesElement as one
already exists.");
+ }
assertNotNull("Method returned null but expected a
TypesElement", typesElement);
if (typesElement != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]