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/28 19:22:15 UTC
svn commit: r437759 [2/2] - in /webservices/muse/trunk/modules:
muse-wsdm-muws-api/src/org/apache/muse/ws/dm/muws/
muse-wsdm-muws-api/src/org/apache/muse/ws/dm/muws/ext/
muse-wsdm-muws-api/src/org/apache/muse/ws/dm/muws/ext/faults/
muse-wsdm-muws-impl/...
Modified: webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/impl/SimpleRelationships.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/impl/SimpleRelationships.java?rev=437759&r1=437758&r2=437759&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/impl/SimpleRelationships.java (original)
+++ webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/impl/SimpleRelationships.java Mon Aug 28 10:22:12 2006
@@ -44,10 +44,18 @@
/**
*
- * SimpleRelationships is Muse's default implementation of the MUWS Part 2
- * Relationships capability. It ensures that the RelationshipResource endpoint is
- * exposed (for SOAP-level access to the relationships a resource participates
- * in) and provides lifecycle management for the relationship resources.
+ * SimpleRelationships is Muse's default implementation of the MUWS (Part 2)
+ * Relationships capability. It performs the following tasks:
+ * <ul>
+ * <li>Ensures that the application has a resource type with the
+ * {@linkplain RelationshipResource RelationshipResource capability} so that
+ * there will be SOAP-level access to the relationships resources,
+ * </li>
+ * <li>Provides lifecycle management for the relationship resources, and
+ * </li>
+ * <li>Implements the muws2:Relationship property and QueryRelationshipsByType
+ * operation.
+ * </li>
*
* @author Dan Jemiolo (danj)
*
@@ -56,17 +64,19 @@
public class SimpleRelationships
extends AbstractManageabilityCapability implements Relationships
{
+ //
+ // Used to look up all exception messages
+ //
private static Messages _MESSAGES = MessagesFactory.get(SimpleRelationships.class);
-
+
+ //
+ // The context path of the resource type that represents
+ // relationship resources
+ //
private String _relationshipPath = null;
private Set _relationships = new HashSet();
- public QName[] getPropertyNames()
- {
- return PROPERTIES;
- }
-
public WsResource addRelationship(String name,
RelationshipType type,
Participant[] participants)
@@ -76,7 +86,7 @@
_relationships.add(relationship);
return relationship;
}
-
+
protected MessageHandler createQueryHandler()
{
MessageHandler handler = new QueryRelationshipsHandler();
@@ -87,54 +97,35 @@
return handler;
}
+ /**
+ *
+ * This method reads the relationship fields from the XML and forwards them
+ * to createRelationship(String, RelationshipType, Participant[]).
+ *
+ */
protected WsResource createRelationship(Element xml)
throws BaseFault
{
- ResourceManager manager = getWsResource().getResourceManager();
- String endpoint = getRelationshipContextPath();
-
- WsResource resource = null;
-
- try
- {
- resource = (WsResource)manager.createResource(endpoint);
- }
-
- catch (SoapFault error)
- {
- throw new RelationshipCreationFailedFault(error);
- }
-
- RelationshipResource relationship =
- (RelationshipResource)resource.getCapability(MuwsConstants.RELATIONSHIP_RESOURCE_URI);
-
- relationship.setName(XmlUtils.getElementText(xml, MuwsConstants.NAME_QNAME));
+ String name = XmlUtils.getElementText(xml, MuwsConstants.NAME_QNAME);
Element typeXML = XmlUtils.getElement(xml, MuwsConstants.TYPE_QNAME);
- relationship.setType(new SimpleRelationshipType(typeXML));
+ RelationshipType type = new SimpleRelationshipType(typeXML);
Element[] participantsXML = XmlUtils.getElements(xml, MuwsConstants.PARTICIPANT_QNAME);
- SimpleParticipant[] participants = new SimpleParticipant[participantsXML.length];
+ Participant[] participants = new SimpleParticipant[participantsXML.length];
for (int n = 0; n < participantsXML.length; ++n)
participants[n] = new SimpleParticipant(participantsXML[n]);
- relationship.setParticipant(participants);
-
- try
- {
- resource.initialize();
- manager.addResource(resource.getEndpointReference(), resource);
- }
-
- catch (SoapFault error)
- {
- throw new RelationshipCreationFailedFault(error);
- }
-
- return resource;
+ return createRelationship(name, type, participants);
}
+ /**
+ *
+ * Creates a new relationship resource with the given fields, initializes
+ * it, and adds it to the ResourceManager before returning it.
+ *
+ */
protected WsResource createRelationship(String name,
RelationshipType type,
Participant[] participants)
@@ -143,6 +134,9 @@
ResourceManager manager = getWsResource().getResourceManager();
String endpoint = getRelationshipContextPath();
+ //
+ // first create an empty instance of the relationship type
+ //
WsResource resource = null;
try
@@ -155,6 +149,9 @@
throw new RelationshipCreationFailedFault(error);
}
+ //
+ // use the relationship capability to set the fields before initializing
+ //
RelationshipResource relationship =
(RelationshipResource)resource.getCapability(MuwsConstants.RELATIONSHIP_RESOURCE_URI);
@@ -176,9 +173,22 @@
return resource;
}
- protected String getRelationshipContextPath()
+ public Element[] getProperty(QName propertyName)
+ throws BaseFault
{
- return _relationshipPath;
+ //
+ // special case - relationship is returned as a WsResource[], we
+ // want to turn that into muws2:Relationship XML
+ //
+ if (propertyName.equals(MuwsConstants.RELATIONSHIP_QNAME))
+ return getRelationshipElements();
+
+ return super.getProperty(propertyName);
+ }
+
+ public QName[] getPropertyNames()
+ {
+ return PROPERTIES;
}
public WsResource[] getRelationship()
@@ -187,6 +197,33 @@
return (WsResource[])_relationships.toArray(array);
}
+ protected String getRelationshipContextPath()
+ {
+ return _relationshipPath;
+ }
+
+ /**
+ *
+ * This method converts the WsResource[] returned by getRelationship()
+ * into an Element[] with muws2:Relationship XML that is compliant with
+ * the MUWS Part 2 spec.
+ *
+ */
+ protected Element[] getRelationshipElements()
+ {
+ WsResource[] relationships = getRelationship();
+ Element[] relationshipXML = new Element[relationships.length];
+
+ for (int n = 0; n < relationships.length; ++n)
+ {
+ RelationshipResource capability =
+ (RelationshipResource)relationships[n].getCapability(MuwsConstants.RELATIONSHIP_RESOURCE_URI);
+ relationshipXML[n] = capability.toXML();
+ }
+
+ return relationshipXML;
+ }
+
public void initialize()
throws SoapFault
{
@@ -216,6 +253,10 @@
if (types.length == 0)
throw new IllegalArgumentException(_MESSAGES.get("EmptyQueryTypes"));
+ //
+ // add types to a hashtable so we can quickly determine if a
+ // relationship has one of the requested types
+ //
Set typesSet = new HashSet();
for (int n = 0; n < types.length; ++n)
@@ -231,6 +272,11 @@
QName[] typeValues = capability.getType().getValues();
+ //
+ // we only check the first (top-level) name in the type array,
+ // because this operation doesn't provide a way to specify
+ // more complex types or paths - we have to ignore the rest
+ //
if (typesSet.contains(typeValues[0]))
results.add(relationships[n]);
}
@@ -246,29 +292,5 @@
if (!_relationships.remove(relationship))
throw new RuntimeException(_MESSAGES.get("RelationshipNotFound"));
- }
-
- protected Element[] getRelationshipElements()
- {
- WsResource[] relationships = getRelationship();
- Element[] relationshipXML = new Element[relationships.length];
-
- for (int n = 0; n < relationships.length; ++n)
- {
- RelationshipResource capability =
- (RelationshipResource)relationships[n].getCapability(MuwsConstants.RELATIONSHIP_RESOURCE_URI);
- relationshipXML[n] = capability.toXML();
- }
-
- return relationshipXML;
- }
-
- public Element[] getProperty(QName propertyName)
- throws BaseFault
- {
- if (propertyName.equals(MuwsConstants.RELATIONSHIP_QNAME))
- return getRelationshipElements();
-
- return super.getProperty(propertyName);
}
}
Modified: webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/impl/SimpleStateTransition.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/impl/SimpleStateTransition.java?rev=437759&r1=437758&r2=437759&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/impl/SimpleStateTransition.java (original)
+++ webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/impl/SimpleStateTransition.java Mon Aug 28 10:22:12 2006
@@ -35,8 +35,8 @@
/**
*
- * SimpleStateTransition represents changes in state for the
- * {@linkplain State State} capability.
+ * SimpleStateTransition represents the muws2:StateTransition property defined
+ * by the WSDM {@linkplain State State capability}.
*
* @author Dan Jemiolo (danj)
*
@@ -165,29 +165,11 @@
return _transitionTime;
}
- /**
- *
- * This method calls toXML(Document) with XmlUtils.EMPTY_DOC, the system's
- * DOM factory scratchpad.
- *
- * @see #toXML(Document)
- *
- */
public Element toXML()
{
return toXML(XmlUtils.EMPTY_DOC);
}
- /**
- *
- * @param doc
- * The XML Document to use when creating new elements for the
- * transition XML. The elements that are created will <b>not</b>
- * be appended to this Document.
- *
- * @return A valid XML representation of this transition.
- *
- */
public Element toXML(Document doc)
{
if (doc == null)
Modified: webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/remote/RelationshipsClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/remote/RelationshipsClient.java?rev=437759&r1=437758&r2=437759&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/remote/RelationshipsClient.java (original)
+++ webservices/muse/trunk/modules/muse-wsdm-muws-impl/src/org/apache/muse/ws/dm/muws/remote/RelationshipsClient.java Mon Aug 28 10:22:12 2006
@@ -31,6 +31,9 @@
/**
*
+ * RelationshipsClient is a client for invoking the web services operations
+ * in WSDM MUWS Part 2 that are defined by the muws2:Relationships capability.
+ *
* @author Dan Jemiolo (danj)
*
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org