You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-dev@ws.apache.org by ip...@apache.org on 2004/12/08 22:54:12 UTC

svn commit: r111315 - in incubator/apollo/trunk/src/java/org/apache/ws/resource/properties: . impl porttype/impl

Author: ips
Date: Wed Dec  8 13:54:06 2004
New Revision: 111315

URL: http://svn.apache.org/viewcvs?view=rev&rev=111315
Log:
updateProp and insertProp now validate that all prop elems have the same name

Modified:
   incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/MetaDataViolationException.java
   incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourceProperty.java
   incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java
   incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java

Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/MetaDataViolationException.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/MetaDataViolationException.java?view=diff&rev=111315&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/MetaDataViolationException.java&r1=111314&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/MetaDataViolationException.java&r2=111315
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/MetaDataViolationException.java	(original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/MetaDataViolationException.java	Wed Dec  8 13:54:06 2004
@@ -15,16 +15,15 @@
  *=============================================================================*/
 package org.apache.ws.resource.properties;
 
-
 /**
- * LOG-DONE
  * Indicates a violation of the metadata constraints associated with a resource properties document.
  *
  * @author Ian P. Springer
  */
 public class MetaDataViolationException
-   extends Exception
+   extends RuntimeException
 {
+
    /**
     * Creates a new {@link MetaDataViolationException} object.
     *
@@ -34,4 +33,5 @@
    {
       super( message );
    }
+
 }

Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourceProperty.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourceProperty.java?view=diff&rev=111315&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourceProperty.java&r1=111314&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourceProperty.java&r2=111315
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourceProperty.java	(original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourceProperty.java	Wed Dec  8 13:54:06 2004
@@ -52,8 +52,10 @@
      * Adds a value.
      *
      * @param value the value to add.
+     *
+     * @throws MetaDataViolationException if the name of the element to be added does not match the name associated with this property
      */
-    void add( Object value ) throws MetaDataViolationException;        
+    void add( Object value );
 
     /**
      * Removes all values.
@@ -83,8 +85,7 @@
      *
      * @return true if, and only if, a property element was removed
      */
-    boolean remove( Object value )
-            throws MetaDataViolationException;
+    boolean remove( Object value );
 
     /**
      * Sets a value at a specific index.
@@ -92,9 +93,7 @@
      * @param index the index to set value at.
      * @param value the new value
      */
-    void set( int index,
-              Object value )
-            throws MetaDataViolationException;
+    void set( int index, Object value );
 
     /**
      * Returns the number of values in the resource property.
@@ -112,8 +111,7 @@
      *
      * @throws SerializationException if conversion fails
      */
-    Element[] toElements()
-            throws SerializationException;
+    Element[] toElements() throws SerializationException;
 
     /**
      * Converts the resource property value into an array of {@link SOAPElement}s. If the RP has no values (is null),
@@ -124,8 +122,7 @@
      *
      * @throws SerializationException if conversion fails
      */
-    SOAPElement[] toSOAPElements()
-            throws SerializationException;
+    SOAPElement[] toSOAPElements() throws SerializationException;
 
     /**
      * Returns the XML representation of this property (i.e. the resource property elements).

Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java?view=diff&rev=111315&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java&r1=111314&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java&r2=111315
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java	(original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java	Wed Dec  8 13:54:06 2004
@@ -113,8 +113,10 @@
     * DOCUMENT_ME
     *
     * @param propElem DOCUMENT_ME
+    *
+    * @throws MetaDataViolationException if the name of the element to be added does not match the name associated with this property
     */
-   public void add( Object propElem ) throws MetaDataViolationException
+   public void add( Object propElem )
    {
       XmlObject propXBean = toPropXBean( propElem );
       trimValue( propXBean );
@@ -161,9 +163,10 @@
     * to populate newly created {@link XmlBeansResourceProperty} objects.
     *
     * @param propXBean a property element XMLBean that is already in the resource properties document
+    *
+    * @throws MetaDataViolationException if the name of the element to be added does not match the name associated with this property
     */
    public void load( XmlObject propXBean )
-   throws MetaDataViolationException
    {
       if ( !XmlBeanUtils.getName( propXBean ).equals( m_metaData.getName(  ) ) )
       {

Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java?view=diff&rev=111315&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java&r1=111314&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java&r2=111315
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java	(original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java	Wed Dec  8 13:54:06 2004
@@ -116,36 +116,24 @@
      */
     protected void deleteResourceProperty( DeleteType deleteElem )
     {
-
         if ( LOG.isDebugEnabled() )
         {
             LOG.debug( MSG.getMessage( Keys.DEL_RP_REQ,
                     deleteElem.toString() ) );
         }
-
         QName nameOfPropToBeDeleted = deleteElem.getResourceProperty();
         if ( nameOfPropToBeDeleted == null )
         {
             throw new InvalidSetResourcePropertiesRequestContentFaultException( MSG.getMessage( Keys.DEL_MISSING_RP_ATTRIB ) );
         }
-
         ResourceProperty prop = getProperties().get( nameOfPropToBeDeleted );
-
         if ( prop == null )
         {
             throw new InvalidResourcePropertyQNameFaultException( nameOfPropToBeDeleted );
         }
-
         throwFaultIfPropertyIsReadOnly( prop );
-
-        if ( prop.getMetaData().getMinOccurs() != 0 )
-        {
-            throw new InvalidSetResourcePropertiesRequestContentFaultException( MSG.getMessage( Keys.ERROR_PROPERTY_DELETE_VIOLATES_SCHEMA,
-                      nameOfPropToBeDeleted ) );
-        }
-
+        throwFaultIfDeletionViolatesSchema( prop );
         //refreshProperty( prop );
-
         try
         {
             deletePropertyCallback( prop );
@@ -154,9 +142,7 @@
         {
             throw new SetResourcePropertyRequestFailedFaultException( re.toString() );
         }
-
         prop.clear();
-
     }
 
     /**
@@ -184,13 +170,8 @@
         //refreshProperty( prop );
 
         throwFaultIfPropertyIsReadOnly( prop );
-        if ( ( prop.size() + propElemsToBeInserted.length ) > prop.getMetaData().getMaxOccurs() )
-        {
-            throw new InvalidSetResourcePropertiesRequestContentFaultException( MSG.getMessage( Keys.ERROR_PROPERTY_INSERT_VIOLATES_SCHEMA,
-                    ( ( propElemsToBeInserted.length > 1 )
-                    ? "s" : "" ),
-                    propName ) );
-        }
+        throwFaultIfElementNamesHeterogenous( propElemsToBeInserted );
+        throwFaultIfInsertionViolatesSchema( prop, propElemsToBeInserted );
 
         try
         {
@@ -239,11 +220,8 @@
         //refreshProperty( prop );
 
         throwFaultIfPropertyIsReadOnly( prop );
-        if ( prop.getMetaData().getMaxOccurs() != -1 && newPropElems.length > prop.getMetaData().getMaxOccurs() )
-        {
-            throw new InvalidSetResourcePropertiesRequestContentFaultException( MSG.getMessage( Keys.ERROR_PROPERTY_UPDATE_VIOLATES_SCHEMA,
-                    propName ) );
-        }
+        throwFaultIfElementNamesHeterogenous( newPropElems );
+        throwFaultIfUpdateViolatesSchema( prop, newPropElems );
 
         try
         {
@@ -288,6 +266,51 @@
         return prop;
     }
 
+    private void throwFaultIfElementNamesHeterogenous( XmlObject[] propElems )
+    {
+        QName firstPropElemName = XmlBeanUtils.getName( propElems[0] );
+        for ( int i = 1; i < propElems.length; i++ )
+        {
+            QName propElemName = XmlBeanUtils.getName( propElems[i] );
+            if ( !firstPropElemName.equals( propElemName ) )
+            {
+                throw new InvalidSetResourcePropertiesRequestContentFaultException( MSG.getMessage( Keys.ERROR_PROPERTY_INSERT_VIOLATES_SCHEMA,
+                        ( ( propElems.length > 1 )
+                        ? "s" : "" ),
+                        firstPropElemName ) );
+            }
+        }
+    }
+
+    private void throwFaultIfDeletionViolatesSchema( ResourceProperty prop )
+    {
+        if ( prop.getMetaData().getMinOccurs() != 0 )
+        {
+            throw new InvalidSetResourcePropertiesRequestContentFaultException( MSG.getMessage( Keys.ERROR_PROPERTY_DELETE_VIOLATES_SCHEMA,
+                    prop.getMetaData().getName() ) );
+        }
+    }
+
+    private void throwFaultIfInsertionViolatesSchema( ResourceProperty prop, XmlObject[] propElemsToBeInserted )
+    {
+        if ( ( prop.size() + propElemsToBeInserted.length ) > prop.getMetaData().getMaxOccurs() )
+        {
+            throw new InvalidSetResourcePropertiesRequestContentFaultException( MSG.getMessage( Keys.ERROR_PROPERTY_INSERT_VIOLATES_SCHEMA,
+                    ( ( propElemsToBeInserted.length > 1 )
+                    ? "s" : "" ),
+                    prop.getMetaData().getName() ) );
+        }
+    }
+
+    private void throwFaultIfUpdateViolatesSchema( ResourceProperty prop, XmlObject[] newPropElems )
+    {
+        if ( prop.getMetaData().getMaxOccurs() != -1 && newPropElems.length > prop.getMetaData().getMaxOccurs() )
+        {
+            throw new InvalidSetResourcePropertiesRequestContentFaultException( MSG.getMessage( Keys.ERROR_PROPERTY_UPDATE_VIOLATES_SCHEMA,
+                    prop.getMetaData().getName() ) );
+        }
+    }
+
     /**
      * Returns SetResourcePropertyCallback or null
      *
@@ -326,7 +349,7 @@
     }
 
     private void insertPropertyCallback( ResourceProperty prop,
-                                 XmlObject[] propElemsToBeInserted )
+                                         XmlObject[] propElemsToBeInserted )
     {
         SetResourcePropertyCallback setResourcePropertyCallback = getSetResourcePropertyCallback( prop );
         if ( setResourcePropertyCallback != null )
@@ -344,7 +367,7 @@
     }
 
     private void updatePropertyCallback( ResourceProperty prop,
-                                 XmlObject[] newPropElems )
+                                         XmlObject[] newPropElems )
     {
         SetResourcePropertyCallback setResourcePropertyCallback = getSetResourcePropertyCallback( prop );
         if ( setResourcePropertyCallback != null )

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