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 sc...@apache.org on 2006/06/02 19:33:13 UTC

svn commit: r411218 [15/34] - in /webservices/muse: branches/1.0/ branches/1.0/src/examples/broker/ branches/1.0/src/examples/broker/WEB-INF/ branches/1.0/src/examples/consumer/ branches/1.0/src/examples/consumer/epr/ branches/1.0/src/examples/consumer...

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UnableToModifyResourcePropertyFaultException.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UnableToModifyResourcePropertyFaultException.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UnableToModifyResourcePropertyFaultException.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UnableToModifyResourcePropertyFaultException.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,73 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.faults;
+
+import org.apache.ws.resource.faults.AbstractBaseFaultException;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.resource.properties.NamespaceVersionHolder;
+import org.apache.ws.util.i18n.Messages;
+import javax.xml.namespace.QName;
+
+/**
+ * LOG-DONE WS-ResourceProperties UnableToModifyResourceProperty fault type implemented as a Java exception.
+ *
+ * @author Ian P. Springer
+ */
+public class UnableToModifyResourcePropertyFaultException
+   extends AbstractBaseFaultException
+{
+   private static final Messages MSG        = MessagesImpl.getInstance(  );
+   private QName                 m_name;
+   private QName                 m_propName;
+
+   /**
+    * Constructs a new UnableToModifyResourcePropertyFaultException.
+    *
+    * @param propName the name of the read-only property that the user attempted to modify
+    */
+   public UnableToModifyResourcePropertyFaultException( NamespaceVersionHolder namespaces,
+                                                        QName                  propName )
+   {
+      super( namespaces,
+             MSG.getMessage( Keys.READ_ONLY_PROP, propName ) );
+      m_propName    = propName;
+      m_name =
+         new QName( namespaces.getPropertiesXsdNamespace(  ),
+                    "UnableToModifyResourcePropertyFault",
+                    "wsrp" );
+   }
+
+   /**
+    * Returns the element name for this base fault.
+    *
+    * @return the element name for this base fault
+    */
+   public QName getBaseFaultName(  )
+   {
+      return m_name;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public QName getPropertyName(  )
+   {
+      return m_propName;
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UnknownQueryExpressionDialectFaultException.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UnknownQueryExpressionDialectFaultException.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UnknownQueryExpressionDialectFaultException.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UnknownQueryExpressionDialectFaultException.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,73 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.faults;
+
+import org.apache.ws.resource.faults.AbstractBaseFaultException;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.resource.properties.NamespaceVersionHolder;
+import org.apache.ws.util.i18n.Messages;
+import javax.xml.namespace.QName;
+import java.net.URI;
+
+/**
+ * LOG-DONE WS-ResourceProperties UnknownQueryExpressionDialect fault type implemented as a Java exception.
+ *
+ * @author Ian P. Springer
+ */
+public class UnknownQueryExpressionDialectFaultException
+   extends AbstractBaseFaultException
+{
+   private static final Messages MSG       = MessagesImpl.getInstance(  );
+   private QName                 m_name;
+   private URI                   m_dialect;
+
+   /**
+    * Constructs a new BaseFaultException with the specified SOAP message and actor.
+    *
+    * @param dialect the URI of the unsupported dialect
+    */
+   public UnknownQueryExpressionDialectFaultException( NamespaceVersionHolder namespaces,
+                                                       URI                    dialect )
+   {
+      super( namespaces,
+             MSG.getMessage( Keys.DIALECT, dialect ) );
+      m_name    = new QName( namespaces.getPropertiesXsdNamespace(  ),
+                             "UnknownQueryExpressionDialectFault",
+                             "wsrp" );
+      m_dialect = dialect;
+   }
+
+   /**
+    * Returns the element name for this base fault.
+    *
+    * @return the element name for this base fault
+    */
+   public QName getBaseFaultName(  )
+   {
+      return m_name;
+   }
+
+   /**
+    * Returns the URI of the unsupported dialect.
+    *
+    * @return the URI of the unsupported dialect
+    */
+   public URI getDialect(  )
+   {
+      return m_dialect;
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UpdateResourcePropertyRequestFailedFaultException.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UpdateResourcePropertyRequestFailedFaultException.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UpdateResourcePropertyRequestFailedFaultException.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/faults/UpdateResourcePropertyRequestFailedFaultException.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,57 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.faults;
+
+import org.apache.ws.resource.faults.AbstractBaseFaultException;
+import org.apache.ws.resource.faults.Description;
+import org.apache.ws.resource.properties.NamespaceVersionHolder;
+import javax.xml.namespace.QName;
+
+/**
+ * @author Sal Campana
+ */
+public class UpdateResourcePropertyRequestFailedFaultException
+   extends AbstractBaseFaultException
+{
+   private QName m_name;
+
+   /**
+    * Creates a new {@link UpdateResourcePropertyRequestFailedFaultException} object.
+    *
+    * @param namespaces  DOCUMENT_ME
+    * @param description DOCUMENT_ME
+    */
+   public UpdateResourcePropertyRequestFailedFaultException( NamespaceVersionHolder namespaces,
+                                                             Description[]          description )
+   {
+      super( namespaces, "" );
+      m_name =
+         new QName( namespaces.getPropertiesXsdNamespace(  ),
+                    "UpdateResourcePropertyRequestFailedFault",
+                    "wsrf-rp" );
+      setDescription( description );
+   }
+
+   /**
+    * Returns the element name for this base fault.
+    *
+    * @return the element name for this base fault
+    */
+   public QName getBaseFaultName(  )
+   {
+      return m_name;
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractGetResourcePropertiesPortType.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractGetResourcePropertiesPortType.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractGetResourcePropertiesPortType.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractGetResourcePropertiesPortType.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,133 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.resource.properties.NamespaceVersionHolder;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.faults.InvalidResourcePropertyQNameFaultException;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.xmlbeans.XmlObject;
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * A version-neutral base class that is extended by all impls of GetRP and GetMultipleRPs portTypes.
+ *
+ * @author Ian Springer
+ */
+public abstract class AbstractGetResourcePropertiesPortType
+   extends AbstractResourcePropertiesPortType
+{
+   private static final Log      LOG = LogFactory.getLog( AbstractGetResourcePropertiesPortType.class );
+   private static final Messages MSG = MessagesImpl.getInstance(  );
+
+   /**
+    * Creates a new {@link AbstractGetResourcePropertiesPortType} object.
+    *
+    * @param resourceContext DOCUMENT_ME
+    */
+   protected AbstractGetResourcePropertiesPortType( ResourceContext resourceContext )
+   {
+      super( resourceContext );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propNames DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected ResourceProperty[] getMultipleProperties( QName[] propNames )
+   {
+      ResourceProperty[] props = new ResourceProperty[propNames.length];
+      for ( int i = 0; i < propNames.length; i++ )
+      {
+         props[i] = getProperty( propNames[i] );
+      }
+
+      return props;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected abstract NamespaceVersionHolder getNamespaceSet(  );
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propName DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected ResourceProperty getProperty( QName propName )
+   {
+      if ( LOG.isDebugEnabled(  ) )
+      {
+         LOG.debug( MSG.getMessage( Keys.GET_RP_REQ, propName ) );
+      }
+
+      ResourceProperty prop = getProperties(  ).get( propName );
+      if ( prop == null )
+      {
+         throw new InvalidResourcePropertyQNameFaultException( getNamespaceSet(  ), propName );
+      }
+
+      refreshProperty( prop );
+      return prop;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param props DOCUMENT_ME
+    * @param response DOCUMENT_ME
+    */
+   protected void addPropertiesToResponse( ResourceProperty[] props,
+                                           XmlObject          response )
+   {
+      for ( int i = 0; i < props.length; i++ )
+      {
+         addPropertyToResponse( props[i], response );
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param prop DOCUMENT_ME
+    * @param response DOCUMENT_ME
+    */
+   protected void addPropertyToResponse( ResourceProperty prop,
+                                         XmlObject        response )
+   {
+      Iterator propElemIter = prop.iterator(  );
+      while ( propElemIter.hasNext(  ) )
+      {
+         XmlObject propElem = (XmlObject) propElemIter.next(  );
+         XmlBeanUtils.addChildElement( response, propElem );
+      }
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractResourcePropertiesPortType.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractResourcePropertiesPortType.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractResourcePropertiesPortType.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractResourcePropertiesPortType.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,104 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.Soap1_1Constants;
+import org.apache.ws.resource.AbstractPortType;
+import org.apache.ws.resource.PropertiesResource;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.ResourcePropertyCallback;
+import org.apache.ws.resource.properties.ResourcePropertySet;
+import org.apache.ws.resource.properties.faults.ResourcePropertyRetrievalFailedFaultException;
+import org.apache.ws.util.i18n.Messages;
+import java.util.Iterator;
+
+/**
+ * A version-neutral base class that is extended by all portType impls that make use of resource properties.
+ *
+ * @author Ian Springer
+ */
+public abstract class AbstractResourcePropertiesPortType
+   extends AbstractPortType
+{
+   private static final Log      LOG = LogFactory.getLog( AbstractResourcePropertiesPortType.class );
+   private static final Messages MSG = MessagesImpl.getInstance(  );
+
+   /**
+    * Creates a new {@link AbstractResourcePropertiesPortType} object.
+    *
+    * @param resourceContext DOCUMENT_ME
+    */
+   protected AbstractResourcePropertiesPortType( ResourceContext resourceContext )
+   {
+      super( resourceContext );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected final ResourcePropertySet getProperties(  )
+   {
+      if ( !( getResource(  ) instanceof PropertiesResource ) )
+      {
+         throw new IllegalStateException( MSG.getMessage( Keys.CALL_WSRP_OP_ON_NOPROP ) );
+      }
+
+      return ( (PropertiesResource) getResource(  ) ).getResourcePropertySet(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    */
+   protected void refreshAllProperties(  )
+   {
+      Iterator iterator = getProperties(  ).iterator(  );
+      while ( iterator.hasNext(  ) )
+      {
+         refreshProperty( (ResourceProperty) iterator.next(  ) );
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param prop DOCUMENT_ME
+    */
+   protected void refreshProperty( ResourceProperty prop )
+   {
+      ResourcePropertyCallback callBack = prop.getCallBack(  );
+      if ( callBack != null )
+      {
+         try
+         {
+            callBack.refreshProperty( prop );
+         }
+         catch ( Exception e )
+         {
+            LOG.debug( "Refresh Callback Failed", e );
+            throw new ResourcePropertyRetrievalFailedFaultException( getNamespaceSet(  ),
+                                                                     e.getLocalizedMessage(  ),
+                                                                     Soap1_1Constants.FAULT_SERVER );
+         }
+      }
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractSetResourcePropertiesPortType.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractSetResourcePropertiesPortType.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractSetResourcePropertiesPortType.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractSetResourcePropertiesPortType.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,439 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.resource.properties.MetaDataViolationException;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.ResourcePropertyCallback;
+import org.apache.ws.resource.properties.ResourcePropertyMetaData;
+import org.apache.ws.resource.properties.ResourcePropertyValueChangeListener;
+import org.apache.ws.resource.properties.SetResourcePropertyCallback;
+import org.apache.ws.resource.properties.faults.DeleteResourcePropertyRequestFailedFaultException;
+import org.apache.ws.resource.properties.faults.InvalidInsertResourcePropertiesRequestContentFaultException;
+import org.apache.ws.resource.properties.faults.InvalidResourcePropertyQNameFaultException;
+import org.apache.ws.resource.properties.faults.InvalidSetResourcePropertiesRequestContentFaultException;
+import org.apache.ws.resource.properties.faults.InvalidUpdateResourcePropertiesRequestContentFaultException;
+import org.apache.ws.resource.properties.faults.SetResourcePropertyRequestFailedFaultException;
+import org.apache.ws.resource.properties.faults.UnableToModifyResourcePropertyFaultException;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.xmlbeans.XmlObject;
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * A version-neutral base class that is extended by all impls of SetRP, InsertRPs, DeleteRPs, and UpdateRPs portTypes.
+ *
+ * @author Ian Springer
+ */
+public abstract class AbstractSetResourcePropertiesPortType
+   extends AbstractResourcePropertiesPortType
+{
+   private static final Log      LOG = LogFactory.getLog( AbstractSetResourcePropertiesPortType.class );
+   private static final Messages MSG = MessagesImpl.getInstance(  );
+
+   /**
+    * Creates a new {@link AbstractSetResourcePropertiesPortType} object.
+    *
+    * @param resourceContext DOCUMENT_ME
+    */
+   protected AbstractSetResourcePropertiesPortType( ResourceContext resourceContext )
+   {
+      super( resourceContext );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param oldValue DOCUMENT_ME
+    * @param newValue DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected abstract AbstractXmlBeansResourcePropertyValueChangeEvent getResourcePropertyValueChangeEvent( Object[] oldValue,
+                                                                                                            Object[] newValue );
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param nameOfPropToBeDeleted name of property to be deleted
+    */
+   protected void deleteResourceProperty( QName nameOfPropToBeDeleted )
+   {
+      if ( LOG.isDebugEnabled(  ) )
+      {
+         LOG.debug( MSG.getMessage( Keys.DEL_RP_REQ, nameOfPropToBeDeleted ) );
+      }
+
+      if ( nameOfPropToBeDeleted == null )
+      {
+         throw new DeleteResourcePropertyRequestFailedFaultException( getNamespaceSet(  ),
+                                                                      MSG.getMessage( Keys.DEL_MISSING_RP_ATTRIB ) );
+      }
+
+      ResourceProperty prop = getProperties(  ).get( nameOfPropToBeDeleted );
+      if ( prop == null )
+      {
+         if ( getProperties(  ).getMetaData(  ).isOpenContent(  ) )
+         {
+            return;
+         }
+         else
+         {
+            throw new InvalidResourcePropertyQNameFaultException( getNamespaceSet(  ), nameOfPropToBeDeleted );
+         }
+      }
+
+      throwFaultIfPropertyIsReadOnly( prop );
+      throwFaultIfDeletionViolatesSchema( prop );
+      try
+      {
+         deletePropertyCallback( prop );
+      }
+      catch ( RuntimeException re )
+      {
+         throw new DeleteResourcePropertyRequestFailedFaultException( getNamespaceSet(  ),
+                                                                      re.toString(  ) );
+      }
+
+      Object[] oldValue = getValue( prop );
+      prop.clear(  );
+      Object[] newValue = null;
+      firePropChangeEvents( prop, oldValue, newValue );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propElemsToBeInserted DOCUMENT_ME
+    */
+   protected void insertResourceProperty( XmlObject[] propElemsToBeInserted )
+   {
+      if ( LOG.isDebugEnabled(  ) )
+      {
+         LOG.debug( MSG.getMessage( Keys.INSERT_RP_REQ ) );
+      }
+
+      if ( propElemsToBeInserted.length == 0 )
+      {
+         return; // nothing to do
+      }
+
+      if ( elementNamesNotHomogenous( propElemsToBeInserted ) )
+      {
+         throw new InvalidInsertResourcePropertiesRequestContentFaultException( getNamespaceSet(  ),
+                                                                                MSG.getMessage( Keys.ERROR_INSERT_ELEMS_NOT_HOMOGENOUS ) );
+      }
+
+      QName            propName = XmlBeanUtils.getName( propElemsToBeInserted[0] );
+      ResourceProperty prop = getProperty( propName );
+
+      if ( prop == null )
+      {
+         prop = createAnyProperty( propName );
+         getProperties(  ).add( prop );
+      }
+
+      if ( !prop.getMetaData(  ).isAny(  ) )
+      {
+         throwFaultIfInsertionViolatesSchema( prop, propElemsToBeInserted );
+      }
+
+      throwFaultIfPropertyIsReadOnly( prop );
+
+      try
+      {
+         insertPropertyCallback( prop, propElemsToBeInserted );
+      }
+      catch ( RuntimeException re )
+      {
+         throw new SetResourcePropertyRequestFailedFaultException( getNamespaceSet(  ),
+                                                                   re.toString(  ) );
+      }
+
+      Object[] oldValue = getValue( prop );
+      for ( int i = 0; i < propElemsToBeInserted.length; i++ )
+      {
+         try
+         {
+            prop.add( propElemsToBeInserted[i] );
+         }
+         catch ( MetaDataViolationException mdve )
+         {
+            throw new InvalidSetResourcePropertiesRequestContentFaultException( getNamespaceSet(  ), mdve );
+         }
+      }
+
+      Object[] newValue = getValue( prop );
+      firePropChangeEvents( prop, oldValue, newValue );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param newPropElems DOCUMENT_ME
+    */
+   protected void updateResourceProperty( XmlObject[] newPropElems )
+   {
+      if ( LOG.isDebugEnabled(  ) )
+      {
+         LOG.debug( MSG.getMessage( Keys.UPDATE_RP_REQ ) );
+      }
+
+      if ( newPropElems.length == 0 )
+      {
+         return; // nothing to do
+      }
+
+      QName            propName = XmlBeanUtils.getName( newPropElems[0] );
+      ResourceProperty prop = getProperty( propName );
+
+      throwFaultIfPropertyIsReadOnly( prop );
+      if ( elementNamesNotHomogenous( newPropElems ) )
+      {
+         throw new InvalidUpdateResourcePropertiesRequestContentFaultException( getNamespaceSet(  ),
+                                                                                MSG.getMessage( Keys.ERROR_UPDATE_ELEMS_NOT_HOMOGENOUS ) );
+      }
+
+      throwFaultIfUpdateViolatesSchema( prop, newPropElems );
+
+      try
+      {
+         updatePropertyCallback( prop, newPropElems );
+      }
+      catch ( RuntimeException re )
+      {
+         throw new SetResourcePropertyRequestFailedFaultException( getNamespaceSet(  ),
+                                                                   re.toString(  ) );
+      }
+
+      Object[] oldValue = getValue( prop );
+
+      try
+      {
+         prop.clear(  );
+         for ( int i = 0; i < newPropElems.length; i++ )
+         {
+            prop.add( newPropElems[i] );
+         }
+      }
+      catch ( MetaDataViolationException mdve )
+      {
+         throw new InvalidSetResourcePropertiesRequestContentFaultException( getNamespaceSet(  ), mdve );
+      }
+
+      Object[] newValue = getValue( prop );
+      firePropChangeEvents( prop, oldValue, newValue );
+   }
+
+   private ResourceProperty getProperty( QName propName )
+   {
+      LOG.debug( MSG.getMessage( Keys.GET_RP_WITH_NAME,
+                                 propName.toString(  ) ) );
+      ResourceProperty prop = getProperties(  ).get( propName );
+      if ( prop == null )
+      {
+         if ( !getProperties(  ).getMetaData(  ).isOpenContent(  ) )
+         {
+            throw new InvalidResourcePropertyQNameFaultException( getNamespaceSet(  ), propName );
+         }
+      }
+
+      return prop;
+   }
+
+   /**
+    * Returns SetResourcePropertyCallback or null
+    *
+    * @param prop
+    *
+    * @return SetResourcePropertyCallback or null
+    */
+   private SetResourcePropertyCallback getSetResourcePropertyCallback( ResourceProperty prop )
+   {
+      SetResourcePropertyCallback setResourcePropertyCallback = null;
+      ResourcePropertyCallback    callBack = prop.getCallBack(  );
+      if ( callBack instanceof SetResourcePropertyCallback )
+      {
+         setResourcePropertyCallback = (SetResourcePropertyCallback) callBack;
+      }
+
+      return setResourcePropertyCallback;
+   }
+
+   private Object[] getValue( ResourceProperty prop )
+   {
+      Object[] value        = new Object[prop.size(  )];
+      Iterator propElemIter = prop.iterator(  );
+      int      i            = 0;
+      while ( propElemIter.hasNext(  ) )
+      {
+         value[i++] = XmlBeanUtils.copyXmlBean( (XmlObject) propElemIter.next(  ) );
+      }
+
+      return value;
+   }
+
+   private ResourceProperty createAnyProperty( QName propName )
+   {
+      ResourcePropertyMetaData propMetaData = new AnyResourcePropertyMetaData( propName );
+      return propMetaData.create( getProperties(  ) );
+   }
+
+   private void deletePropertyCallback( ResourceProperty prop )
+   {
+      QName                       nameOfPropToBeDeleted       = prop.getMetaData(  ).getName(  );
+      SetResourcePropertyCallback setResourcePropertyCallback = getSetResourcePropertyCallback( prop );
+      if ( setResourcePropertyCallback != null )
+      {
+         try
+         {
+            setResourcePropertyCallback.deleteProperty( nameOfPropToBeDeleted );
+         }
+         catch ( Exception e )
+         {
+            LOG.debug( MSG.getMessage( Keys.ERROR_DURING_DELETE_CALLBACK, setResourcePropertyCallback ),
+                       e );
+            throw new SetResourcePropertyRequestFailedFaultException( getNamespaceSet(  ),
+                                                                      MSG.getMessage( Keys.ERROR_DURING_DELETE ) );
+         }
+      }
+   }
+
+   private boolean elementNamesNotHomogenous( 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 ) )
+         {
+            return true;
+         }
+      }
+
+      return false;
+   }
+
+   private void firePropChangeEvents( ResourceProperty prop,
+                                      Object[]         oldValue,
+                                      Object[]         newValue )
+   {
+      for ( int i = 0; i < prop.getChangeListeners(  ).length; i++ )
+      {
+         ResourcePropertyValueChangeListener listener = prop.getChangeListeners(  )[i];
+         listener.propertyChanged( getResourcePropertyValueChangeEvent( oldValue, newValue ) );
+      }
+   }
+
+   private void insertPropertyCallback( ResourceProperty prop,
+                                        XmlObject[]      propElemsToBeInserted )
+   {
+      SetResourcePropertyCallback setResourcePropertyCallback = getSetResourcePropertyCallback( prop );
+      if ( setResourcePropertyCallback != null )
+      {
+         try
+         {
+            setResourcePropertyCallback.insertProperty( propElemsToBeInserted );
+         }
+         catch ( Exception e )
+         {
+            LOG.debug( MSG.getMessage( Keys.ERROR_DURING_INSERT_CALLBACK, setResourcePropertyCallback ),
+                       e );
+            throw new SetResourcePropertyRequestFailedFaultException( getNamespaceSet(  ),
+                                                                      MSG.getMessage( Keys.ERROR_DURING_INSERT ) );
+         }
+      }
+   }
+
+   private void throwFaultIfDeletionViolatesSchema( ResourceProperty prop )
+   {
+      if ( prop.getMetaData(  ).getMinOccurs(  ) != 0 )
+      {
+         throw new InvalidSetResourcePropertiesRequestContentFaultException( getNamespaceSet(  ),
+                                                                             MSG.getMessage( 
+                                                                                             Keys.ERROR_PROPERTY_DELETE_VIOLATES_SCHEMA,
+                                                                                             prop.getMetaData(  )
+                                                                                                 .getName(  ) ) );
+      }
+   }
+
+   private void throwFaultIfInsertionViolatesSchema( ResourceProperty prop,
+                                                     XmlObject[]      propElemsToBeInserted )
+   {
+      // TODO (low-priority): if prop is an xsd:any, a more complex algorithm needs to be used to check for minOccurs/maxOccurs violations
+      if ( ( prop.getMetaData(  ).getMaxOccurs(  ) != -1 )
+           && ( ( prop.size(  ) + propElemsToBeInserted.length ) > prop.getMetaData(  ).getMaxOccurs(  ) ) )
+      {
+         throw new InvalidInsertResourcePropertiesRequestContentFaultException( getNamespaceSet(  ),
+                                                                                MSG.getMessage( 
+                                                                                                Keys.ERROR_PROPERTY_INSERT_VIOLATES_SCHEMA,
+                                                                                                ( ( propElemsToBeInserted.length > 1 )
+                                                                                                  ? "s" : "" ),
+                                                                                                prop.getMetaData(  )
+                                                                                                    .getName(  ) ) );
+      }
+   }
+
+   private void throwFaultIfPropertyIsReadOnly( ResourceProperty prop )
+   {
+      if ( prop.getMetaData(  ).isReadOnly(  ) )
+      {
+         throw new UnableToModifyResourcePropertyFaultException( getNamespaceSet(  ),
+                                                                 prop.getMetaData(  ).getName(  ) );
+      }
+   }
+
+   private void throwFaultIfUpdateViolatesSchema( ResourceProperty prop,
+                                                  XmlObject[]      newPropElems )
+   {
+      // TODO (low-priority): if prop is an xsd:any, a more complex algorithm needs to be used to check for minOccurs/maxOccurs violations
+      if ( ( prop.getMetaData(  ).getMaxOccurs(  ) != -1 )
+           && ( newPropElems.length > prop.getMetaData(  ).getMaxOccurs(  ) ) )
+      {
+         throw new InvalidUpdateResourcePropertiesRequestContentFaultException( getNamespaceSet(  ),
+                                                                                MSG.getMessage( 
+                                                                                                Keys.ERROR_PROPERTY_UPDATE_VIOLATES_SCHEMA,
+                                                                                                prop.getMetaData(  )
+                                                                                                    .getName(  ) ) );
+      }
+   }
+
+   private void updatePropertyCallback( ResourceProperty prop,
+                                        XmlObject[]      newPropElems )
+   {
+      SetResourcePropertyCallback setResourcePropertyCallback = getSetResourcePropertyCallback( prop );
+      if ( setResourcePropertyCallback != null )
+      {
+         try
+         {
+            setResourcePropertyCallback.updateProperty( newPropElems );
+         }
+         catch ( Exception e )
+         {
+            LOG.debug( MSG.getMessage( Keys.ERROR_DURING_UPDATE_CALLBACK, setResourcePropertyCallback ),
+                       e );
+            throw new SetResourcePropertyRequestFailedFaultException( getNamespaceSet(  ),
+                                                                      MSG.getMessage( Keys.ERROR_DURING_UPDATE ) );
+         }
+      }
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractXmlBeansResourcePropertyValueChangeEvent.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractXmlBeansResourcePropertyValueChangeEvent.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractXmlBeansResourcePropertyValueChangeEvent.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AbstractXmlBeansResourcePropertyValueChangeEvent.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,87 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+import org.apache.ws.XmlObjectWrapper;
+import org.apache.ws.resource.properties.ResourcePropertyValueChangeEvent;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * @author Ian P. Springer (Hewlett-Packard Company)
+ */
+public abstract class AbstractXmlBeansResourcePropertyValueChangeEvent
+   implements ResourcePropertyValueChangeEvent,
+              XmlObjectWrapper
+{
+   private Object[]  m_oldValue;
+   private Object[]  m_newValue;
+   private XmlObject m_propValueChangeNotifDocXBean;
+
+   /**
+    * Creates a new {@link AbstractXmlBeansResourcePropertyValueChangeEvent} object.
+    *
+    * @param oldValue DOCUMENT_ME
+    * @param newValue DOCUMENT_ME
+    */
+   public AbstractXmlBeansResourcePropertyValueChangeEvent( Object[] oldValue,
+                                                            Object[] newValue )
+   {
+      m_oldValue                        = oldValue;
+      m_newValue                        = newValue;
+      m_propValueChangeNotifDocXBean    = buildPropValueChangeNotifDocXmlBean( oldValue, newValue );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Object[] getNewValue(  )
+   {
+      return m_newValue;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Object[] getOldValue(  )
+   {
+      return m_oldValue;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public XmlObject getXmlObject(  )
+   {
+      return m_propValueChangeNotifDocXBean;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param oldValue DOCUMENT_ME
+    * @param newValue DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   protected abstract XmlObject buildPropValueChangeNotifDocXmlBean( Object[] oldValue,
+                                                                     Object[] newValue );
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AnyResourcePropertyMetaData.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AnyResourcePropertyMetaData.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AnyResourcePropertyMetaData.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/AnyResourcePropertyMetaData.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,112 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+import org.apache.xmlbeans.XmlObject;
+import javax.xml.namespace.QName;
+
+/**
+ * LOG-DONE
+ * @author Ian P. Springer
+ */
+public class AnyResourcePropertyMetaData
+   extends XmlBeansResourcePropertyMetaData
+{
+   private QName m_name;
+
+   /**
+    * Creates a new {@link AnyResourcePropertyMetaData} object.
+    *
+    * @param name DOCUMENT_ME
+    */
+   public AnyResourcePropertyMetaData( QName name )
+   {
+      this( name, false );
+   }
+
+   /**
+    * Creates a new {@link AnyResourcePropertyMetaData} object.
+    *
+    * @param name DOCUMENT_ME
+    * @param isReadOnly DOCUMENT_ME
+    */
+   public AnyResourcePropertyMetaData( QName   name,
+                                       boolean isReadOnly )
+   {
+      super( null, isReadOnly );
+      m_name = name;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean isAny(  )
+   {
+      return true;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int getMaxOccurs(  )
+   {
+      return -1;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int getMinOccurs(  )
+   {
+      return 0;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public QName getName(  )
+   {
+      return m_name;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean isNillable(  )
+   {
+      return false;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Class getType(  )
+   {
+      return XmlObject.class;
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/CallbackFailedException.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/CallbackFailedException.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/CallbackFailedException.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/CallbackFailedException.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,87 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+
+/**
+ * An exception to be thrown when a SetResourcePropertyCallback operation fails
+ *
+ * @author Sal Campana
+ */
+public class CallbackFailedException
+   extends Exception
+{
+   /**
+    * Constructs a new exception with the specified detail message.  The
+    * cause is not initialized, and may subsequently be initialized by
+    * a call to {@link #initCause}.
+    *
+    * @param message the detail message. The detail message is saved for
+    *                later retrieval by the {@link #getMessage()} method.
+    */
+   public CallbackFailedException( String message )
+   {
+      super( message );
+   }
+
+   /**
+    * Constructs a new exception with <code>null</code> as its detail message.
+    * The cause is not initialized, and may subsequently be initialized by a
+    * call to {@link #initCause}.
+    */
+   public CallbackFailedException(  )
+   {
+   }
+
+   /**
+    * Constructs a new exception with the specified cause and a detail
+    * message of <tt>(cause==null ? null : cause.toString())</tt> (which
+    * typically contains the class and detail message of <tt>cause</tt>).
+    * This constructor is useful for exceptions that are little more than
+    * wrappers for other throwables (for example, {@link
+    * java.security.PrivilegedActionException}).
+    *
+    * @param cause the cause (which is saved for later retrieval by the
+    *              {@link #getCause()} method).  (A <tt>null</tt> value is
+    *              permitted, and indicates that the cause is nonexistent or
+    *              unknown.)
+    * @since 1.4
+    */
+   public CallbackFailedException( Throwable cause )
+   {
+      super( cause );
+   }
+
+   /**
+    * Constructs a new exception with the specified detail message and
+    * cause.  <p>Note that the detail message associated with
+    * <code>cause</code> is <i>not</i> automatically incorporated in
+    * this exception's detail message.
+    *
+    * @param message the detail message (which is saved for later retrieval
+    *                by the {@link #getMessage()} method).
+    * @param cause   the cause (which is saved for later retrieval by the
+    *                {@link #getCause()} method).  (A <tt>null</tt> value is
+    *                permitted, and indicates that the cause is nonexistent or
+    *                unknown.)
+    * @since 1.4
+    */
+   public CallbackFailedException( String    message,
+                                   Throwable cause )
+   {
+      super( message, cause );
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourceProperty.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,382 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+import org.apache.commons.lang.SerializationException;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.resource.properties.MetaDataViolationException;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.ResourcePropertyCallback;
+import org.apache.ws.resource.properties.ResourcePropertyMetaData;
+import org.apache.ws.resource.properties.ResourcePropertySet;
+import org.apache.ws.resource.properties.ResourcePropertyValueChangeListener;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.xmlbeans.XmlAnySimpleType;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.w3c.dom.Element;
+import javax.xml.soap.SOAPElement;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * An Apache XMLBeans-based implementation of a resource property.
+ *
+ * @author Ian P. Springer
+ */
+public class XmlBeansResourceProperty
+   implements ResourceProperty
+{
+   private static final Messages       MSG               = MessagesImpl.getInstance(  );
+   private ResourcePropertyMetaData    m_metaData;
+   private XmlBeansResourcePropertySet m_propSet;
+   private List                        m_propElems       = new ArrayList(  );
+   private ResourcePropertyCallback    m_callBack;
+   private Set                         m_changeListeners = new HashSet(  );
+
+   /**
+    * Creates a new {@link XmlBeansResourceProperty} object.
+    *
+    * @param metaData DOCUMENT_ME
+    * @param propSet  DOCUMENT_ME
+    */
+   public XmlBeansResourceProperty( ResourcePropertyMetaData    metaData,
+                                    XmlBeansResourcePropertySet propSet )
+   {
+      m_metaData    = metaData;
+      m_propSet     = propSet;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ResourcePropertyCallback getCallBack(  )
+   {
+      return m_callBack;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param callback DOCUMENT_ME
+    */
+   public void setCallback( ResourcePropertyCallback callback )
+   {
+      m_callBack = callback;
+
+      //m_callBack.refreshProperty(this); todo we probably want to refresh immediately to ensure the rp is initialized...throw a runtime
+   }
+
+   /**
+    * @see ResourceProperty#getChangeListeners()
+    */
+   public ResourcePropertyValueChangeListener[] getChangeListeners(  )
+   {
+      return (ResourcePropertyValueChangeListener[]) m_changeListeners.toArray( new ResourcePropertyValueChangeListener[0] );
+   }
+
+   /**
+    * @see ResourceProperty#isEmpty()
+    */
+   public boolean isEmpty(  )
+   {
+      return m_propElems.isEmpty(  );
+   }
+
+   /**
+    * @see ResourceProperty#getMetaData()
+    */
+   public ResourcePropertyMetaData getMetaData(  )
+   {
+      return m_metaData;
+   }
+
+   /**
+    * @see ResourceProperty#getSet()
+    */
+   public ResourcePropertySet getSet(  )
+   {
+      return m_propSet;
+   }
+
+   /**
+    * 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 )
+   {
+      XmlObject propXBean = toPropXBean( propElem );
+      if ( propXBean == null )
+      {
+         throw new IllegalArgumentException( "A" );
+      }
+
+      trimValue( propXBean );
+      propXBean = XmlBeanUtils.addChildElement( m_propSet.toXmlObject(  ),
+                                                propXBean );
+      load( propXBean );
+   }
+
+   /**
+    * @see ResourceProperty#addChangeListener(ResourcePropertyValueChangeListener)
+    */
+   public void addChangeListener( ResourcePropertyValueChangeListener changeListener )
+   {
+      m_changeListeners.add( changeListener );
+   }
+
+   /**
+    * @see org.apache.ws.resource.properties.ResourceProperty#clear()
+    */
+   public void clear(  )
+   {
+      XmlBeanUtils.removeChildElements( m_propSet.toXmlObject(  ),
+                                        m_metaData.getName(  ) );
+      m_propElems.clear(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param index DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Object get( int index )
+   {
+      return m_propElems.get( index );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Iterator iterator(  )
+   {
+      return m_propElems.iterator(  );
+   }
+
+   /**
+    * This method loads a property element XMLBean, which is already in the resource properties document, into this
+    * {@link XmlBeansResourceProperty}. It is called by {@link XmlBeansResourcePropertySet#XmlBeansResourcePropertySet(org.apache.xmlbeans.XmlObject)}
+    * 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 )
+   {
+      if ( !XmlBeanUtils.getName( propXBean ).equals( m_metaData.getName(  ) ) )
+      {
+         throw new MetaDataViolationException( MSG.getMessage( Keys.PROP_MUST_BE_NAMED,
+                                                               m_metaData.getName(  ) ) );
+      }
+
+      m_propElems.add( propXBean );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propElem DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean remove( Object propElem )
+   {
+      XmlObject propXBeanToRemove;
+      try
+      {
+         propXBeanToRemove = XmlBeanUtils.getRootElement( XmlBeanUtils.toXmlObject( propElem ) );
+      }
+      catch ( Exception e )
+      {
+         throw new IllegalArgumentException( MSG.getMessage( Keys.UNABLE_TO_CONVERT_TO_XMLOBJECT ) + " " + e );
+      }
+
+      if ( !XmlBeanUtils.getName( propXBeanToRemove ).equals( m_metaData.getName(  ) ) )
+      {
+         throw new IllegalArgumentException( MSG.getMessage( Keys.PROP_ELEM_TO_REMOVE_MST_B_NAMED,
+                                                             m_metaData.getName(  ) ) );
+      }
+
+      for ( int index = 0; index < m_propElems.size(  ); index++ )
+      {
+         XmlObject propXBean = (org.apache.xmlbeans.XmlObject) m_propElems.get( index );
+         if ( propXBean.equals( propXBeanToRemove ) )
+         {
+            XmlBeanUtils.remove( propXBean );
+            m_propElems.remove( index );
+            return true;
+         }
+      }
+
+      return false;
+   }
+
+   /**
+    * @see ResourceProperty#set(int, Object)
+    */
+   public void set( int    index,
+                    Object propElem )
+   {
+      XmlObject propXBean = toPropXBean( propElem );
+      if ( !XmlBeanUtils.getName( propXBean ).equals( m_metaData.getName(  ) ) )
+      {
+         throw new IllegalArgumentException( MSG.getMessage( Keys.PROP_SET_MST_B_NAMED,
+                                                             m_metaData.getName(  ) ) );
+      }
+
+      if ( index >= m_propElems.size(  ) )
+      {
+         throw new IndexOutOfBoundsException( MSG.getMessage( Keys.INDEX_MST_B_GTR0,
+                                                              Integer.toString( m_propElems.size(  ) ) ) );
+      }
+
+      XmlObject currentPropXBean = (XmlObject) m_propElems.get( index );
+      trimValue( propXBean );
+      currentPropXBean.set( propXBean );
+   }
+
+   /**
+    * @see ResourceProperty#size()
+    */
+   public int size(  )
+   {
+      return m_propElems.size(  );
+   }
+
+   /**
+    * @see ResourceProperty#toElements()
+    */
+   public Element[] toElements(  )
+   throws SerializationException
+   {
+      List elems = new ArrayList(  );
+      for ( int i = 0; i < m_propElems.size(  ); i++ )
+      {
+         XmlObject propXBean = (XmlObject) m_propElems.get( i );
+         elems.add( propXBean.newDomNode(  ) );
+      }
+
+      return (Element[]) elems.toArray( new Element[0] );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    *
+    * @throws SerializationException DOCUMENT_ME
+    */
+   public SOAPElement[] toSOAPElements(  )
+   throws SerializationException
+   {
+      try
+      {
+         return XmlBeanUtils.toSOAPElementArray( (XmlObject[]) m_propElems.toArray( new XmlObject[0] ) );
+      }
+      catch ( Exception e )
+      {
+         throw new SerializationException( e );
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public String toString(  )
+   {
+      return toXML(  );
+   }
+
+   /**
+    * @see ResourceProperty#toXML()
+    */
+   public String toXML(  )
+   {
+      StringBuffer buf = new StringBuffer(  );
+      for ( int i = 0; i < m_propElems.size(  ); i++ )
+      {
+         XmlObject propXBean = (XmlObject) m_propElems.get( i );
+         buf.append( propXBean.xmlText( new XmlOptions(  ).setSaveOuter(  ).setSavePrettyPrint(  ) ) );
+      }
+
+      return buf.toString(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public XmlObject[] toXmlObjects(  )
+   {
+      return (XmlObject[]) m_propElems.toArray( new XmlObject[0] );
+   }
+
+   private XmlObject toPropXBean( Object propElem )
+   {
+      if ( propElem == null )
+      {
+         throw new IllegalArgumentException( "Property element is null." );
+      }
+
+      XmlObject propXBean;
+      try
+      {
+         propXBean = XmlBeanUtils.getRootElement( XmlBeanUtils.toXmlObject( propElem ) );
+         if ( propXBean == null )
+         {
+            throw new IllegalArgumentException( "Property element is an empty document XmlObject." );
+         }
+      }
+      catch ( Exception e )
+      {
+         throw new IllegalArgumentException( MSG.getMessage( Keys.UNABLE_TO_CONVERT_TO_XMLOBJECT ) + " " + e );
+      }
+
+      return propXBean;
+   }
+
+   private void trimValue( XmlObject propXBean )
+   {
+      // TODO: get rid of this or make it a configurable option
+      if ( propXBean instanceof XmlAnySimpleType )
+      {
+         XmlAnySimpleType simplePropXBean = (XmlAnySimpleType) propXBean;
+         String           value = simplePropXBean.getStringValue(  );
+         if ( ( value != null ) && !value.equals( "" ) )
+         {
+            simplePropXBean.setStringValue( value.trim(  ) );
+         }
+      }
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyMetaData.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyMetaData.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyMetaData.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyMetaData.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,179 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.ResourcePropertyMetaData;
+import org.apache.ws.resource.properties.ResourcePropertySet;
+import org.apache.ws.resource.properties.ResourcePropertySetMetaData;
+import org.apache.xmlbeans.SchemaProperty;
+import org.oasisOpen.docs.wsrf.x2004.x10.wsrfWSResourceMetadataDescriptor10Draft01.ModifiabilityType;
+import org.oasisOpen.docs.wsrf.x2004.x10.wsrfWSResourceMetadataDescriptor10Draft01.PropertyType;
+import javax.xml.namespace.QName;
+import java.math.BigInteger;
+
+/**
+ * Apache XMLBeans-based implementation of resource property metadata.
+ *
+ * @author Ian P. Springer
+ */
+public class XmlBeansResourcePropertyMetaData
+   implements ResourcePropertyMetaData
+{
+   //private static final Log LOG = LogFactory.getLog( XmlBeansResourcePropertyMetaData.class );
+   private SchemaProperty              m_schemaProp;
+   private boolean                     m_isReadOnly;
+   private ResourcePropertySetMetaData m_setMetaData;
+
+   /**
+    * Creates a new {@link XmlBeansResourcePropertyMetaData} object.
+    *
+    * @param schemaProp DOCUMENT_ME
+    */
+   public XmlBeansResourcePropertyMetaData( SchemaProperty schemaProp )
+   {
+      this( schemaProp, false );
+   }
+
+   /**
+    * Creates a new {@link XmlBeansResourcePropertyMetaData} object based on the specified
+    * xsd:element schema property and wsrmd:Property.
+    *
+    * @param schemaProp DOCUMENT_ME
+    * @param propDesc
+    */
+   public XmlBeansResourcePropertyMetaData( SchemaProperty schemaProp,
+                                            PropertyType   propDesc )
+   {
+      this( schemaProp,
+            ( propDesc != null ) ? ( propDesc.getModifiability(  ).intValue(  ) == ModifiabilityType.INT_READ_ONLY )
+                                 : false );
+   }
+
+   /**
+    * Creates a new {@link XmlBeansResourcePropertyMetaData} object.
+    *
+    * @param schemaProp DOCUMENT_ME
+    * @param isReadOnly DOCUMENT_ME
+    */
+   public XmlBeansResourcePropertyMetaData( SchemaProperty schemaProp,
+                                            boolean        isReadOnly )
+   {
+      m_schemaProp    = schemaProp;
+      m_isReadOnly    = isReadOnly;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean isAny(  )
+   {
+      return false;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int getMaxOccurs(  )
+   {
+      BigInteger maxOccurs = m_schemaProp.getMaxOccurs(  );
+      return ( maxOccurs != null ) ? maxOccurs.intValue(  ) : ( -1 );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public int getMinOccurs(  )
+   {
+      return m_schemaProp.getMinOccurs(  ).intValue(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public QName getName(  )
+   {
+      return m_schemaProp.getName(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean isNillable(  )
+   {
+      return m_schemaProp.hasNillable(  ) == SchemaProperty.CONSISTENTLY;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean isReadOnly(  )
+   {
+      return m_isReadOnly;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ResourcePropertySetMetaData getSetMetaData(  )
+   {
+      synchronized ( this )
+      {
+         if ( m_setMetaData == null )
+         {
+            m_setMetaData = new XmlBeansResourcePropertySetMetaData( m_schemaProp.getContainerType(  ) );
+         }
+      }
+
+      return m_setMetaData;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Class getType(  )
+   {
+      return m_schemaProp.getType(  ).getJavaClass(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propSet DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ResourceProperty create( ResourcePropertySet propSet )
+   {
+      return new XmlBeansResourceProperty( this, (XmlBeansResourcePropertySet) propSet );
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,396 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+import org.apache.commons.lang.SerializationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.resource.properties.MetaDataViolationException;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.ResourcePropertyMetaData;
+import org.apache.ws.resource.properties.ResourcePropertySet;
+import org.apache.ws.resource.properties.ResourcePropertySetMetaData;
+import org.apache.ws.util.XmlBeanNameUtils;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.xmlbeans.SchemaProperty;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPElement;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * An Apache XMLBeans-based implementation of a resource property set.
+ *
+ * @author Ian P. Springer
+ */
+public class XmlBeansResourcePropertySet
+   implements ResourcePropertySet
+{
+   private static final Log            LOG             = LogFactory.getLog( XmlBeansResourcePropertySet.class );
+   private static final Messages       MSG             = MessagesImpl.getInstance(  );
+   private XmlObject                   m_propsDocXBean;
+   private XmlObject                   m_propsXBean;
+   private Map                         m_propsMap      = new HashMap(  );
+   private ResourcePropertySetMetaData m_metaData;
+
+   /**
+    * Creates a new {@link XmlBeansResourcePropertySet} object.
+    *
+    * @param propsDocXBean DOCUMENT_ME
+    */
+   public XmlBeansResourcePropertySet( XmlObject propsDocXBean )
+   throws MetaDataViolationException
+   {
+      this( propsDocXBean, new XmlBeansResourcePropertySetMetaData( propsDocXBean.schemaType(  ) ) );
+   }
+
+   /**
+    * Creates a new {@link XmlBeansResourcePropertySet} object.
+    *
+    * @param propsDocXBean DOCUMENT_ME
+    * @param metaData metadata describing this property set
+    */
+   public XmlBeansResourcePropertySet( XmlObject                   propsDocXBean,
+                                       ResourcePropertySetMetaData metaData )
+   throws MetaDataViolationException
+   {
+      if ( !XmlBeanUtils.isDocument( propsDocXBean ) )
+      {
+         throw new IllegalArgumentException( MSG.getMessage( Keys.XMLOBJECT_DOC,
+                                                             propsDocXBean.getClass(  ).getName(  ) ) );
+      }
+
+      m_propsDocXBean    = propsDocXBean;
+      m_propsXBean       = getPropsDocRootElem(  );
+      m_metaData         = metaData;
+      initProperties( metaData );
+   }
+
+   /**
+    * @return
+    */
+   public boolean isEmpty(  )
+   {
+      return m_propsMap.isEmpty(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ResourcePropertySetMetaData getMetaData(  )
+   {
+      return m_metaData;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param prop DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean add( ResourceProperty prop )
+   throws MetaDataViolationException
+   {
+      if ( !m_metaData.isOpenContent(  ) )
+      {
+         throw new MetaDataViolationException( MSG.getMessage( Keys.NON_ANY_PROP_CANNOT_BE_REMOVED ) );
+      }
+
+      if ( m_propsMap.containsKey( prop.getMetaData(  ).getName(  ) ) )
+      {
+         throw new MetaDataViolationException( MSG.getMessage( Keys.PROP_DOC_ALREADY_CONTAINS_PROPERTY,
+                                                               prop.getMetaData(  ).getName(  ) ) );
+      }
+
+      addProperty( prop );
+      return true;
+   }
+
+   /**
+    * @throws MetaDataViolationException
+    */
+   public void clear(  )
+   throws MetaDataViolationException
+   {
+      LOG.debug( MSG.getMessage( Keys.CLEAR_PROP_SET ) );
+      Collection props = m_propsMap.values(  );
+      for ( Iterator iterator = props.iterator(  ); iterator.hasNext(  ); )
+      {
+         ResourceProperty prop = (ResourceProperty) iterator.next(  );
+         prop.clear(  );
+         m_propsMap.remove( prop.getMetaData(  ).getName(  ) );
+      }
+   }
+
+   /**
+    * A factory method for creating
+    *
+    * @param metaData
+    *
+    * @return ResourceProperty
+    */
+   public ResourceProperty create( ResourcePropertyMetaData metaData )
+   {
+      return new XmlBeansResourceProperty( metaData, this );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propName DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ResourceProperty get( QName propName )
+   {
+      return (ResourceProperty) m_propsMap.get( propName );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public Iterator iterator(  )
+   {
+      return m_propsMap.values(  ).iterator(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param propName DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean remove( QName propName )
+   throws MetaDataViolationException
+   {
+      if ( !m_metaData.isOpenContent(  ) )
+      {
+         throw new MetaDataViolationException( MSG.getMessage( Keys.NON_ANY_PROP_CANNOT_BE_REMOVED ) );
+      }
+
+      LOG.debug( MSG.getMessage( Keys.REMOVING_PROP,
+                                 propName.toString(  ) ) );
+      ResourceProperty resourceProp = (ResourceProperty) m_propsMap.get( propName );
+      resourceProp.clear(  );
+      m_propsMap.remove( propName );
+      return true;
+   }
+
+   /**
+    * Forces the removal/addition of a ResourceProperty...This will not check with the schema and is intended
+    * to be used when the user intends to "replace" the internal ResourceProperty with something else.
+    *
+    * @param prop The ResourceProperty which will be overwritten
+    * @return true
+    */
+   public boolean set( ResourceProperty prop )
+   {
+      QName propName = prop.getMetaData(  ).getName(  );
+      LOG.debug( MSG.getMessage( Keys.REMOVING_PROP,
+                                 propName.toString(  ) ) );
+      ResourceProperty resourceProp = (ResourceProperty) m_propsMap.get( propName );
+      resourceProp.clear(  );
+      m_propsMap.remove( propName );
+      addProperty( prop );
+      return true;
+   }
+
+   /**
+    * @return
+    */
+   public int size(  )
+   {
+      return m_propsMap.size(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    *
+    * @throws SerializationException DOCUMENT_ME
+    */
+   public Element toElement(  )
+   throws SerializationException
+   {
+      Document doc = (Document) m_propsDocXBean.newDomNode(  );
+      return doc.getDocumentElement(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    *
+    * @throws SerializationException DOCUMENT_ME
+    */
+   public SOAPElement toSOAPElement(  )
+   throws SerializationException
+   {
+      try
+      {
+         return XmlBeanUtils.toSOAPElement( m_propsXBean );
+      }
+      catch ( Exception e )
+      {
+         throw new SerializationException( e );
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public String toString(  )
+   {
+      return toXML(  );
+   }
+
+   /**
+    * @return
+    */
+   public String toXML(  )
+   {
+      return m_propsDocXBean.xmlText( new XmlOptions(  ).setSavePrettyPrint(  ) );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public XmlObject toXmlObject(  )
+   {
+      return m_propsDocXBean;
+   }
+
+   /**
+    * Gets the XmlBean Java classname representing the resource property document.
+    *
+    * @param resourcePropsDocElemQName the QName of the resource property document
+    *
+    * @return XmlBean classname that represents the resource property document
+    */
+   protected String getPropsDocClassName( QName resourcePropsDocElemQName )
+   {
+      String resourcePropertiesClassName =
+         XmlBeanNameUtils.getElementXmlBeanClassName( resourcePropsDocElemQName );
+
+      if ( resourcePropertiesClassName == null )
+      {
+         throw new NoClassDefFoundError( "Could not determine name of the Resource Properties Document XML Bean class for document element: "
+                                         + resourcePropsDocElemQName );
+      }
+
+      return resourcePropertiesClassName;
+   }
+
+   private XmlObject getPropsDocRootElem(  )
+   {
+      XmlObject propsXBean = XmlBeanUtils.getRootElement( m_propsDocXBean );
+      if ( propsXBean == null )
+      {
+         // user did not initialize the props doc root element, so do it for them...
+         String propsElemJavaPropName =
+            m_propsDocXBean.schemaType(  ).getElementProperties(  )[0].getJavaPropertyName(  );
+         try
+         {
+            Method addNewMethod =
+               m_propsDocXBean.getClass(  ).getMethod( "addNew" + propsElemJavaPropName,
+                                                       new Class[0] );
+            propsXBean = (XmlObject) addNewMethod.invoke( m_propsDocXBean,
+                                                          new Object[0] );
+         }
+         catch ( Exception e )
+         {
+            e.printStackTrace(  );
+            throw new RuntimeException( e );
+         }
+      }
+
+      return propsXBean;
+   }
+
+   private ResourceProperty addProperty( ResourceProperty prop )
+   {
+      Iterator iter = prop.iterator(  );
+      while ( iter.hasNext(  ) )
+      {
+         XmlObject propElemXBean = (XmlObject) iter.next(  );
+         XmlBeanUtils.addChildElement( m_propsDocXBean, propElemXBean );
+      }
+
+      addPropertyToMap( prop );
+      return prop;
+   }
+
+   private void addPropertyToMap( ResourceProperty resourceProp )
+   {
+      QName name = resourceProp.getMetaData(  ).getName(  );
+      LOG.debug( MSG.getMessage( Keys.ADDING_PROP,
+                                 name.toString(  ) ) );
+      m_propsMap.put( name, resourceProp );
+   }
+
+   private XmlBeansResourceProperty createProperty( SchemaProperty elemSchemaProp,
+                                                    boolean        isReadOnly )
+   {
+      return new XmlBeansResourceProperty( new XmlBeansResourcePropertyMetaData( elemSchemaProp, isReadOnly ),
+                                           this );
+   }
+
+   private void initProperties( ResourcePropertySetMetaData setMetaData )
+   throws MetaDataViolationException
+   {
+      SchemaProperty[] propElemDefs = m_propsXBean.schemaType(  ).getElementProperties(  );
+      for ( int i = 0; i < propElemDefs.length; i++ )
+      {
+         XmlBeansResourceProperty prop =
+            createProperty( propElemDefs[i],
+                            setMetaData.getPropertyMetaData( propElemDefs[i].getName(  ) ).isReadOnly(  ) );
+         populateProperty( prop );
+         addPropertyToMap( prop );
+      }
+   }
+
+   private void populateProperty( XmlBeansResourceProperty prop )
+   throws MetaDataViolationException
+   {
+      XmlObject[] propXBeans = XmlBeanUtils.getChildElements( m_propsXBean,
+                                                              prop.getMetaData(  ).getName(  ) );
+      for ( int j = 0; j < propXBeans.length; j++ )
+      {
+         prop.load( propXBeans[j] );
+      }
+   }
+}
\ No newline at end of file

Added: webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaData.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaData.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaData.java (added)
+++ webservices/muse/branches/1.0/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaData.java Fri Jun  2 10:32:46 2006
@@ -0,0 +1,219 @@
+/*=============================================================================*
+ *  Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.resource.properties.ResourcePropertyMetaData;
+import org.apache.ws.resource.properties.ResourcePropertySet;
+import org.apache.ws.resource.properties.ResourcePropertySetMetaData;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.xmlbeans.SchemaProperty;
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsrf.x2004.x10.wsrfWSResourceMetadataDescriptor10Draft01.MetadataDescriptorType;
+import org.oasisOpen.docs.wsrf.x2004.x10.wsrfWSResourceMetadataDescriptor10Draft01.PropertyType;
+import javax.xml.namespace.QName;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * An Apache XMLBeans-based implementation of resource property set metadata.
+ *
+ * @author Ian P. Springer
+ */
+public class XmlBeansResourcePropertySetMetaData
+   implements ResourcePropertySetMetaData
+{
+   private static final Log      LOG             = LogFactory.getLog( XmlBeansResourcePropertySetMetaData.class );
+   private static final Messages MSG             = MessagesImpl.getInstance(  );
+   private final SchemaType      m_schemaType;
+   private final Map             m_propMetaDatas = new HashMap(  );
+
+   /**
+    * Creates a new {@link XmlBeansResourcePropertySetMetaData} object.
+    *
+    * @param schemaType DOCUMENT_ME
+    */
+   public XmlBeansResourcePropertySetMetaData( SchemaType schemaType )
+   {
+      this( schemaType, new QName[0] );
+   }
+
+   /**
+    * Creates a new {@link XmlBeansResourcePropertySetMetaData} object.
+    *
+    * @param schemaType DOCUMENT_ME
+    */
+   public XmlBeansResourcePropertySetMetaData( SchemaType             schemaType,
+                                               MetadataDescriptorType metaDataDesc )
+   {
+      if ( !schemaType.isDocumentType(  ) )
+      {
+         throw new IllegalArgumentException( MSG.getMessage( Keys.SCHEMA_MUST_BE_DOC ) );
+      }
+
+      m_schemaType = schemaType;
+      SchemaProperty[] elemTypes = m_schemaType.getElementProperties(  )[0].getType(  ).getElementProperties(  );
+      for ( int i = 0; i < elemTypes.length; i++ )
+      {
+         PropertyType propDesc = getPropertyDesc( metaDataDesc,
+                                                  elemTypes[i].getName(  ) );
+         m_propMetaDatas.put( elemTypes[i].getName(  ),
+                              new XmlBeansResourcePropertyMetaData( elemTypes[i], propDesc ) );
+      }
+   }
+
+   /**
+    * Creates a new {@link XmlBeansResourcePropertySetMetaData} object.
+    *
+    * @param schemaType DOCUMENT_ME
+    */
+   public XmlBeansResourcePropertySetMetaData( SchemaType schemaType,
+                                               QName[]    readOnlyPropNames )
+   {
+      if ( !schemaType.isDocumentType(  ) )
+      {
+         throw new IllegalArgumentException( MSG.getMessage( Keys.SCHEMA_MUST_BE_DOC ) );
+      }
+
+      m_schemaType = schemaType;
+      SchemaProperty[] elemTypes = m_schemaType.getElementProperties(  )[0].getType(  ).getElementProperties(  );
+      Set              readOnlyPropNameSet = toSet( readOnlyPropNames );
+      for ( int i = 0; i < elemTypes.length; i++ )
+      {
+         m_propMetaDatas.put( elemTypes[i].getName(  ),
+                              new XmlBeansResourcePropertyMetaData( elemTypes[i],
+                                                                    readOnlyPropNameSet.contains( elemTypes[i]
+                                                                                                  .getName(  ) ) ) );
+      }
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public QName getName(  )
+   {
+      return m_schemaType.getDocumentElementName(  );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public boolean isOpenContent(  )
+   {
+      SchemaType[] anonTypes = m_schemaType.getAnonymousTypes(  );
+      for ( int i = 0; i < anonTypes.length; i++ )
+      {
+         if ( anonTypes[i].hasElementWildcards(  ) )
+         {
+            return true;
+         }
+      }
+
+      return false;
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @param name DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ResourcePropertyMetaData getPropertyMetaData( QName name )
+   {
+      return (ResourcePropertyMetaData) m_propMetaDatas.get( name );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ResourcePropertyMetaData[] getPropertyMetaDatas(  )
+   {
+      return (ResourcePropertyMetaData[]) m_propMetaDatas.values(  ).toArray( new ResourcePropertyMetaData[0] );
+   }
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @return DOCUMENT_ME
+    */
+   public ResourcePropertySet create(  )
+   {
+      try
+      {
+         Class factoryClass = Class.forName( m_schemaType.getFullJavaName(  ) + "$Factory" );
+         LOG.debug( MSG.getMessage( Keys.CREATING_PROPSET, factoryClass ) );
+         Method    newInstanceMethod = factoryClass.getMethod( "newInstance", null );
+         XmlObject propsDocXBean = (XmlObject) newInstanceMethod.invoke( null,
+                                                                         new Object[0] );
+         return new XmlBeansResourcePropertySet( propsDocXBean );
+      }
+      catch ( Exception e )
+      {
+         throw new RuntimeException( e );
+      }
+   }
+
+   private static PropertyType getPropertyDesc( MetadataDescriptorType metadataDesc,
+                                                QName                  propName )
+   {
+      // TODO (low priority): recurse into inherited descriptors when looking for property descs
+      //       (assume inherited-desc locations are absolute URLs, since we don't know our base URL)
+      if ( metadataDesc != null )
+      {
+         PropertyType[] propDescs = metadataDesc.getPropertyArray(  );
+         for ( int i = 0; i < propDescs.length; i++ )
+         {
+            QName name = XmlBeanUtils.getAttributeValueAsQName( propDescs[i],
+                                                                new QName( "", "path" ) );
+            if ( name.equals( propName ) )
+            {
+               return propDescs[i];
+            }
+         }
+      }
+
+      return null;
+   }
+
+   private static Set toSet( Object[] array )
+   {
+      Set set = new HashSet(  );
+      if ( array != null )
+      {
+         for ( int i = 0; i < array.length; i++ )
+         {
+            set.add( array[i] );
+         }
+      }
+
+      return set;
+   }
+}
\ No newline at end of file



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