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/08/16 21:12:42 UTC
svn commit: r431994 - in /webservices/muse/trunk/modules:
muse-wsrf-api/src/org/apache/muse/ws/resource/properties/set/faults/
muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/
Author: danj
Date: Wed Aug 16 12:12:41 2006
New Revision: 431994
URL: http://svn.apache.org/viewvc?rev=431994&view=rev
Log:
Fix for MUSE-29 - submitted by Mohammad Fakhar in JIRA.
Added:
webservices/muse/trunk/modules/muse-wsrf-api/src/org/apache/muse/ws/resource/properties/set/faults/UnableToPutResourcePropertyDocumentFault.java
Modified:
webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties
webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java
Added: webservices/muse/trunk/modules/muse-wsrf-api/src/org/apache/muse/ws/resource/properties/set/faults/UnableToPutResourcePropertyDocumentFault.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-api/src/org/apache/muse/ws/resource/properties/set/faults/UnableToPutResourcePropertyDocumentFault.java?rev=431994&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-api/src/org/apache/muse/ws/resource/properties/set/faults/UnableToPutResourcePropertyDocumentFault.java (added)
+++ webservices/muse/trunk/modules/muse-wsrf-api/src/org/apache/muse/ws/resource/properties/set/faults/UnableToPutResourcePropertyDocumentFault.java Wed Aug 16 12:12:41 2006
@@ -0,0 +1,39 @@
+
+package org.apache.muse.ws.resource.properties.set.faults;
+
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * UnableToPutResourcePropertyDocumentFault is ...
+ *
+ * @author Mohammad Fakhar
+ *
+ */
+
+public class UnableToPutResourcePropertyDocumentFault extends BaseFault
+{
+ private static final long serialVersionUID = 7882599000949695852L;
+
+ public UnableToPutResourcePropertyDocumentFault(Element xml)
+ {
+ super(xml);
+ }
+
+ public UnableToPutResourcePropertyDocumentFault(String message)
+ {
+ super(WsrpConstants.UNABLE_TO_PUT_RP_QNAME, message);
+ }
+
+ public UnableToPutResourcePropertyDocumentFault(String message, Throwable cause)
+ {
+ super(WsrpConstants.UNABLE_TO_PUT_RP_QNAME, message, cause);
+ }
+
+ public UnableToPutResourcePropertyDocumentFault(Throwable cause)
+ {
+ super(WsrpConstants.UNABLE_TO_PUT_RP_QNAME, cause);
+ }
+}
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties?rev=431994&r1=431993&r2=431994&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/Messages.properties Wed Aug 16 12:12:41 2006
@@ -43,3 +43,6 @@
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.
NoCapabilityForProperty = There is no capability that defines the property XXX. If you have a capability that is supposed to define this property, make sure the name is returned as part of WsResourceCapability.getPropertyNames().
+NullRPDoc = The Element passed in to the PutResourcePropertyDocument operation was null.
+PutRPDocReadOnlyError = PutResourcePropertyDocument operation tried to set XXX, which is an immutable property.
+PutRPDocError = The PutResourcePropertyDocument operation failed; the original cause was: XXX
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java?rev=431994&r1=431993&r2=431994&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/properties/impl/SimpleResourcePropertyCollection.java Wed Aug 16 12:12:41 2006
@@ -48,7 +48,9 @@
import org.apache.muse.ws.resource.properties.set.SetRequest;
import org.apache.muse.ws.resource.properties.set.SetRequestComponent;
import org.apache.muse.ws.resource.properties.set.faults.UnableToModifyResourcePropertyFault;
+import org.apache.muse.ws.resource.properties.set.faults.UnableToPutResourcePropertyDocumentFault;
import org.apache.muse.ws.resource.properties.set.impl.InsertRequest;
+import org.apache.muse.ws.resource.properties.set.impl.SimpleSetRequest;
import org.apache.muse.ws.resource.properties.set.impl.UpdateRequest;
/**
@@ -105,11 +107,11 @@
private ResourcePropertiesSchema _schema = null;
//
- // The security token allows other components in the touchpoint to
+ // The security token allows other components in the application to
// modify read-only properties that are not accessible by clients.
// Properties that are read-only may still be mutable (or appendable),
// which means that they may change, but cannot be explicitly modified
- // by touchpoint consumers.
+ // by consumers.
//
// Our security token is just a unique reference (which cannot be
// duplicated within the JVM).
@@ -384,12 +386,60 @@
}
}
+ protected SetRequest createInsertRequests(Element newDoc)
+ throws UnableToPutResourcePropertyDocumentFault, BaseFault
+ {
+ //
+ // Process each top level property from root of doc
+ //
+ Element[] properties = XmlUtils.getAllElements(newDoc);
+ SetRequest set = new SimpleSetRequest();
+
+ for (int i = 0; i < properties.length; i++)
+ {
+ QName propQName = XmlUtils.getElementQName(properties[i]);
+
+ if (getMetadata().isReadOnlyExternal(propQName))
+ {
+ Object[] filler = { propQName };
+ throw new UnableToPutResourcePropertyDocumentFault(_MESSAGES.get("PutRPDocReadOnlyError", filler));
+ }
+
+ SetRequestComponent insertComp = new InsertRequest(propQName, properties[i]);
+ set.addRequestComponent(insertComp);
+ }
+
+ return set;
+ }
+
public void deleteResourceProperty(QName qname)
throws BaseFault
{
deleteResourceProperty(qname, getSecurityToken());
}
+ protected void deleteMutableProperties()
+ throws BaseFault
+ {
+ Iterator i = getPropertyNames().iterator();
+
+ while (i.hasNext())
+ {
+ QName propName = (QName)i.next();
+
+ if (getMetadata().canDelete(propName))
+ {
+ //
+ // check if there are any instances to delete
+ //
+ Element[] instances = getResourceProperty(propName);
+
+ if (instances.length > 0)
+ deleteResourceProperty(propName, getSecurityToken());
+ }
+ }
+ }
+
public synchronized void deleteResourceProperty(QName qname, Object securityToken)
throws BaseFault
{
@@ -672,11 +722,41 @@
changeCompleted(qname, null, valuesXML[n]);
}
- public synchronized Element putResourcePropertyDocument(Element newDoc)
+ public synchronized Element putResourcePropertyDocument(Element newDoc)
+ throws UnableToPutResourcePropertyDocumentFault, BaseFault
{
- return newDoc; // FIXME: implement - this is harder than it first appears
+ if(newDoc == null)
+ throw new NullPointerException(_MESSAGES.get("NullRPDoc"));
+
+ try
+ {
+ //
+ // entire rp doc is replaced by this op, therefore all properties,
+ // except read-only properties, are deleted first
+ //
+ deleteMutableProperties();
+
+ //
+ // break the operation down into multiple set request insert components
+ //
+ SetRequest insertRequests = createInsertRequests(newDoc);
+ setResourceProperties(insertRequests);
+ }
+
+ catch (BaseFault fault)
+ {
+ throw new UnableToPutResourcePropertyDocumentFault(_MESSAGES.get("PutRPDocError"), fault);
+ }
+
+ //
+ // if final representation and intended representation are not the same,
+ // return the document on response
+ //
+ Element finalDoc = getResourcePropertyDocument();
+
+ return XmlUtils.equals(newDoc, finalDoc) ? null : finalDoc;
}
-
+
/**
*
* Reports all property read requests to the PropertyReadListeners. If
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org