You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2006/12/08 21:30:39 UTC

svn commit: r484752 - in /webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource: impl/ properties/impl/ properties/schema/impl/

Author: danj
Date: Fri Dec  8 12:30:37 2006
New Revision: 484752

URL: http://svn.apache.org/viewvc?view=rev&rev=484752
Log:
Part of fix for MUSE-100

Modified:
    webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/impl/SimpleWsResource.java
    webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties
    webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java
    webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/WsrpUtils.java
    webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/PropertySchemaDefinition.java
    webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/SimpleResourcePropertiesSchema.java

Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/impl/SimpleWsResource.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/impl/SimpleWsResource.java?view=diff&rev=484752&r1=484751&r2=484752
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/impl/SimpleWsResource.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/impl/SimpleWsResource.java Fri Dec  8 12:30:37 2006
@@ -127,7 +127,7 @@
         // find the element that corresponds to the WS-RP name
         // 
         QName wsrpName = WsrpUtils.getPropertiesName(wsdl, getWsdlPortType());
-        Element wsrpDoc = WsdlUtils.getTypeDeclaration(wsdl, wsrpName);
+        Element wsrpDoc = WsdlUtils.getElementDeclaration(wsdl, wsrpName);
         
         if (wsrpDoc == null) 
         {

Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties?view=diff&rev=484752&r1=484751&r2=484752
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties Fri Dec  8 12:30:37 2006
@@ -6,7 +6,7 @@
 BelowMinimum=The property 'XXX' has a minOccurs value of XXX, but there are only XXX instances in the document.
 NullQNameArray=The QName array is null.
 NullWSDLDocument=The WSDL Document reference is null.
-NotNillable=The property 'XXX' is not nillable, but there is an instance of it with no child nodes (a null value).
+NotNillable=The property 'XXX' is not nillable, but there is an instance of it with no child nodes, attributes, or text (a null value).
 NullValuesArray=The array of property values is null. If you want to set properties to null, you still need a valid array - just add null value(s) to it.
 NoInstancesToDelete=There are no instances of the property 'XXX', so it cannot be deleted.
 NullMetadataDescriptor=The MetadataDescriptor is null.

Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java?view=diff&rev=484752&r1=484751&r2=484752
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java Fri Dec  8 12:30:37 2006
@@ -1108,18 +1108,9 @@
         }
         
         //
-        // are we trying to set to null when we shouldn't be?
+        // not nillable yet still null?
         //
-        boolean isNillable = schema.isNillable(qname);
-        
-        for (int n = 0; n < values.length; ++n)
-        {
-            if (!isNillable && !values[n].hasChildNodes())
-            {
-                Object[] filler = { qname };
-                throw new SchemaValidationFault(_MESSAGES.get("NotNillable", filler));
-            }
-        }
+        validateNillable(qname, values, schema.isNillable(qname));
     }
     
     public synchronized void validateMetadata()
@@ -1159,6 +1150,25 @@
         }
     }
     
+    protected void validateNillable(QName qname, Element[] instances, boolean isNillable)
+        throws SchemaValidationFault
+    {
+        if (isNillable)
+            return;
+        
+        for (int n = 0; n < instances.length; ++n)
+        {
+            //
+            // check for child elements, attributes, and text, all of 
+            // which qualify an element as "not null"
+            //
+            if (!instances[n].hasChildNodes() && 
+                !instances[n].hasAttributes() && 
+                XmlUtils.extractText(instances[n]) == null)
+                throw new SchemaValidationFault(_MESSAGES.get("NotNillable", new Object[]{ qname }));
+        }
+    }
+    
     public synchronized void validateSchema()
         throws BaseFault
     {        
@@ -1180,9 +1190,7 @@
             
             int max = schema.getMaxOccurs(qname);
             boolean maxUnbounded = schema.isMaxUnbounded(qname);
-            
             int min = schema.getMinOccurs(qname);
-            
             boolean isNillable = schema.isNillable(qname);
             
             //
@@ -1213,24 +1221,11 @@
             }
             
             //
+            // not nillable yet still null?
+            ////
             // are any instances null that shouldn't be?
             //
-            String message = _MESSAGES.get("NotNillable", new Object[]{ qname });
-            
-            if (!isNillable)
-            {
-                for (int n = 0; n < instances.length; ++n)
-                {
-                    //
-                    // check for child elements, attributes, and text, all of 
-                    // which qualify an element as "not null"
-                    //
-                    if (!instances[n].hasChildNodes() && 
-                        !instances[n].hasAttributes() && 
-                        XmlUtils.extractText(instances[n]) == null)
-                        throw new SchemaValidationFault(message);
-                }
-            }
+            validateNillable(qname, instances, isNillable);
         }
     }
 }

Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/WsrpUtils.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/WsrpUtils.java?view=diff&rev=484752&r1=484751&r2=484752
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/WsrpUtils.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/WsrpUtils.java Fri Dec  8 12:30:37 2006
@@ -154,7 +154,7 @@
      *         is a sequence of other XSD elements that use the <em>ref</em> 
      *         attribute to define their types.
      *         
-     * @see WsdlUtils#getTypeDeclaration(Node, QName)
+     * @see WsdlUtils#getElementDeclaration(Node, QName)
      *
      */
     public static QName getPropertiesName(Node wsdl, QName portType)

Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/PropertySchemaDefinition.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/PropertySchemaDefinition.java?view=diff&rev=484752&r1=484751&r2=484752
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/PropertySchemaDefinition.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/PropertySchemaDefinition.java Fri Dec  8 12:30:37 2006
@@ -128,7 +128,7 @@
         // finally, scan the whole wsdl:types for the type definition
         //
         Document doc = definition.getOwnerDocument();
-        Element typeDeclaration = WsdlUtils.getTypeDeclaration(doc, _qname);
+        Element typeDeclaration = WsdlUtils.getElementDeclaration(doc, _qname);
         
         if (typeDeclaration == null)
         {

Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/SimpleResourcePropertiesSchema.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/SimpleResourcePropertiesSchema.java?view=diff&rev=484752&r1=484751&r2=484752
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/SimpleResourcePropertiesSchema.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/schema/impl/SimpleResourcePropertiesSchema.java Fri Dec  8 12:30:37 2006
@@ -32,6 +32,7 @@
 import org.apache.muse.ws.resource.WsResourceCapability;
 import org.apache.muse.ws.resource.properties.WsrpConstants;
 import org.apache.muse.ws.resource.properties.schema.ResourcePropertiesSchema;
+import org.apache.muse.ws.wsdl.WsdlUtils;
 
 /**
  *
@@ -129,16 +130,76 @@
      *        The DOM Element containing the WS-RP document definition.
      * 
      * @return All of the child xsd:element Elements that have a <em>ref</em> 
-     *         attribute { complexType/sequence/element[@ref] }.
+     *         attribute { complexType/sequence/element[@ref] }, including 
+     *         those in the schema's base types.
      *
      */
     private Element[] getAllPropertyElements(Element wsrpElement)
     {
-        Element complexType = 
-            XmlUtils.getElement(wsrpElement, XsdUtils.COMPLEX_TYPE_QNAME);
-        Element sequence = 
-            XmlUtils.getElement(complexType, XsdUtils.SEQUENCE_QNAME);
-        return XmlUtils.getElements(sequence, XsdUtils.ELEMENT_QNAME);
+        Element complexType = XmlUtils.getElement(wsrpElement, XsdUtils.COMPLEX_TYPE_QNAME);
+        
+        //
+        // if the complexType isn't under the element, there must be a type 
+        // attribute that tells us where the definition is
+        //
+        if (complexType == null)
+        {
+            Element wsdl = XmlUtils.getDocumentRoot(wsrpElement);
+            
+            String typeName = wsrpElement.getAttribute(XsdUtils.TYPE);
+            QName typeQName = XmlUtils.parseQName(typeName, wsrpElement);
+            
+            //
+            // search the <wsdl:types/> for the WSRP type def
+            //
+            complexType = WsdlUtils.getComplexTypeDeclaration(wsdl, typeQName);
+        }
+        
+        Element sequence = XmlUtils.getElement(complexType, XsdUtils.SEQUENCE_QNAME);
+        
+        if (sequence != null)
+            return XmlUtils.getElements(sequence, XsdUtils.ELEMENT_QNAME);
+        
+        return getBasePropertyElements(complexType);
+    }
+    
+    private Element[] getBasePropertyElements(Element complexType)
+    {
+        Element sequence = XmlUtils.getElement(complexType, XsdUtils.SEQUENCE_QNAME);
+        
+        //
+        // complexType has no parent type - just return its elements
+        //
+        if (sequence != null)
+            return XmlUtils.getElements(sequence, XsdUtils.ELEMENT_QNAME);
+        
+        Element wsdl = XmlUtils.getDocumentRoot(complexType);
+        
+        Element complexContent = XmlUtils.getElement(complexType, XsdUtils.COMPLEX_CONTENT_QNAME);
+        Element extension = XmlUtils.getElement(complexContent, XsdUtils.EXTENSION_QNAME);
+        
+        //
+        // otherwise, get the parent type and its elements...
+        //
+        String base = extension.getAttribute(XsdUtils.BASE);
+        QName baseName = XmlUtils.parseQName(base, extension);
+        Element baseType = WsdlUtils.getComplexTypeDeclaration(wsdl, baseName);
+        Element[] baseProperties = getBasePropertyElements(baseType);
+        
+        //
+        // ...now get our own elements...
+        //
+        sequence = XmlUtils.getElement(extension, XsdUtils.SEQUENCE_QNAME);
+        Element[] childProperties = XmlUtils.getElements(sequence, XsdUtils.ELEMENT_QNAME);
+        
+        //
+        // ...and combine the two into one big array
+        //
+        Element[] allProperties = new Element[baseProperties.length + childProperties.length];
+        System.arraycopy(baseProperties, 0, allProperties, 0, baseProperties.length);
+        System.arraycopy(childProperties, 0, allProperties, baseProperties.length, childProperties.length);
+        
+        return allProperties;
     }
     
     public WsResourceCapability getCapability(QName property)



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org