You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2006/06/16 00:17:07 UTC

svn commit: r414694 [6/7] - in /webservices/muse/trunk/modules/muse-wsrf: ./ src-api/ src-api/org/ src-api/org/apache/ src-api/org/apache/muse/ src-api/org/apache/muse/ws/ src-api/org/apache/muse/ws/resource/ src-api/org/apache/muse/ws/resource/basefau...

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/query/impl/XPathQueryExpressionFactory.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/query/impl/XPathQueryExpressionFactory.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/query/impl/XPathQueryExpressionFactory.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/query/impl/XPathQueryExpressionFactory.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,56 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.query.impl;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XPathUtils;
+import org.apache.muse.ws.resource.properties.query.QueryExpression;
+import org.apache.muse.ws.resource.properties.query.QueryExpressionFactory;
+import org.apache.muse.ws.resource.properties.query.faults.UnknownQueryExpressionDialectFault;
+
+
+public class XPathQueryExpressionFactory implements QueryExpressionFactory
+{
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = 
+        MessagesFactory.get(XPathQueryExpressionFactory.class);
+    
+    private static final QueryExpression _EVALUATOR = new XPathQueryExpression();
+    
+    public boolean hasDialect(String dialect)
+    {
+        return dialect != null && dialect.equals(_EVALUATOR.getDialect());
+    }
+    
+    public QueryExpression newInstance(String dialect)
+        throws UnknownQueryExpressionDialectFault
+    {
+        //
+        // this implementation only supports XPath queries
+        //
+        if (!hasDialect(dialect))
+        {
+            Object[] filler = { dialect, XPathUtils.NAMESPACE_URI };
+            throw new UnknownQueryExpressionDialectFault(_MESSAGES.get("UnknownQueryDialect", filler));
+        }
+
+        return _EVALUATOR;
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/Messages.properties?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/Messages.properties (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/Messages.properties Thu Jun 15 15:16:59 2006
@@ -0,0 +1,43 @@
+NullQName = The QName reference is null.
+NullQNameArray = The QName array is null.
+NullTopic = The Topic reference is null.
+NullPropertyElement = The DOM Element with the WS-RP property definition is null.
+NullPropertiesElement = The DOM Element with the WS-ResourceProperties definition is null.
+NotAnElement = The DOM Element with the WS-ResourceProperties definition is not an xsd:element. A WS-RP definition must be an xsd:element.
+NoPropertiesName = The WS-ResourceProperties element has no name attribute. What is the name of the properties document?
+NoTypeDeclaration = The property 'XXX' has no definition in the WSDL's types section. A common error is that the property's QName has an invalid namespace URI.
+PropertyNotFound = The schema has no property with the name 'XXX'. Use the hasProperty method to determine if a property exists.
+NullDocument = The DOM Document is null.
+NullPCA = The PropertyChangeApprover is null.
+NullPCL = The PropertyChangeListener is null.
+NullPRL = The PropertyReadListener is null.
+QueryNotProperty = The query 'XXX' does not resolve to a property element. Deletion via query string can only be done if the query maps to complete property instances in the DOM; that is, all results must be child elements of the document's root node. Appropriate queries include '/*/MyName', '/*/MyName[@attr]', etc.
+EmptyDocument = The DOM Document that represents the WS-RP document is empty. The Document must be a valid XML document, which means it must have at least a root node.
+NullValuesArray = The array of property values is null. If you want to set properties to null, you still need a valid array - just add null value(s) to it.
+EmptyValuesArray = The array of property values is null. If you want to set properties to null, you still need a non-empty array - just add null value(s) to it.
+NullQuery = The query string is null. What are we looking for?
+NullDialect = The dialect is null. The only dialect supported by this implementation is XPath 1.0 (see XPathUtils for the full XPath 1.0 URI).
+NullMetadataDescriptor = The MetadataDescriptor is null.
+NullSchema = The ResourcePropertiesSchema is null. The properties document must have a schema, even if it has no constraints. If you want to place no schema constraints on your properties, you can rely on the default schema, which is an instance of OpenPropertiesSchema.
+EmptySetRequest = The SetResourceProperties request has no concrete set operations (Insert/Update/Delete). Each SetRequest must have at least one operation.
+BelowMinimumPotential = The property 'XXX' has a minOccurs value of XXX. If the deletion were performed, there would only be XXX instances of the property left, which is below the minimum.
+AboveMaximumPotential = The property 'XXX' has a maxOccurs value of XXX. If the insertion were performed, there would be XXX instances of the property left, which is above the maximum.
+BelowMinimum = The property 'XXX' has a minOccurs value of XXX, but there are only XXX instances in the document.
+AboveMaximum = The property 'XXX' has a maxOccurs value of XXX, but there are XXX instances in the document.
+NotNillable = The property 'XXX' is not nillable, but there is an instance of it with no child nodes (a null value).
+NoMetadata = The WS-RP collection has no metadata descriptor - you must set the metadata with setMetadata() before you can try to validate the properties. Use the EmptyMetadataDescriptor class if you want to avoid making metadata restrictions.
+NoSchema = The WS-RP collection has no XML Schema definition - you must set the schema with setSchema() before you can try to validate the properties. Use the OpenPropertiesSchema class if you want to avoid making schema restrictions.
+NullNLF = The NotificationListenerFactory is null.
+NoNLF = You are trying to create WS-N Topics for the resource properties, but no NotificationListenerFactory has been provided for the WS-RP container. You must call setNotificationListenerFactory() before you can create Topics (and accept subscriptions) for the resource properties.
+NullTopicPath = The Topic path expression is null.
+NoNotificationElement = The WS-N NotificationMessage does not have any message content in Element form. Property change notifications should be represented by (at the very least) a wsrp:ResourcePropertyValueChangeNotification element under the wsn:Message.
+InvalidNotification = The property change subscriber failed to parse the WS-N NotificationMessage. It found the element 'XXX' when looking for 'XXX'. Make sure the WS-RP change notifications are formatted according to the WS-RP spec.
+PropertyNotInSchema = There is no property named 'XXX' defined in the schema. A property should not have any operations or metadata applied to it if it is not in the WS-RP document.
+InvalidValue = The property 'XXX' has a value that is not valid according to its metadata. The invalid value is: XXX
+DeletingStaticValue = Could not delete a value for the property 'XXX' because it is static. The static value was: XXX
+NoExternalChanges = The metadata for property 'XXX' allows it to be changed, but not by other services. You cannot modify the value of this property via WS-RP SetResourceProperties.
+InsertOnly = The metadata for property 'XXX' only allows it to be inserted ('appended'), not updated or deleted.
+ReadOnly = The metadata for property 'XXX' makes it read-only. It cannot be modified in any way via WS-RP SetResourceProperties.
+NoInstancesToDelete = There are no instances of the property 'XXX', so it cannot be deleted.
+InvalidQueryDialect = The query dialect 'XXX' is not supported by this WS-RP implementation. The only valid dialect is 'XXX'.
+QueryEvaluationError = There was an error trying to evaluate the query 'XXX'. The original error was: XXX

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/PropertySchemaDefinition.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/PropertySchemaDefinition.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/PropertySchemaDefinition.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/PropertySchemaDefinition.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,194 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.schema.impl;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.util.xml.XsdUtils;
+import org.apache.muse.ws.resource.WsResourceCapability;
+import org.apache.muse.ws.resource.properties.schema.ResourcePropertiesSchema;
+import org.apache.muse.ws.wsdl.WsdlUtils;
+
+/**
+ *
+ * PropertySchemaDefinition is an internal class that represents one type 
+ * definition in a WS-RP document definition. It holds all of the schema 
+ * information for one resource property.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ * @see SimpleResourcePropertiesSchema
+ * 
+ */
+
+class PropertySchemaDefinition
+{
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = 
+        MessagesFactory.get(PropertySchemaDefinition.class);
+    
+    private WsResourceCapability _capability = null;
+    
+    //
+    // True if instances of the property can be set to null. The 
+    // default is 'false'.
+    //
+    private boolean _isNillable = false;
+    
+    //
+    // The maximum number of instances per properties document. The 
+    // default is 1.
+    //
+    private int _max = 1;
+
+    //
+    // The minimum number of instances per properties document. The 
+    // default is 1.
+    //
+    private int _min = 1;
+    
+    //
+    // The name of the property
+    //
+    private QName _qname = null;
+    
+    //
+    // The base type of the property
+    //
+    private QName _typeName = XsdUtils.ANY_TYPE_QNAME;
+    
+    /**
+     * 
+     * @param qname
+     *        The name of the new property.
+     * 
+     * @param definition
+     *        The property's XML schema element (from the WS-RP document).
+     *
+     */
+    public PropertySchemaDefinition(QName qname, Element definition)
+    {
+        if (qname == null)
+            throw new NullPointerException(_MESSAGES.get("NullQName"));
+        
+        if (definition == null)
+            throw new NullPointerException(_MESSAGES.get("NullPropertyElement"));
+        
+        _qname = qname;
+        
+        //
+        // property minimum - optional
+        //
+        String attr = definition.getAttribute(XsdUtils.MIN_OCCURS);
+        
+        if (attr != null && attr.length() > 0)
+            _min = Integer.parseInt(attr);
+        
+        //
+        // property maximum - optional
+        //
+        attr = definition.getAttribute(XsdUtils.MAX_OCCURS);
+        
+        if (attr != null && attr.length() > 0)
+        {
+            boolean isUnbounded = attr.equals(XsdUtils.UNBOUNDED);
+            
+            if (isUnbounded)
+                _max = ResourcePropertiesSchema.UNBOUNDED;
+            
+            else
+                _max = Integer.parseInt(attr);
+        }
+                
+        //
+        // finally, scan the whole wsdl:types for the type definition
+        //
+        Document doc = definition.getOwnerDocument();
+        Element typeDeclaration = WsdlUtils.getTypeDeclaration(doc, _qname);
+        
+        if (typeDeclaration == null)
+        {
+            Object[] filler = { qname };
+            throw new RuntimeException(_MESSAGES.get("NoTypeDeclaration", filler));
+        }
+
+        //
+        // get the concrete/parent type of the property (if any)
+        //        
+        attr = typeDeclaration.getAttribute(XsdUtils.TYPE);
+        
+        if (attr != null && attr.length() > 0)
+            _typeName = XmlUtils.parseQName(attr, typeDeclaration);
+        
+        //
+        // property's nillable setting - optional
+        //
+        attr = typeDeclaration.getAttribute(XsdUtils.NILLABLE);
+        
+        if (attr != null && attr.length() > 0)
+            _isNillable = Boolean.valueOf(attr).booleanValue(); 
+    }
+    
+    public int getMaxOccurs()
+    {
+        return _max;
+    }
+
+    public int getMinOccurs()
+    {
+        return _min;
+    }
+
+    public QName getPropertyName()
+    {
+        return _qname;
+    }
+    
+    public QName getPropertyTypeName()
+    {
+        return _typeName;
+    }
+
+    public boolean isMaxUnbounded()
+    {
+        return getMaxOccurs() == ResourcePropertiesSchema.UNBOUNDED;
+    }
+    
+    public boolean isNillable()
+    {
+        return _isNillable;
+    }
+    
+    public WsResourceCapability getCapability()
+    {
+        return _capability;
+    }
+    
+    public void setCapability(WsResourceCapability capability)
+    {
+        // FIXME: check for duplicate set
+        _capability = capability;
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/SimpleResourcePropertiesSchema.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/SimpleResourcePropertiesSchema.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/SimpleResourcePropertiesSchema.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/schema/impl/SimpleResourcePropertiesSchema.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,217 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.schema.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.TransformerException;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XPathUtils;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.util.xml.XsdUtils;
+import org.apache.muse.ws.resource.WsResourceCapability;
+import org.apache.muse.ws.resource.properties.schema.ResourcePropertiesSchema;
+
+/**
+ *
+ * SimpleResourcePropertiesSchema is Muse's default implementation of the WS-RP 
+ * ({@linkplain ResourcePropertiesSchema ResourcePropertiesSchema}). data 
+ * structure. Instances of this schema structure can be created from a DOM 
+ * Element containing the WS-RP document definition.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleResourcePropertiesSchema implements ResourcePropertiesSchema
+{
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = 
+        MessagesFactory.get(SimpleResourcePropertiesSchema.class);
+    
+    //
+    // All of the type definitions in the schema. This is a 
+    // Map[QName, PropertySchemaDefinition].
+    //
+    private Map _definitionsByQName = new HashMap();
+    
+    /**
+     * 
+     * Creates a new schema by parsing the WS-RP document and storing the 
+     * various property data for future lookups. The child xsd:elements in 
+     * the given Element represent the actual properties in the WS-RP 
+     * definition; the types of these properties must be referred to using 
+     * the XSD <em>ref</em> attribute.
+     *
+     * @param wsrpElement
+     *        The DOM Element containing the WS-RP document's type definition.
+     *
+     */
+    public SimpleResourcePropertiesSchema(Element wsrpElement)
+    {
+        if (wsrpElement == null)
+            throw new NullPointerException(_MESSAGES.get("NullPropertiesElement"));
+        
+        QName qname = XmlUtils.getElementQName(wsrpElement);
+        
+        //
+        // make sure we're starting from an element fragment
+        //
+        if (!qname.equals(XsdUtils.ELEMENT_QNAME))
+            throw new RuntimeException(_MESSAGES.get("NotAnElement"));
+        
+        //
+        // get the name of the WS-RP collection
+        //
+        String name = wsrpElement.getAttribute(XsdUtils.NAME);
+        
+        if (name == null || name.length() == 0)
+            throw new RuntimeException(_MESSAGES.get("NoPropertiesName"));
+        
+        qname = XmlUtils.parseQName(name, wsrpElement);
+        
+        //
+        // get all of the elements defined in the WS-RP sequence
+        //
+        // NOTE: we only get those properties declared with "ref"
+        //
+        Node[] elements = getAllPropertyElements(wsrpElement);        
+        
+        //
+        // for every property element, record its metadata/definition
+        //
+        for (int n = 0; n < elements.length; ++n)
+        {
+            Element next = (Element)elements[n];
+            String ref = next.getAttribute(XsdUtils.REF);
+            qname = XmlUtils.parseQName(ref, next);
+            
+            PropertySchemaDefinition definition = 
+                new PropertySchemaDefinition(qname, next);
+            _definitionsByQName.put(qname, definition); 
+        }
+    }
+    
+    /**
+     *
+     * @param wsrpElement
+     *        The DOM Element containing the WS-RP document definition.
+     * 
+     * @return All of the child xsd:element Elements that have a <em>ref</em> 
+     *         attribute { complexType/sequence/element[@ref] }.
+     *
+     */
+    private Node[] getAllPropertyElements(Element wsrpElement)
+    {
+        Element complexType = 
+            XmlUtils.getElement(wsrpElement, XsdUtils.COMPLEX_TYPE_QNAME);
+        Element sequence = 
+            XmlUtils.getElement(complexType, XsdUtils.SEQUENCE_QNAME);
+        
+        //
+        // get all elements defined with the ref attribute (the WS-RP 
+        // definition cannot define properties inline)
+        //
+        try
+        {
+            return XPathUtils.selectNodeList(sequence, "*[@ref]");
+        }
+        
+        catch (TransformerException error)
+        {
+            //
+            // this "should never happen" - the XPath is static
+            //
+            throw new RuntimeException(error);
+        }
+    }
+    
+    public int getMaxOccurs(QName property)
+    {
+        return getProperty(property).getMaxOccurs();
+    }
+
+    public int getMinOccurs(QName property)
+    {
+        return getProperty(property).getMinOccurs();
+    }
+    
+    protected PropertySchemaDefinition getProperty(QName property)
+    {
+        PropertySchemaDefinition definition = 
+            (PropertySchemaDefinition)_definitionsByQName.get(property);
+
+        if (definition == null)
+        {
+            Object[] filler = { property };
+            throw new RuntimeException(_MESSAGES.get("PropertyNotFound", filler));
+        }
+        
+        return definition;        
+    }
+
+    public Collection getPropertyNames()
+    {
+        return Collections.unmodifiableSet(_definitionsByQName.keySet());
+    }
+    
+    public QName getPropertyTypeName(QName property)
+    {
+        return getProperty(property).getPropertyTypeName();
+    }
+    
+    public boolean hasProperty(QName property)
+    {
+        return _definitionsByQName.containsKey(property);
+    }
+    
+    public boolean isMaxUnbounded(QName property)
+    {
+        return getProperty(property).isMaxUnbounded();
+    }
+    
+    public boolean isNillable(QName property)
+    {
+        return getProperty(property).isNillable();
+    }
+
+    public WsResourceCapability getCapability(QName property)
+    {
+        return getProperty(property).getCapability();
+    }
+
+    public boolean hasCapability(QName property)
+    {
+        return getCapability(property) != null;
+    }
+
+    public void setCapability(QName property, WsResourceCapability capability)
+    {
+        getProperty(property).setCapability(capability);
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/AbstractSetRequestComponent.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/AbstractSetRequestComponent.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/AbstractSetRequestComponent.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/AbstractSetRequestComponent.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,154 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.set.impl;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.resource.properties.impl.WsrpUtils;
+import org.apache.muse.ws.resource.properties.set.SetRequestComponent;
+
+/**
+ *
+ * AbstractSetRequestComponent is a the base class for the WS-ResourceProperties 
+ * QueryResourceProperties operations. It provides the basic creation and 
+ * execution mechanisms, as well as security.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public abstract class AbstractSetRequestComponent implements SetRequestComponent
+{
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = 
+        MessagesFactory.get(AbstractSetRequestComponent.class);
+    
+    //
+    // The name of the property to modify
+    //
+    private QName _qname = null;
+    
+    //
+    // The token that the WS-RP container can use to determine if this 
+    // request was created from within the touchpoint instance or by 
+    // an external request. The default is a unique, non-null token that 
+    // will not map to any WS-RP container.
+    //
+    private Object _securityToken = new Object();
+    
+    //
+    // The values (instances) of the property to use during modification
+    //
+    private Element[] _valuesXML = null;
+    
+    public int getNumberOfValues()
+    {
+        return _valuesXML.length;
+    }
+    
+    public QName getPropertyName()
+    {
+        return _qname;
+    }
+    
+    public Object getSecurityToken()
+    {
+        return _securityToken;
+    }
+    
+    public Element getValue(int index)
+    {
+        return _valuesXML[index];
+    }
+    
+    public Element[] getValues()
+    {
+        return _valuesXML;
+    }
+    
+    public final void setPropertyName(QName qname)
+    {
+        if (qname == null)
+            throw new NullPointerException(_MESSAGES.get("NullQName"));
+        
+        _qname = qname;
+    }
+    
+    public final void setSecurityToken(Object securityToken)
+    {
+        _securityToken = securityToken;
+    }
+    
+    public final void setValues(Object[] values)
+    {
+        if (values == null)
+            throw new NullPointerException(_MESSAGES.get("NullValueArray"));
+        
+        if (values.length == 0)
+        {
+            _valuesXML = EMPTY_VALUES;
+            return;
+        }
+
+        QName qname = getPropertyName();
+        
+        int firstNonNull = -1;
+        
+        for (int n = 0; n < values.length && firstNonNull < 0; ++n)
+            if (values[n] != null)
+                firstNonNull = n;
+        
+        if (firstNonNull < 0)
+        {
+            firstNonNull = 0;
+            Element xml = XmlUtils.createElement(qname);
+            
+            for (int n = 0; n < values.length; ++n)
+                values[n] = xml;                
+        }
+        
+        Class type = values[firstNonNull].getClass();
+            
+        if (Element.class.isAssignableFrom(type))
+        {
+            _valuesXML = new Element[values.length];
+            
+            for (int n = 0; n < values.length; ++n)
+                _valuesXML[n] = XmlUtils.createElement(qname, values[n]);
+        }
+        
+        else
+        {
+            try
+            {
+                _valuesXML = WsrpUtils.convertToElements(values, type, qname);
+            }
+            
+            catch (Throwable error)
+            {
+                throw new RuntimeException(error.getMessage(), error);
+            }
+        }
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/DeleteRequest.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/DeleteRequest.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/DeleteRequest.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/DeleteRequest.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,115 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.set.impl;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+
+/**
+ *
+ * DeleteRequest is a serializer/deserializer for the WS-ResourceProperties 
+ * Delete operation, which is part of SetResourceProperties.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class DeleteRequest extends AbstractSetRequestComponent
+{
+    //
+    // The name of this SetResourceProperties operation
+    //
+    public static final String OPERATION = "Delete";
+    
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = MessagesFactory.get(DeleteRequest.class);
+    
+    public DeleteRequest(QName qname)
+    {
+        if (qname == null)
+            throw new NullPointerException(_MESSAGES.get("NullQName"));
+        
+        setPropertyName(qname);
+        setValues(new Object[0]);
+    }
+    
+    public DeleteRequest(Element request)
+    {
+        if (request == null)
+            throw new NullPointerException(_MESSAGES.get("NullRequestElement"));
+        
+        String property = request.getAttribute(WsrpConstants.RESOURCE_PROPERTY);
+        QName qname = XmlUtils.parseQName(property, request);
+        
+        setPropertyName(qname);
+        setValues(new Object[0]);
+    }
+    
+    public void execute(ResourcePropertyCollection properties)
+        throws BaseFault
+    {
+        if (properties == null)
+            throw new NullPointerException(_MESSAGES.get("NullProperties"));
+        
+        properties.deleteResourceProperty(getPropertyName(), getSecurityToken());
+    }
+    
+    public String toString()
+    {
+        return XmlUtils.toString(toXML(), false);
+    }
+    
+    public Element toXML()
+    {
+        return toXML(XmlUtils.EMPTY_DOC);
+    }
+    
+    public Element toXML(Document doc)
+    {
+        if (doc == null)
+            throw new NullPointerException(_MESSAGES.get("NullDocument"));
+        
+        QName qname = getPropertyName();
+        String prefix = qname.getPrefix();
+        String uri = qname.getNamespaceURI();
+        
+        Element root = XmlUtils.createElement(doc, WsrpConstants.DELETE_QNAME);
+        
+        //
+        // if the name of the property has a prefix/NS, we need to set the 
+        // NS attribute in the request element
+        //
+        if (prefix != null && prefix.length() > 0)
+            XmlUtils.setNamespaceAttribute(root, prefix, uri);
+        
+        String propertyName = XmlUtils.toString(qname);
+        root.setAttribute(WsrpConstants.RESOURCE_PROPERTY, propertyName);
+        
+        return root;
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/InsertRequest.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/InsertRequest.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/InsertRequest.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/InsertRequest.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,145 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.set.impl;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.ext.faults.InvalidMessageFormatFault;
+import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+
+/**
+ *
+ * InsertRequest is a serializer/deserializer for the WS-ResourceProperties 
+ * Insert operation, which is part of SetResourceProperties.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class InsertRequest extends AbstractSetRequestComponent
+{
+    //
+    // The name of this SetResourceProperties operation
+    //
+    public static final String OPERATION = "Insert";
+
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = MessagesFactory.get(InsertRequest.class);
+    
+    public InsertRequest(QName qname)
+    {
+        this(qname, 1);
+    }
+    
+    public InsertRequest(QName qname, int numberOfCopies)
+    {
+        this(qname, new Object[numberOfCopies]);
+    }
+    
+    public InsertRequest(QName qname, Object value)
+    {
+        this(qname, new Object[]{ value });
+    }
+    
+    public InsertRequest(QName qname, Object[] values)
+    {
+        if (qname == null)
+            throw new NullPointerException(_MESSAGES.get("NullQName"));
+        
+        if (values == null)
+            throw new NullPointerException(_MESSAGES.get("NullValueArray"));
+        
+        if (values.length == 0)
+            throw new IllegalArgumentException(_MESSAGES.get("EmptyValuesArray"));
+        
+        setPropertyName(qname);
+        setValues(values);
+    }
+    
+    public InsertRequest(Element request)
+        throws BaseFault
+    {
+        if (request == null)
+            throw new NullPointerException(_MESSAGES.get("NullRequestElement"));
+        
+        Element[] children = XmlUtils.getAllElements(request);
+        
+        if (children.length == 0)
+            throw new InvalidMessageFormatFault(_MESSAGES.get("NoPropertiesFoundInsert"));
+        
+        //
+        // the WS-RP spec says that in an Insert request with multiple 
+        // elements, all elements MUST have the same qualified name
+        //
+        
+        QName firstQName = XmlUtils.getElementQName(children[0]);
+        
+        Element[] matches = XmlUtils.getElements(request, firstQName);
+        
+        if (matches.length != children.length)
+            throw new InvalidMessageFormatFault(_MESSAGES.get("NamesNotEqualInsert"));
+        
+        setPropertyName(firstQName);
+        setValues(children);
+    }
+
+    public void execute(ResourcePropertyCollection properties)
+        throws BaseFault
+    {
+        if (properties == null)
+            throw new NullPointerException(_MESSAGES.get("NullProperties"));
+        
+        properties.insertResourceProperty(getPropertyName(), getValues(), getSecurityToken());
+    }
+    
+    public String toString()
+    {
+        return XmlUtils.toString(toXML(), false);
+    }
+    
+    public Element toXML()
+    {
+        return toXML(XmlUtils.EMPTY_DOC);
+    }
+    
+    public Element toXML(Document doc)
+    {
+        if (doc == null)
+            throw new NullPointerException(_MESSAGES.get("NullDocument"));
+        
+        Element root = XmlUtils.createElement(doc, WsrpConstants.INSERT_QNAME);
+        Element[] values = getValues();
+        
+        for (int n = 0; n < values.length; ++n)
+        {
+            Element next = (Element)doc.importNode(values[n], true);
+            root.appendChild(next);
+        }
+        
+        return root;
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/Messages.properties?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/Messages.properties (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/Messages.properties Thu Jun 15 15:16:59 2006
@@ -0,0 +1,15 @@
+NullValue = The property value is null.
+NullValueArray = The array holding the property values is null.
+EmptyValuesArray = The array of property values is null. If you want to set properties to null, you still need a non-empty array - just add null value(s) to it.
+NoPropertiesFoundInsert = The Insert request element did not include any property instances. An Insert operation must specify at least one property.
+NamesNotEqualInsert = The Insert request contained property instances that do not have the same QName. The WS-RP spec requires that all properties added with an Insert operation be of the same name.
+NoPropertiesFoundUpdate = The Update request element did not include a property instance (value). An Update operation must specify a property instance that can be used to modify (update) all of the current properties with the same name.
+EmptySetRequestBuilt = Could not serialize SetResourceProperties request to XML because it is empty - there are no concrete 'set' operations in the request. Valid SetRequests can be built using the SetRequest.add method.
+EmptySetRequest = The SetResourceProperties request had no concrete 'set' operations. The WS-RP spec requires that the request have at least one Insert/Delete/Update operation.
+NullQuery = The query string is null.
+NullDialect = The dialect string is null.
+NoQueryExpressionFound = The QueryResourceProperties request does not have a QueryExpression element; this element must be present in order to get the query string and dialect for the request.
+NoQueryFound = The QueryExpression element in the QueryResourceProperties request did not contain a query string. What is the query to run?
+NoDialectFound = The QueryExpression element in the QueryResourceProperties request did not have a dialect attribute. What is the language of the query being run?
+NullNodeList = The DOM NodeList with the results of the QueryResourceProperties query is null.
+InvalidSet = The SetResourceProperties request contained an invalid operation, 'XXX'. The only valid operations are Insert, Update, and Delete.

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SetHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SetHandler.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SetHandler.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SetHandler.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,67 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.set.impl;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.core.routing.AbstractMessageHandler;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+import org.apache.muse.ws.resource.properties.set.SetOperationFactory;
+
+/**
+ *
+ * SetHandler is the parser for the WS-ResourceProperties 
+ * SetResourceProperties operation.
+ *
+ * @author Dan Jemiolo (danjemiolo)
+ * 
+ * @see org.apache.muse.ws.resource.properties.set.SetResourceProperties
+ *
+ */
+
+public class SetHandler extends AbstractMessageHandler
+{
+    //
+    // Used to parse all different types of SetResourceProperties
+    //
+    private static final SetOperationFactory _FACTORY = new SimpleSetOperationFactory();
+    
+    /**
+     * 
+     * The wsrp:SetResourcePropertiesResponse content is always the same, 
+     * so we can share one instance of SetResponse among all components.
+     * 
+     */
+    public static final SetResponse SET_RESPONSE = new SetResponse();
+    
+    public SetHandler()
+    {
+        super(WsrpConstants.SET_QNAME);
+    }
+    
+    public Object[] fromXML(Element xml) 
+        throws SoapFault
+    {
+        return new Object[]{ _FACTORY.createSet(xml) };
+    }
+    
+    public Element toXML(Object result)
+    {
+        return SET_RESPONSE.toXML();
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SetResponse.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SetResponse.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SetResponse.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SetResponse.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,58 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.set.impl;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+import org.apache.muse.util.xml.XmlSerializable;
+import org.apache.muse.util.xml.XmlUtils;
+
+/**
+ *
+ * SetResponse is a serializer/deserializer for the WS-ResourceProperties 
+ * SetResourceProperties operation's response content.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SetResponse implements XmlSerializable
+{
+    private static Element _xml = null;
+    
+    static
+    {
+        _xml = XmlUtils.createElement(XmlUtils.EMPTY_DOC, WsrpConstants.SET_RESPONSE_QNAME);
+    }
+    
+    public String toString()
+    {
+        return XmlUtils.toString(toXML(), false);
+    }
+    
+    public Element toXML()
+    {
+        return _xml;
+    }
+    
+    public Element toXML(Document doc)
+    {
+        return (Element)doc.importNode(_xml, true);
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetCapability.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetCapability.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetCapability.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetCapability.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,62 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.set.impl;
+
+import java.lang.reflect.Method;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.core.routing.MessageHandler;
+import org.apache.muse.util.ReflectUtils;
+import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;
+import org.apache.muse.ws.resource.properties.set.SetCapability;
+import org.apache.muse.ws.resource.properties.set.SetRequest;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+
+public class SimpleSetCapability 
+    extends AbstractWsResourceCapability implements SetCapability
+{
+    protected MessageHandler createSetHandler()
+    {
+        MessageHandler handler = new SetHandler();
+        
+        Method method = ReflectUtils.getFirstMethod(getClass(), "setResourceProperties");
+        handler.setMethod(method);
+        
+        return handler;
+    }
+    
+    public void initialize() 
+        throws SoapFault
+    {
+        super.initialize();
+        
+        setMessageHandler(createSetHandler());
+    }
+
+    public Element putResourcePropertyDocument(Element wsrpDoc)
+        throws SoapFault
+    {
+        return getWsResource().getPropertyCollection().putResourcePropertyDocument(wsrpDoc);
+    }
+    
+    public void setResourceProperties(SetRequest request) 
+        throws SoapFault
+    {
+        getWsResource().getPropertyCollection().setResourceProperties(request);
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetOperationFactory.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetOperationFactory.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetOperationFactory.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetOperationFactory.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,171 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.set.impl;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.ext.faults.InvalidMessageFormatFault;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+import org.apache.muse.ws.resource.properties.set.SetOperationFactory;
+import org.apache.muse.ws.resource.properties.set.SetRequest;
+import org.apache.muse.ws.resource.properties.set.SetRequestComponent;
+
+/**
+ *
+ * SimpleSetOperationFactory provides an API for constructing and parsing WS-RP 
+ * SetResourceProperties requests, including the Insert, Delete, 
+ * and Update operations. There are convenience methods for creating 
+ * outbound requests with each operation type as well as a factory 
+ * method for parsing inbound XML into executables.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleSetOperationFactory implements SetOperationFactory
+{
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = MessagesFactory.get(SimpleSetOperationFactory.class);
+
+    /**
+     * 
+     * This is a convenience method that creates a new SimpleSetRequest object 
+     * an populates it with a DeleteRequest for the given property.
+     *
+     * @param qname
+     *        The name of the property to delete.
+     * 
+     */
+    public SetRequest createDelete(QName qname)
+    {
+        SetRequest set = new SimpleSetRequest();
+        set.addRequestComponent(new DeleteRequest(qname));
+        return set;
+    }
+
+    /**
+     * 
+     * This is a convenience method that creates a new SimpleSetRequest object 
+     * an populates it with a InsertRequest for the given property.
+     *
+     * @param qname
+     *        The name of the property to insert.
+     * 
+     * @param values
+     *        The initial values for each instance of the property. This 
+     *        array should not be null, nor empty.
+     * 
+     */
+    public SetRequest createInsert(QName qname, Object[] values)
+    {
+        SetRequest set = new SimpleSetRequest();
+        set.addRequestComponent(new InsertRequest(qname, values));
+        return set;
+    }
+    
+    /**
+     * 
+     * Parses the given XML fragment according to the WS-RP spec for 
+     * SetResourceProperties requests.
+     *
+     * @param request
+     *        An XML fragment containing a SetResourceProperties request.
+     * 
+     * @return A SimpleSetRequest that contains one AbstractSetRequestComponent for each 
+     *         operation defined in the request. This object can be used 
+     *         to execute the request against a WS-RP container.
+     * 
+     * @throws BaseFault
+     *         <ul>
+     *         <li>If the request is empty (contains no operations).</li>
+     *         <li>If one of the operation types is invalid (only Insert, 
+     *         Delete, and Update are allowed).</li>
+     *         <li>If one of the operations is not properly formatted.</li>
+     *         </ul>
+     *
+     */
+    public SetRequest createSet(Element request)
+        throws BaseFault
+    {
+        if (request == null)
+            throw new NullPointerException(_MESSAGES.get("NullRequestElement"));
+        
+        Element[] children = 
+            XmlUtils.getAllElements(request, WsrpConstants.NAMESPACE_URI);
+        
+        if (children.length == 0)
+            throw new InvalidMessageFormatFault(_MESSAGES.get("EmptySetRequest"));
+        
+        SetRequest set = new SimpleSetRequest();
+        
+        //
+        // build the different types of sets from XML
+        //
+        for (int n = 0; n < children.length; ++n)
+        {
+            String type = children[n].getLocalName();
+            
+            SetRequestComponent operation = null;
+            
+            if (type.equals(DeleteRequest.OPERATION))
+                operation = new DeleteRequest(children[n]);
+            
+            else if (type.equals(InsertRequest.OPERATION))
+                operation = new InsertRequest(children[n]);
+            
+            else if (type.equals(UpdateRequest.OPERATION))
+                operation = new UpdateRequest(children[n]);
+            
+            else
+            {
+                Object[] filler = { type };
+                throw new InvalidMessageFormatFault(_MESSAGES.get("InvalidSet", filler));
+            }
+            
+            set.addRequestComponent(operation);
+        }
+        
+        return set;
+    }
+
+    /**
+     * 
+     * This is a convenience method that creates a new SimpleSetRequest object 
+     * an populates it with a UpdateRequest for the given property.
+     *
+     * @param qname
+     *        The name of the property to update.
+     * 
+     * @param values
+     *        The values that will be copied to each instance of the property.
+     * 
+     */
+    public SetRequest createUpdate(QName qname, Object[] values)
+    {
+        SetRequest set = new SimpleSetRequest();
+        set.addRequestComponent(new UpdateRequest(qname, values));
+        return set;
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetRequest.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetRequest.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetRequest.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/SimpleSetRequest.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,109 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.set.impl;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+import org.apache.muse.ws.resource.properties.set.SetRequest;
+import org.apache.muse.ws.resource.properties.set.SetRequestComponent;
+import org.apache.muse.util.xml.XmlUtils;
+
+/**
+ *
+ * SimpleSetRequest is a simple container that represents the WS-ResourceProperties 
+ * SetResourceProperties operation's request content. It may contain one or 
+ * more executable {@linkplain AbstractSetRequestComponent SetRequestComponents}.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleSetRequest implements SetRequest
+{
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = MessagesFactory.get(SimpleSetRequest.class);
+    
+    //
+    // The individual operations that insert, update, delete, etc.
+    //
+    private List _operations = new LinkedList();
+    
+    public void addRequestComponent(SetRequestComponent operation)
+    {
+        if (operation == null)
+            throw new NullPointerException(_MESSAGES.get("NullSetRequestComponent"));
+        
+        _operations.add(operation);
+    }
+    
+    public List getRequestComponents()
+    {
+        return Collections.unmodifiableList(_operations);
+    }
+
+    public String toString()
+    {
+        return XmlUtils.toString(toXML(), false);
+    }
+    
+    public Element toXML()
+    {
+        return toXML(XmlUtils.EMPTY_DOC);
+    }
+    
+    public Element toXML(Document doc)
+    {
+        if (doc == null)
+            throw new NullPointerException(_MESSAGES.get("NullDocument"));
+        
+        Element root = XmlUtils.createElement(doc, WsrpConstants.SET_QNAME);
+        
+        //
+        // the SetResourceProperties XML is an aggregate of the XML for 
+        // the concrete set operations (insert/delete/update/etc)
+        //
+        List ops = getRequestComponents();
+        
+        //
+        // can't have empty set requests
+        //
+        if (ops.isEmpty())
+            throw new IllegalStateException(_MESSAGES.get("EmptySetRequestBuilt"));
+        
+        Iterator i = ops.iterator();
+        
+        while (i.hasNext())
+        {
+            AbstractSetRequestComponent next = (AbstractSetRequestComponent)i.next();
+            Element nextXML = next.toXML(doc);
+            root.appendChild(nextXML);
+        }
+        
+        return root;
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/UpdateRequest.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/UpdateRequest.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/UpdateRequest.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/properties/set/impl/UpdateRequest.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,119 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.properties.set.impl;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.ext.faults.InvalidMessageFormatFault;
+import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+
+/**
+ *
+ * UpdateRequest is a serializer/deserializer for the WS-ResourceProperties 
+ * Update operation, which is part of SetResourceProperties.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class UpdateRequest extends AbstractSetRequestComponent
+{
+    //
+    // The name of this SetResourceProperties operation
+    //
+    public static final String OPERATION = "Update";
+
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = MessagesFactory.get(UpdateRequest.class);
+    
+    public UpdateRequest(QName qname, Object value)
+    {
+        this(qname, new Object[]{ value });
+    }
+    
+    public UpdateRequest(QName qname, Object[] values)
+    {
+        if (qname == null)
+            throw new NullPointerException(_MESSAGES.get("NullQName"));
+        
+        setPropertyName(qname);
+        setValues(values);
+    }
+    
+    public UpdateRequest(Element request)
+        throws BaseFault
+    {
+        if (request == null)
+            throw new NullPointerException(_MESSAGES.get("NullRequestElement"));
+        
+        Element[] properties = XmlUtils.getAllElements(request);
+        
+        if (properties.length == 0)
+            throw new InvalidMessageFormatFault(_MESSAGES.get("NoPropertiesFoundUpdate"));
+        
+        setPropertyName(XmlUtils.getElementQName(properties[0]));
+        setValues(properties);
+    }
+
+    public void execute(ResourcePropertyCollection properties)
+        throws BaseFault
+    {
+        if (properties == null)
+            throw new NullPointerException(_MESSAGES.get("NullProperties"));
+        
+        Object[] values = getValues();
+        
+        properties.updateResourceProperty(getPropertyName(), values, getSecurityToken());
+    }
+    
+    public String toString()
+    {
+        return XmlUtils.toString(toXML(), false);
+    }
+    
+    public Element toXML()
+    {
+        return toXML(XmlUtils.EMPTY_DOC);
+    }
+    
+    public Element toXML(Document doc)
+    {
+        if (doc == null)
+            throw new NullPointerException(_MESSAGES.get("NullDocument"));
+        
+        Element root = XmlUtils.createElement(doc, WsrpConstants.UPDATE_QNAME);
+        Element[] values = getValues();
+        
+        for (int n = 0; n < values.length; ++n)
+        {
+            Element next = (Element)doc.importNode(values[n], true);
+            root.appendChild(next);
+        }
+        
+        return root;
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/remote/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/remote/Messages.properties?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/remote/Messages.properties (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/remote/Messages.properties Thu Jun 15 15:16:59 2006
@@ -0,0 +1,4 @@
+NullDestinationEPR = The proxy's destination EPR is null. Where are we going to send requests?
+NullSourceEPR = The proxy's source EPR is null. What is the caller's EPR?
+NullSoapClient = The SoapClient is null. How are we going to send requests?
+NullProxyHandler = The ProxyHandler is null. How are we going to send requests?

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/remote/WsResourceClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/remote/WsResourceClient.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/remote/WsResourceClient.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/remote/WsResourceClient.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,212 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.remote;
+
+import java.net.URI;
+import java.text.ParseException;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.muse.core.AbstractResourceClient;
+import org.apache.muse.core.Environment;
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.ws.resource.lifetime.WsrlConstants;
+import org.apache.muse.ws.resource.lifetime.impl.SetTerminationTime;
+import org.apache.muse.ws.resource.lifetime.impl.SetTerminationTimeResponse;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+import org.apache.muse.ws.resource.properties.get.impl.GetMultipleRequest;
+import org.apache.muse.ws.resource.properties.get.impl.GetRequest;
+import org.apache.muse.ws.resource.properties.impl.WsrpUtils;
+import org.apache.muse.ws.resource.properties.query.impl.QueryRequest;
+import org.apache.muse.ws.resource.properties.set.SetOperationFactory;
+import org.apache.muse.ws.resource.properties.set.SetRequest;
+import org.apache.muse.ws.resource.properties.set.impl.SimpleSetOperationFactory;
+import org.apache.muse.ws.addressing.soap.SoapClient;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.util.xml.XmlUtils;
+
+/**
+ *
+ * WsResourceClient is a web service proxy that allows users to invoke standard 
+ * WSRF operations without writing any XML plumbing code. This class includes 
+ * all of the operations from WSRL and WSRP, but this does <b>not</b> mean that 
+ * all Muse resource types implement all WSRL and WSRP operations. It is more 
+ * convenient to have one proxy class since all WSRL and WSRP operations are 
+ * defined as separate capabilities (which would result in one proxy per 
+ * operation); if users need more detailed information about what operations 
+ * are supported by a resource, they can use the WS-MetadataExchange client 
+ * and/or the Muse ResourceInspector tool.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class WsResourceClient extends AbstractResourceClient
+{
+    private static final SetOperationFactory _SET_FACTORY = new SimpleSetOperationFactory();
+    
+    public WsResourceClient(EndpointReference destination)
+    {
+        super(destination);
+    }
+    
+    public WsResourceClient(EndpointReference destination, 
+                            EndpointReference source)
+    {
+        super(destination, source);
+    }
+    
+    public WsResourceClient(EndpointReference destination,
+                            EndpointReference source, 
+                            Environment environment)
+    {
+        super(destination, source, environment);
+    }
+    
+    public WsResourceClient(EndpointReference destination,
+                            EndpointReference source, 
+                            SoapClient soapClient)
+    {
+        super(destination, source, soapClient);
+    }
+    
+    public void deleteResourceProperty(QName qname)
+        throws SoapFault
+    {
+        SetRequest set = _SET_FACTORY.createDelete(qname);
+        setResourceProperties(set);
+    }
+    
+    public void destroy() 
+        throws SoapFault
+    {
+        URI action = URI.create(WsrlConstants.DESTROY_URI);
+        Element body = XmlUtils.createElement(WsrlConstants.DESTROY_QNAME);
+        
+        invoke(action, body);
+    }
+    
+    public Element[] getMultipleResourceProperties(QName[] qnames) 
+        throws SoapFault
+    {
+        GetMultipleRequest get = new GetMultipleRequest(qnames);        
+        URI action = URI.create(WsrpConstants.GET_MULTIPLE_PROPERTIES_URI);
+        
+        Element response = invoke(action, get.toXML());
+        
+        return XmlUtils.getAllElements(response);
+    }
+    
+    public Element[] getResourceProperty(QName qname) 
+        throws SoapFault
+    {
+        GetRequest get = new GetRequest(qname);        
+        URI action = URI.create(WsrpConstants.GET_RESOURCE_PROPERTY_URI);
+        
+        Element response = invoke(action, get.toXML());
+        
+        return XmlUtils.getAllElements(response);
+    }
+    
+    public Element getResourcePropertyDocument()
+        throws SoapFault
+    {
+        Element request = XmlUtils.createElement(WsrpConstants.GET_DOCUMENT_QNAME);
+        URI action = URI.create(WsrpConstants.GET_RP_DOCUMENT_URI);
+        
+        Element response = invoke(action, request);
+        
+        return XmlUtils.getFirstElement(response);
+    }
+    
+    public Element putResourcePropertyDocument(Element wsrpDoc)
+        throws SoapFault
+    {
+        Element request = XmlUtils.createElement(XmlUtils.EMPTY_DOC, WsrpConstants.PUT_DOCUMENT_QNAME, wsrpDoc, false);
+        URI action = URI.create(WsrpConstants.PUT_RP_DOCUMENT_URI);
+        
+        Element response = invoke(action, request);
+        
+        return XmlUtils.getFirstElement(response);
+    }
+    
+    public Object getPropertyAsObject(QName qname, Class type)
+        throws SoapFault
+    {
+        Element[] properties = getResourceProperty(qname);
+        return WsrpUtils.convertToObjects(properties, type);
+    }
+    
+    public void insertResourceProperty(QName qname, Object[] values)
+        throws SoapFault
+    {
+        SetRequest set = _SET_FACTORY.createInsert(qname, values);
+        setResourceProperties(set);
+    }
+    
+    public Node[] queryResourceProperties(String query, String dialect) 
+        throws SoapFault
+    {
+        QueryRequest request = new QueryRequest(query, dialect);        
+        URI action = URI.create(WsrpConstants.QUERY_RESOURCE_PROPERTIES_URI);
+        
+        Element response = invoke(action, request.toXML());
+        
+        NodeList children = response.getChildNodes();
+        return XmlUtils.convertToArray(children);
+    }
+    
+    public void setResourceProperties(SetRequest request) 
+        throws SoapFault
+    {
+        URI action = URI.create(WsrpConstants.SET_RESOURCE_PROPERTIES_URI);
+        invoke(action, request.toXML());
+    }
+    
+    public Date setTerminationTime(Date time) 
+        throws SoapFault
+    {
+        SetTerminationTime set = new SetTerminationTime(time);        
+        URI action = URI.create(WsrlConstants.SET_TERMINATION_URI);
+        
+        Element response = invoke(action, set.toXML());
+        
+        try
+        {
+            SetTerminationTimeResponse setResponse = 
+                new SetTerminationTimeResponse(response);
+            return setResponse.getTerminationTime();
+        }
+        
+        catch (ParseException error)
+        {
+            throw new SoapFault(error.getMessage(), error);
+        }
+    }
+    
+    public void updateResourceProperty(QName qname, Object[] values)
+        throws SoapFault
+    {
+        SetRequest set = _SET_FACTORY.createUpdate(qname, values);
+        setResourceProperties(set);
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddHandler.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddHandler.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddHandler.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,53 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.sg.impl;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.core.routing.AbstractMessageHandler;
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.ws.resource.sg.WssgConstants;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+
+/**
+ *
+ * AddHandler is the parser for the WS-ServiceGroup Add operation.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class AddHandler extends AbstractMessageHandler
+{
+    public AddHandler()
+    {
+        super(WssgConstants.ADD_QNAME);
+    }
+
+    public Object[] fromXML(Element xml) 
+        throws SoapFault
+    {
+        AddRequest add = new AddRequest(xml);
+        return new Object[]{ add.getMemberEPR(), add.getTerminationTime() };
+    }
+
+    public Element toXML(Object result)
+    {
+        AddResponse response = new AddResponse((EndpointReference)result);
+        return response.toXML();
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddRequest.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddRequest.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddRequest.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddRequest.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,157 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.sg.impl;
+
+import java.text.ParseException;
+import java.util.Date;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.ws.resource.ext.faults.InvalidMessageFormatFault;
+import org.apache.muse.ws.resource.remote.WsResourceClient;
+import org.apache.muse.ws.resource.sg.WssgConstants;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.util.xml.XmlSerializable;
+import org.apache.muse.util.xml.XmlUtils;
+
+/**
+ *
+ * AddRequest is a serializer/deserializer for the WS-ServiceGroup Add 
+ * operation's request content.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class AddRequest implements XmlSerializable
+{
+    private static Messages _MESSAGES = MessagesFactory.get(AddRequest.class);
+    
+    private Element _content = null;
+    
+    private EndpointReference _memberEPR = null;
+    
+    private Date _termination = null;
+    
+    public AddRequest(Element xml)
+        throws InvalidMessageFormatFault
+    {
+        if (xml == null)
+            throw new NullPointerException(_MESSAGES.get("NullElement"));
+        
+        Element eprXML = XmlUtils.getElement(xml, WssgConstants.MEMBER_EPR_QNAME);
+        
+        if (eprXML == null)
+            throw new InvalidMessageFormatFault(_MESSAGES.get("NoMemberEPR"));
+        
+        try
+        {
+            _memberEPR = new EndpointReference(eprXML);
+        }
+        
+        catch (SoapFault error)
+        {
+            throw new InvalidMessageFormatFault(error);
+        }
+        
+        _content = XmlUtils.getElement(xml, WssgConstants.CONTENT_QNAME);
+        
+        Element timeXML = XmlUtils.getElement(xml, WssgConstants.INIT_TERMINATION_QNAME);
+        
+        try
+        {
+            if (timeXML != null)
+                _termination = XmlUtils.getDate(timeXML);
+        }
+        
+        catch (ParseException error)
+        {
+            throw new InvalidMessageFormatFault(error);
+        }
+    }
+    
+    public AddRequest(EndpointReference memberEPR, Date termination)
+    {
+        if (memberEPR == null)
+            throw new NullPointerException(_MESSAGES.get("NullMemberEPR"));
+        
+        _memberEPR = memberEPR;
+        _termination = termination;
+    }
+    
+    public EndpointReference getMemberEPR()
+    {
+        return _memberEPR;
+    }
+    
+    public Element getContent()
+    {
+        return _content;
+    }
+    
+    public Date getTerminationTime()
+    {
+        return _termination;
+    }
+
+    public Element toXML()
+    {
+        return toXML(XmlUtils.EMPTY_DOC);
+    }
+
+    public Element toXML(Document factory)
+    {
+        if (factory == null)
+            throw new NullPointerException(_MESSAGES.get("NullDocument"));
+        
+        Element root = XmlUtils.createElement(factory, WssgConstants.ADD_QNAME);
+        
+        EndpointReference epr = getMemberEPR();
+        XmlUtils.setElement(root, WssgConstants.MEMBER_EPR_QNAME, epr.toXML());
+        
+        WsResourceClient member = new WsResourceClient(epr);
+        Element content = getContent();
+        
+        try
+        {
+            if (content != null)
+            {
+                Element[] results = member.getResourceProperty(WssgConstants.CONTENT_QNAME);
+                content = results[0];
+            }
+        }
+        
+        catch (SoapFault error)
+        {
+            throw new RuntimeException(error.getMessage(), error);
+        }
+        
+        content = (Element)factory.importNode(content, true);
+        root.appendChild(content);
+        
+        Date time = getTerminationTime();
+        
+        if (time != null)
+            XmlUtils.setElement(root, WssgConstants.INIT_TERMINATION_QNAME, time);
+        
+        return root;
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddResponse.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddResponse.java?rev=414694&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddResponse.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/sg/impl/AddResponse.java Thu Jun 15 15:16:59 2006
@@ -0,0 +1,136 @@
+/*=============================================================================*
+ *  Copyright 2006 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.muse.ws.resource.sg.impl;
+
+import java.text.ParseException;
+import java.util.Date;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.resource.ext.faults.InvalidMessageFormatFault;
+import org.apache.muse.ws.resource.remote.WsResourceClient;
+import org.apache.muse.ws.resource.sg.WssgConstants;
+import org.apache.muse.util.xml.XmlSerializable;
+import org.apache.muse.util.xml.XmlUtils;
+
+/**
+ *
+ * AddResponse is a serializer/deserializer for the WS-ServiceGroup Add 
+ * operation's response content.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class AddResponse implements XmlSerializable
+{
+    private static Messages _MESSAGES = MessagesFactory.get(AddRequest.class);
+    
+    private Date _currentTime = new Date();
+    
+    private EndpointReference _entryEPR = null;
+    
+    private Date _terminationTime = null;
+    
+    public AddResponse(Element xml)
+        throws InvalidMessageFormatFault
+    {
+        if (xml == null)
+            throw new NullPointerException(_MESSAGES.get("NullElement"));
+        
+        Element eprXML = XmlUtils.getElement(xml, WssgConstants.SG_ENTRY_REFERENCE_QNAME);
+
+        if (eprXML == null)
+            throw new InvalidMessageFormatFault(_MESSAGES.get("NoEntryEPR"));
+        
+        try
+        {
+            _entryEPR = new EndpointReference(eprXML);
+        }
+        
+        catch (SoapFault error)
+        {
+            throw new InvalidMessageFormatFault(error);
+        }
+        
+        Element currentXML = XmlUtils.getElement(xml, WssgConstants.CURRENT_TIME_QNAME);
+        Element terminationXML = XmlUtils.getElement(xml, WssgConstants.TERMINATION_TIME_QNAME);
+        
+        try
+        {
+            _currentTime = XmlUtils.getDate(currentXML);
+            _terminationTime = XmlUtils.getDate(terminationXML);
+        }
+        
+        catch (ParseException error)
+        {
+            throw new InvalidMessageFormatFault(error);
+        }
+    }
+    
+    public AddResponse(EndpointReference entryEPR)
+    {
+        this(entryEPR, null);
+    }
+    
+    public AddResponse(EndpointReference entryEPR, Date terminationTime)
+    {
+        _entryEPR = entryEPR;
+        _terminationTime = terminationTime;
+    }
+    
+    public Date getCurrentTime()
+    {
+        return _currentTime;
+    }
+    
+    public Date getTerminationTime()
+    {
+        return _terminationTime;
+    }
+    
+    public WsResourceClient getEntryClient()
+    {
+        return new WsResourceClient(_entryEPR);
+    }
+
+    public Element toXML()
+    {
+        return toXML(XmlUtils.EMPTY_DOC);
+    }
+
+    public Element toXML(Document doc)
+    {
+        if (doc == null)
+            throw new NullPointerException(_MESSAGES.get("NullDocument"));
+        
+        Element root = XmlUtils.createElement(doc, WssgConstants.ADD_RESPONSE_QNAME);
+        
+        Element eprXML = _entryEPR.toXML(doc);
+        XmlUtils.setElement(root, WssgConstants.SG_ENTRY_REFERENCE_QNAME, eprXML);
+        
+        XmlUtils.setElement(root, WssgConstants.CURRENT_TIME_QNAME, getCurrentTime());
+        XmlUtils.setElement(root, WssgConstants.TERMINATION_TIME_QNAME, getTerminationTime());
+                
+        return root;
+    }
+}



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