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 wi...@apache.org on 2005/10/11 20:02:10 UTC
svn commit: r312925 - in
/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client:
./ impl/properties/ impl/relationships/
Author: wire
Date: Tue Oct 11 11:02:04 2005
New Revision: 312925
URL: http://svn.apache.org/viewcvs?rev=312925&view=rev
Log:
Updated for Relationships
Added:
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Participant.java
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/ParticipantImpl.java
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Relationship.java
Modified:
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/properties/ResourcePropertiesImpl.java
webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/RelationshipImpl.java
Modified: webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java?rev=312925&r1=312924&r2=312925&view=diff
==============================================================================
--- webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java (original)
+++ webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java Tue Oct 11 11:02:04 2005
@@ -28,6 +28,7 @@
import org.apache.ws.client.muse.client.impl.exceptions.FaultException;
import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
import org.apache.ws.client.muse.client.impl.notification.NotifyableResourceImpl;
+import org.apache.ws.client.muse.client.impl.relationships.Relationship;
import org.apache.ws.client.muse.client.model.Notification;
import org.apache.ws.client.muse.client.model.Query;
import org.apache.ws.client.muse.client.model.PropertiesList;
@@ -454,4 +455,21 @@
throws URISyntaxException, IOException, XmlException,
UnexpectedServerResponseException, FaultException;
+ /**
+ *
+ * This operation is OPTIONAL. It is a shortcut to query relationships of the same type.
+ * param qnames a QName which
+ * identifies the requested type(s) of relationship(s). When processing this request, the
+ * manageability endpoint MUST return any available instance relationship that is of the requested
+ * type or of any type that is a specialization of the requested type. There can be more than one
+ * requested type, in which case any relationship instance corresponding to any requested type
+ * MUST be returned.
+ * @return The response to the above request is either a fault (any fault) or an array of relationships
+ * that match the requested type.
+ */
+ public Relationship[] queryRelationshipsByType(QName qname) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException, FaultException;
+
}
+
+
+
Modified: webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/properties/ResourcePropertiesImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/properties/ResourcePropertiesImpl.java?rev=312925&r1=312924&r2=312925&view=diff
==============================================================================
--- webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/properties/ResourcePropertiesImpl.java (original)
+++ webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/properties/ResourcePropertiesImpl.java Tue Oct 11 11:02:04 2005
@@ -18,6 +18,8 @@
import org.apache.ws.client.muse.client.impl.ManageableResourceImpl;
import org.apache.ws.client.muse.client.impl.exceptions.FaultException;
import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+import org.apache.ws.client.muse.client.impl.relationships.Relationship;
+import org.apache.ws.client.muse.client.impl.relationships.RelationshipImpl;
import org.apache.ws.client.muse.client.impl.stubs.ResourceStub;
import org.apache.ws.client.muse.client.impl.stubs.ServiceStub;
import org.apache.ws.client.muse.client.impl.wsrf.InsertOrUpdateRequest;
@@ -37,6 +39,11 @@
import org.apache.xmlbeans.impl.values.XmlDoubleImpl;
import org.apache.xmlbeans.impl.values.XmlIntImpl;
import org.apache.xmlbeans.impl.values.XmlStringImpl;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.QueryRelationshipsByTypeDocument;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.RelationshipType;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.QueryRelationshipsByTypeDocument.QueryRelationshipsByType;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.impl.QueryRelationshipsByTypeResponseDocumentImpl;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.impl.RelationshipTypeImpl;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.DeleteType;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertType;
@@ -55,6 +62,7 @@
public class ResourcePropertiesImpl {
protected EndpointReference epr;
+ private static final QName RELATIONSHIP_QNAME=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","Relationship");
protected ResourceStub rs;
@@ -678,4 +686,41 @@
public PropertiesList createNewSetPropertiesRequest(){
return new SetPropertiesRequestImpl();
}
+
+ public Relationship[] getRelationships() throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
+ XmlObject[] relationships = getProperty(RELATIONSHIP_QNAME);
+ Vector ret=new Vector();
+ for (int i = 0; i < relationships.length; i++) {
+ XmlObject object = relationships[i];
+ if(object instanceof RelationshipTypeImpl){
+ RelationshipTypeImpl relation=(RelationshipTypeImpl)object;
+ ret.add(new RelationshipImpl(relation));
+ }
+ }
+ return (Relationship[]) ret.toArray(new Relationship[0]);
+
+ }
+
+ public Relationship[] queryRelationshipsByType(QName qname) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException, FaultException{
+ QueryRelationshipsByTypeDocument qrbtDoc = QueryRelationshipsByTypeDocument.Factory.newInstance();
+ QueryRelationshipsByType qrType = qrbtDoc.addNewQueryRelationshipsByType();
+ qrType.setRequestedType(qname);
+
+ XmlObject parts = rs.sendRequest(qrbtDoc,"http://docs.oasis-open.org/wsrf/2004/06/WS-ResourceProperties/queryRelationshipsByType");
+ if(parts instanceof FaultImpl)
+ throw new FaultException(parts.toString());
+ if(!(parts instanceof QueryRelationshipsByTypeResponseDocumentImpl.QueryRelationshipsByTypeResponseImpl))
+ throw new UnexpectedServerResponseException("Expected QueryRelationshipsByTypeResponseDocumentImpl but received "+parts.getClass().getName());
+ QueryRelationshipsByTypeResponseDocumentImpl.QueryRelationshipsByTypeResponseImpl relationResponse=(QueryRelationshipsByTypeResponseDocumentImpl.QueryRelationshipsByTypeResponseImpl)parts;
+ RelationshipType[] arryRelations = relationResponse.getRelationshipArray();
+ Vector ret=new Vector();
+ for (int i = 0; i < arryRelations.length; i++) {
+ RelationshipType relationType = arryRelations[i];
+ ret.add(new RelationshipImpl((RelationshipTypeImpl)relationType));
+ }
+
+ return (Relationship[]) ret.toArray(new Relationship[0]);
+ }
+
+
}
Added: webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Participant.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Participant.java?rev=312925&view=auto
==============================================================================
--- webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Participant.java (added)
+++ webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Participant.java Tue Oct 11 11:02:04 2005
@@ -0,0 +1,16 @@
+package org.apache.ws.client.muse.client.impl.relationships;
+
+import java.net.MalformedURLException;
+
+import org.apache.ws.client.muse.client.ManageableResource;
+
+public interface Participant {
+
+ public abstract String getRole();
+
+ public abstract String getResourceId();
+
+ public abstract ManageableResource[] getResources()
+ throws MalformedURLException;
+
+}
\ No newline at end of file
Added: webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/ParticipantImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/ParticipantImpl.java?rev=312925&view=auto
==============================================================================
--- webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/ParticipantImpl.java (added)
+++ webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/ParticipantImpl.java Tue Oct 11 11:02:04 2005
@@ -0,0 +1,45 @@
+package org.apache.ws.client.muse.client.impl.relationships;
+
+import java.net.MalformedURLException;
+import java.util.Vector;
+
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.apache.ws.client.muse.client.ManageableResource;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.RelationshipParticipantType;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType;
+
+public class ParticipantImpl implements Participant {
+
+ private RelationshipParticipantType participant;
+
+ public ParticipantImpl(RelationshipParticipantType participant) {
+ this.participant=participant;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ws.client.muse.client.impl.relationships.Participant#getRole()
+ */
+ public String getRole(){
+ return participant.getRole();
+ }
+ /* (non-Javadoc)
+ * @see org.apache.ws.client.muse.client.impl.relationships.Participant#getResourceId()
+ */
+ public String getResourceId(){
+ return participant.getResourceId();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ws.client.muse.client.impl.relationships.Participant#getResource()
+ */
+ public ManageableResource[] getResources() throws MalformedURLException{
+ EndpointReferenceType[] resArry = participant.getManageabilityEndpointReferenceArray();
+ Vector ret=new Vector();
+ for (int i = 0; i < resArry.length; i++) {
+ EndpointReferenceType type = resArry[i];
+ ret.add(ManageableResource.Factory.create(null,new XmlBeansEndpointReference(type)));
+ }
+ return (ManageableResource[]) ret.toArray(new ManageableResource[0]);
+ }
+}
Added: webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Relationship.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Relationship.java?rev=312925&view=auto
==============================================================================
--- webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Relationship.java (added)
+++ webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/Relationship.java Tue Oct 11 11:02:04 2005
@@ -0,0 +1,37 @@
+package org.apache.ws.client.muse.client.impl.relationships;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+
+public interface Relationship {
+
+ /**
+ * A human readable name for a relationship.
+ * Name should not be used for machine reasoning about
+ * the semantics of a relationship. Type
+ * should be used instead. This element is OPTIONAL.
+ * @return A human readable name or exception if not implemented.
+ */
+ public abstract String getName();
+
+ /**
+ * Returns a user defined Relationship type object.
+ * xs:Type is the relationship type this relationship belongs
+ * to. Examples of such types include linkage, containment, or dependency. MUWS does not define
+ * any specific relationship type. This is left to domain-specific models. MUWS only defines a way to
+ * convey the type as part of the representation of a relationship.
+ * @return The relationship xml contained in an XmlObject.
+ * @throws UnexpectedServerResponseException
+ */
+ public abstract QName getType() throws UnexpectedServerResponseException;
+
+ /**
+ * Participant contains information about a participant in
+ * the relationship. There MUST be at least two participants,
+ * but there MAY be more than two participants.
+ * @return An Array of Participant Resources
+ */
+ public abstract Participant[] getParicipants();
+
+}
\ No newline at end of file
Modified: webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/RelationshipImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/RelationshipImpl.java?rev=312925&r1=312924&r2=312925&view=diff
==============================================================================
--- webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/RelationshipImpl.java (original)
+++ webservices/muse/trunk/client/src/java/org/apache/ws/client/muse/client/impl/relationships/RelationshipImpl.java Tue Oct 11 11:02:04 2005
@@ -1,64 +1,52 @@
package org.apache.ws.client.muse.client.impl.relationships;
+import java.util.Vector;
+
import javax.xml.namespace.QName;
-import org.apache.ws.client.muse.client.ManageableResource;
+import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+import org.apache.ws.util.XmlBeanUtils;
import org.apache.xmlbeans.XmlObject;
-import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.impl.RelationshipDocumentImpl;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.RelationshipParticipantType;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.impl.RelationshipTypeImpl;
-public class RelationshipImpl {
+public class RelationshipImpl implements Relationship {
- public RelationshipImpl(RelationshipDocumentImpl document) {
- super();
+ private RelationshipTypeImpl relation;
+
+ public RelationshipImpl(RelationshipTypeImpl relation) {
+ this.relation=relation;
}
- /**
- * A human readable name for a relationship.
- * Name should not be used for machine reasoning about
- * the semantics of a relationship. Type
- * should be used instead. This element is OPTIONAL.
- * @return A human readable name or exception if not implemented.
+ /* (non-Javadoc)
+ * @see org.apache.ws.client.muse.client.impl.relationships.Relationship#getName()
*/
- public QName getName(){
- return null;
+ public String getName(){
+ return relation.getName();
}
- /**
- * Returns a user defined Relationship type object.
- * xs:Type is the relationship type this relationship belongs
- * to. Examples of such types include linkage, containment, or dependency. MUWS does not define
- * any specific relationship type. This is left to domain-specific models. MUWS only defines a way to
- * convey the type as part of the representation of a relationship.
- * @return The relationship xml contained in an XmlObject.
+ /* (non-Javadoc)
+ * @see org.apache.ws.client.muse.client.impl.relationships.Relationship#getType()
*/
- public XmlObject getType(){
- return null;
+ public QName getType() throws UnexpectedServerResponseException{
+ XmlObject[] children = XmlBeanUtils.getChildElements(relation.getType());
+ if(children.length==0 )
+ throw new UnexpectedServerResponseException("Response contains no type information.");
+
+ return children[0].newCursor().getName();
}
- /**
- * Participant contains information about a participant in
- * the relationship. There MUST be at least two participants,
- * but there MAY be more than two participants.
- * @return An Array of Participant Resources
- */
- public ManageableResource[] getPaticipants(){
- return null;
- }
-
- //TODO Move this method into the ManageableResource Inheritance Path
- /**
- * This operation is OPTIONAL. It is a shortcut to query relationships of the same type.
- * param qnames a QName which
- * identifies the requested type(s) of relationship(s). When processing this request, the
- * manageability endpoint MUST return any available instance relationship that is of the requested
- * type or of any type that is a specialization of the requested type. There can be more than one
- * requested type, in which case any relationship instance corresponding to any requested type
- * MUST be returned.
- * @return The response to the above request is either a fault (any fault) or an array of relationships
- * that match the requested type.
+ /* (non-Javadoc)
+ * @see org.apache.ws.client.muse.client.impl.relationships.Relationship#getParicipants()
*/
- public RelationshipImpl[] queryRelationshipsByType(QName[] qnames){
- return null;
+ public Participant[] getParicipants(){
+ RelationshipParticipantType[] arryParticipants = relation.getParticipantArray();
+ Vector ret=new Vector();
+ for (int i = 0; i < arryParticipants.length; i++) {
+ RelationshipParticipantType participant = arryParticipants[i];
+ ret.add(new ParticipantImpl(participant));
+ }
+ return (Participant[]) ret.toArray(new Participant[0]);
}
}