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/09/20 17:55:11 UTC
svn commit: r290478 - in
/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client:
./ impl/ impl/notification/ model/
Author: wire
Date: Tue Sep 20 08:55:05 2005
New Revision: 290478
URL: http://svn.apache.org/viewcvs?rev=290478&view=rev
Log:
Refactored to add interfaces to all model impls
Added:
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/ChangeNotificationImpl.java
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/SituationImpl.java
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/ChangeNotification.java
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Notification.java
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Situation.java
Modified:
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationConsumerImpl.java
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationImpl.java
webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceImpl.java
Modified: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java?rev=290478&r1=290477&r2=290478&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/ManageableResource.java Tue Sep 20 08:55:05 2005
@@ -12,8 +12,8 @@
import org.apache.ws.addressing.XmlBeansEndpointReference;
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.NotificationImpl;
import org.apache.ws.client.muse.client.impl.notification.NotifyableResourceImpl;
+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.TopicExpression;
import org.apache.xmlbeans.XmlException;
@@ -167,7 +167,7 @@
/* (non-Javadoc)
* @see org.apache.ws.client.muse.client.impl.notification.Temp#getCurrentMessage(org.apache.ws.client.muse.client.impl.notification.TopicExpressionImpl)
*/
- public abstract NotificationImpl getCurrentMessage(TopicExpression topic)
+ public abstract Notification getCurrentMessage(TopicExpression topic)
throws URISyntaxException, IOException, XmlException,
UnexpectedServerResponseException;
Modified: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java?rev=290478&r1=290477&r2=290478&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java Tue Sep 20 08:55:05 2005
@@ -21,9 +21,15 @@
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.Vector;
import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,21 +41,46 @@
import org.apache.ws.client.muse.client.impl.stubs.ResourceStub;
import org.apache.ws.client.muse.client.impl.stubs.ServiceStub;
import org.apache.ws.muws.v1_0.capability.IdentityCapability;
+import org.apache.ws.service.testresource.TestResourcePropertyQNames;
+import org.apache.ws.util.XmlBeanUtils;
import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlDocumentProperties;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.regex.ParseException;
+import org.apache.xmlbeans.impl.soap.Node;
+import org.apache.xmlbeans.impl.soap.SOAPElement;
+import org.apache.xmlbeans.impl.soap.SOAPElementFactory;
+import org.apache.xmlbeans.impl.soap.SOAPException;
+//import org.apache.xmlbeans.impl.soap.Text;
import org.apache.xmlbeans.impl.values.XmlAnyUriImpl;
import org.apache.xmlbeans.impl.values.XmlBooleanImpl;
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.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.DeleteType;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertType;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryExpressionType;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryResourcePropertiesDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.SetResourcePropertiesDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryResourcePropertiesResponseDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.SetResourcePropertiesResponseDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.UpdateType;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesDocument.GetMultipleResourceProperties;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryResourcePropertiesDocument.QueryResourceProperties;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.SetResourcePropertiesDocument.SetResourceProperties;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.impl.GetMultipleResourcePropertiesDocumentImpl;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.impl.GetMultipleResourcePropertiesResponseDocumentImpl;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.impl.GetResourcePropertyDocumentImpl;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.impl.QueryResourcePropertiesDocumentImpl;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.impl.SetResourcePropertiesResponseDocumentImpl;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.impl.QueryResourcePropertiesDocumentImpl.QueryResourcePropertiesImpl;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceDocument;
public class ManageableResourceImpl {
@@ -277,8 +308,9 @@
return (QName[]) infoList.toArray(new QName[0]);
}
- /* (non-Javadoc)
- * @see org.apache.ws.client.muse.client.impl.ManageableResource#getMultipleResourceProperties(javax.xml.namespace.QName[])
+ /* Takes a list of QNames that constitute the requested list of properties to retrieve.
+ * Returns XmlObject instances as there is not guarantee that we'll receive anything more specific,
+ * therefore just returning fragments.
*/
public XmlObject[] getMultipleResourceProperties(QName[] requestedValues) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
@@ -294,30 +326,401 @@
}
//Now send the request
- XmlObject parts = rs.sendRequest(gmpDoc,"http://getmultipleresourcepropertydocument","M");
+ XmlObject parts = rs.sendRequest(gmpDoc,"http://getmultipleresourcepropertydocument","M");
if(!(parts instanceof GetMultipleResourcePropertiesResponseDocumentImpl.GetMultipleResourcePropertiesResponseImpl))
- throw new UnexpectedServerResponseException("Expected GetMultipleResourcePropertiesResponseDocument but received "+parts.getClass().getName());
-
- // Now cursor down into each returned property and add it to the collection
+ throw new UnexpectedServerResponseException("Expected GetMultipleResourcePropertiesResponseDocumentImpl but received "+parts.getClass().getName());
+
+ //type cast and walk the array to extract the responses
GetMultipleResourcePropertiesResponseDocumentImpl.GetMultipleResourcePropertiesResponseImpl response = (GetMultipleResourcePropertiesResponseDocumentImpl.GetMultipleResourcePropertiesResponseImpl)parts;
- Vector infoList = new Vector(20);
+ //Create cursor to walk through the response.
XmlCursor cursor = response.newCursor();
- cursor.toFirstChild();
- cursor.toFirstChild();
+ cursor.toChild(0);
+ cursor.toFirstChild();
- QName propName=cursor.getName();
- infoList.add(propName);
+ XmlObject obj = cursor.getObject();
+ Vector infoList = new Vector(20);
+
+ //extract the first XmlObject
+ XmlObject prop=cursor.getObject();
+ infoList.add(prop);
+
+ //walk the sibling list to extract all objects
while(cursor.toNextSibling()){
- propName=cursor.getName();
- infoList.add(propName);
+ prop=cursor.getObject();
+ infoList.add(prop);
}
cursor.dispose();
-// return (QName[]) infoList.toArray(new QName[0]);
- return null;
+
+ return (XmlObject[]) infoList.toArray(new XmlObject[0]);
}
+// //Spec method.
+// public XmlObject getResourcePropertyDocument() throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+//// public XmlObject[] getResourcePropertyDocument() throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+//
+// //Create GetResourcePropertyDocument document
+// GetResourcePropertyDocument resPropDoc = GetResourcePropertyDocument.Factory.newInstance();
+//// GetMultipleResourcePropertiesDocument gmpDoc = GetMultipleResourcePropertiesDocument.Factory.newInstance();
+//
+// //Build the query to be included in that document
+//// XmlDocumentProperties query = resPropDoc.documentProperties();
+//// XmlDocumentProperties query = resPropDoc.();
+//// GetMultipleResourceProperties query = gmpDoc.addNewGetMultipleResourceProperties();
+//
+// //Now send the request
+// XmlObject parts = rs.sendRequest(resPropDoc,
+// "http://docs.oasis-open.org/wsrf/rpw-1/GetResourcePropertyDocument/GetResourcePropertyDocumentRequest","M");
+//// XmlObject parts = rs.sendRequest(resPropDoc,"http://getresourcepropertydocument","M");
+//// XmlObject parts = rs.sendRequest(gmpDoc,"http://getmultipleresourcepropertydocument","M");
+//
+// if(!(parts instanceof GetResourcePropertyDocumentImpl))
+// throw new UnexpectedServerResponseException("Expected GetResourcePropertyDocumentImpl but received "+parts.getClass().getName());
+//// if(!(parts instanceof GetMultipleResourcePropertiesResponseDocumentImpl.GetMultipleResourcePropertiesResponseImpl))
+//// throw new UnexpectedServerResponseException("Expected GetMultipleResourcePropertiesResponseDocumentImpl but received "+parts.getClass().getName());
+//
+// //type cast and walk the array to extract the responses
+// GetResourcePropertyDocumentImpl response = (GetResourcePropertyDocumentImpl)parts;
+//// GetMultipleResourcePropertiesResponseDocumentImpl.GetMultipleResourcePropertiesResponseImpl response = (GetMultipleResourcePropertiesResponseDocumentImpl.GetMultipleResourcePropertiesResponseImpl)parts;
+//
+// //Create cursor to walk through the response.
+// XmlCursor cursor = response.newCursor();
+// cursor.toChild(0);
+// cursor.toFirstChild();
+//
+//// XmlObject obj = cursor.getObject();
+//// Vector infoList = new Vector(20);
+//
+// //extract the first XmlObject
+// XmlObject prop=cursor.getObject();
+//// infoList.add(prop);
+////
+//// //walk the sibling list to extract all objects
+//// while(cursor.toNextSibling()){
+//// prop=cursor.getObject();
+//// infoList.add(prop);
+//// }
+// cursor.dispose();
+//
+// return prop;
+//// return (XmlObject[]) infoList.toArray(new XmlObject[0]);
+// }
+
+ /* Takes an XPath query and a dialect, and returns the results as an XMLObject[].
+ * Operation returns a subset of the ResourceProperties or an XPath operation on
+ * the same.
+ */
+ public XmlObject[] queryResourceProperties(String xpathExp, String xpthDialect) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+
+ //build the query document
+ QueryResourcePropertiesDocument queryDocument = QueryResourcePropertiesDocument.Factory.newInstance();
+ //add the query properties component
+ QueryResourceProperties query = queryDocument.addNewQueryResourceProperties();
+ //add the query expression
+ QueryExpressionType expression = query.addNewQueryExpression();
+ //set the specific dialect to use
+ expression.setDialect("http://www.w3.org/TR/1999/REC-xpath-19991116");
+ //Manipulate the xml
+ XmlCursor cursor = expression.newCursor();
+ //insert the xpath component
+ cursor.setTextValue(xpathExp);
+ cursor.dispose();
+
+ XmlObject parts = rs.sendRequest(queryDocument,"http://queryresourcepropertydocument","M");
+ if(!(parts instanceof QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse))
+ throw new UnexpectedServerResponseException("Expected QueryResourcePropertiesResponseDocument but received "+parts.getClass().getName());
+
+ //cast to response
+ QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse response=(QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse)parts;
+
+ //navigate the document to retrieve all the properties
+ cursor=response.newCursor();
+ cursor.toChild(0);
+ cursor.toFirstChild();
+
+ //store all encountered responses
+ Vector infoList = new Vector(20);
+ XmlObject propValue=cursor.getObject();
+ infoList.add(propValue);
+
+ //for numerous response components
+ while(cursor.toNextSibling()){
+ propValue=cursor.getObject();
+ infoList.add(propValue);
+ }
+ cursor.dispose();
+
+ //build the response
+ return (XmlObject[]) infoList.toArray(new XmlObject[0]);
+ }
+
+ public boolean updatePropertyWithDouble(QName property, double newValue) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
+ boolean success =false;
+
+ //update that property
+ SetPropertiesRequest setRequest = new SetPropertiesRequest();
+ String[] updates = {String.valueOf(newValue)};
+ boolean completed =setRequest.addUpdateRequest(TestResourcePropertyQNames.PRICE,updates);
+ setProperties(setRequest);
+ success = true;
+
+ return success;
+ }
+
+ public boolean updatePropertyWithInt(QName property, int newValue) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
+ boolean success =false;
+
+ //update that property
+ SetPropertiesRequest setRequest = new SetPropertiesRequest();
+ String[] updates = {String.valueOf(newValue)};
+ boolean completed =setRequest.addUpdateRequest(TestResourcePropertyQNames.PRICE,updates);
+ setProperties(setRequest);
+ success = true;
+
+ return success;
+ }
+
+ public boolean updatePropertyWithFloat(QName property, float newValue) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
+ boolean success =false;
+
+ //update that property
+ SetPropertiesRequest setRequest = new SetPropertiesRequest();
+ String[] updates = {String.valueOf(newValue)};
+ boolean completed =setRequest.addUpdateRequest(TestResourcePropertyQNames.PRICE,updates);
+ setProperties(setRequest);
+ success = true;
+
+ return success;
+ }
+
+// public boolean updatePropertyWithDouble(QName price, double newVal) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+// boolean success = false;
+//
+// //build the change document
+// SetResourcePropertiesDocument setPropsDocument = SetResourcePropertiesDocument.Factory.newInstance();
+// //add the set properties component
+// SetResourceProperties query = setPropsDocument.addNewSetResourceProperties();
+// //add the update expression
+// UpdateType modification = query.addNewUpdate();
+// //Manipulate the xml
+// XmlCursor cursor = modification.newCursor();
+// //Now begin to add each update element
+// //tmp string conversion?
+// String txt = String.valueOf(newVal);
+//// modification.
+// //add all update parameters to the current node
+//
+//// addItemsToNode(price, cursor, txt);
+//// QName[] updateQnameList = new QName[2]; updateQnameList[0] = TestResourcePropertyQNames.PRICE;
+// QName[] updateQnameList = new QName[1]; updateQnameList[0] = TestResourcePropertyQNames.PRICE;
+//// updateQnameList[1] = TestResourcePropertyQNames.NAME;
+//// String[] updatePropValList = new String[2]; updatePropValList[0]=String.valueOf(newVal);
+// String[] updatePropValList = new String[1]; updatePropValList[0]=String.valueOf(newVal);
+//// updatePropValList[1]="NewlyTHoughtOfName";
+//
+// addItemsToNode(updateQnameList, cursor, updatePropValList);
+//
+//
+//// validateXmlBean(setPropsDocument);
+//
+//// //now add the other two elements
+//// DeleteType delete = query.addNewDelete();
+//// delete.setResourceProperty(TestResourcePropertyQNames.OPERATIONALSTATUS);
+//// InsertType insert = query.addNewInsert();
+//// XmlCursor iCursor = insert.newCursor();
+//// QName[] updateQnameList = new QName[1]; updateQnameList[0] = TestResourcePropertyQNames.NAME;
+//// String[] updatePropValList = new String[1]; updatePropValList[0]=String.valueOf("NewName");
+//// addItemsToNode(updateQnameList,iCursor,updatePropValList);
+//
+//// XmlObject parts = rs.sendRequest(queryDocument,"http://updateresourcepropertydocument","M");
+// XmlObject parts = rs.sendRequest(setPropsDocument,"http://docs.oasis-open.org/wsrf/2004/06/WS-ResourceProperties/SetResourceProperties","M");
+// if(!(parts instanceof SetResourcePropertiesResponseDocumentImpl.SetResourcePropertiesResponseImpl))
+// throw new UnexpectedServerResponseException("Expected SetResourcePropertiesResponseDocumentImpl but received "+parts.getClass().getName());
+//
+// //cast to response
+// SetResourcePropertiesResponseDocumentImpl.SetResourcePropertiesResponseImpl response
+// =(SetResourcePropertiesResponseDocumentImpl.SetResourcePropertiesResponseImpl)parts;
+//
+// //navigate the document to retrieve all the properties
+// cursor=response.newCursor();
+// cursor.toChild(0);
+// cursor.toFirstChild();
+//
+// //store all encountered responses
+// Vector infoList = new Vector(20);
+// XmlObject propValue=cursor.getObject();
+// infoList.add(propValue);
+//
+// //for numerous response components
+// while(cursor.toNextSibling()){
+// propValue=cursor.getObject();
+// infoList.add(propValue);
+// }
+// cursor.dispose();
+// success = true;
+//
+// return success;
+// }
+
+ /* updateProperties takes a SetPropertiesRequest instance which defines
+ * Insert, Update and Delete requests and the order in which they were made.
+ */
+ public XmlObject setProperties(SetPropertiesRequest modificationList) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+
+ //build the SetResourceProperties document
+ SetResourcePropertiesDocument setPropsDocument =
+ SetResourcePropertiesDocument.Factory.newInstance();
+ //add the set properties component
+ SetResourceProperties request = setPropsDocument.addNewSetResourceProperties();
+ XmlCursor cursor = null;
+
+ //iterate through the SetPropertiesRequest to populate the SetResourcePropertiesDocument
+// for (int i = 0; i < modificationList.allResourcesIndex; i++) {
+ for (int i = 0; i < modificationList.allResourcesIndex; i++) {
+
+ //Retrieve the current object
+// Object resMod = modificationList.allSetResourceRequests.get(i);
+ Object resMod = modificationList.allSetResourceRequests.get(i);
+
+ if (resMod instanceof QName) { //Then this is a delete request
+ QName deleteParameter = (QName) resMod;
+ //Then create the xml for the delete
+ DeleteType delete =request.addNewDelete();
+ delete.setResourceProperty(deleteParameter);
+ }
+ else{//then is an insert or update request
+ InsertOrUpdateRequest custRequest = (InsertOrUpdateRequest)resMod;
+ if(custRequest.isInsert()){//then generate xml for insert
+ //is an insert request. Building appropriate xml
+ //add the insert expression
+ InsertType modification = request.addNewInsert();
+ //Manipulate the xml
+ cursor = modification.newCursor();
+
+ //add all update parameters to the current node
+ addItemsToNode(custRequest.getProperty(),cursor,custRequest.getPropetyValues());
+ }
+ else{//is an update request. Building appropriate xml
+ //add the update expression
+ UpdateType modification = request.addNewUpdate();
+ //Manipulate the xml
+ cursor = modification.newCursor();
+
+ //add all update parameters to the current node
+ addItemsToNode(custRequest.getProperty(),cursor,custRequest.getPropetyValues());
+ }
+ }
+ }
+
+// validateXmlBean(setPropsDocument);
+
+ XmlObject parts = rs.sendRequest(setPropsDocument,"http://docs.oasis-open.org/wsrf/2004/06/WS-ResourceProperties/SetResourceProperties","M");
+ if(!(parts instanceof SetResourcePropertiesResponseDocumentImpl.SetResourcePropertiesResponseImpl))
+ throw new UnexpectedServerResponseException("Expected SetResourcePropertiesResponseDocumentImpl but received "+parts.getClass().getName());
+
+ //cast to response
+ SetResourcePropertiesResponseDocumentImpl.SetResourcePropertiesResponseImpl response
+ =(SetResourcePropertiesResponseDocumentImpl.SetResourcePropertiesResponseImpl)parts;
+
+ //navigate the document to retrieve all the properties
+ cursor=response.newCursor();
+ cursor.toChild(0);
+ cursor.toFirstChild();
+
+ //store all encountered responses
+ Vector infoList = new Vector(20);
+ XmlObject propValue=cursor.getObject();
+ infoList.add(propValue);
+
+ //for numerous response components
+ while(cursor.toNextSibling()){
+ propValue=cursor.getObject();
+ infoList.add(propValue);
+ }
+ cursor.dispose();
+
+ return propValue;
+ }
+
+ /* AddItemsToNode: this method takes: XmlCursor, QName[] and String[].
+ * adds an element for each corresponding QName and String value for each property.
+ */
+ private void addItemsToNode(QName propQname, XmlCursor cursor, String[] propList) throws IllegalArgumentException {
+ //store away reference to original cursor location
+ XmlCursor origCursorLocation = cursor.newCursor();
+
+ //For each property value encountered, create sub nodes
+ for (int i = 0; i < propList.length; i++) {
+ XmlCursor listCursorPosition = origCursorLocation.newCursor();
+ cursor = origCursorLocation.newCursor();
+ //Create a new node
+ cursor.insertElementWithText(propQname,propList[i]);
+// System.out.println("QName:"+propQname);
+// System.out.println("Val:"+cursor.getName());
+// System.out.println("Val:"+listCursorPosition.getName());
+ boolean suc = cursor.toParent();
+// System.out.println("To Par:"+suc);
+// System.out.println("Val:"+cursor.getName());
+// System.out.println("Val:"+listCursorPosition.getName());
+
+ cursor.toChild(propQname);
+ //move the cursor positioning
+ listCursorPosition.toNextToken();
+ //stitch the node into new location
+ cursor.copyXml(listCursorPosition);
+// System.out.println("Val-q:"+cursor.getName());
+ //remove the original node
+ cursor.removeXml();
+ //clean up
+ cursor.dispose();
+ listCursorPosition.dispose();
+ }
+ }
+ /* AddItemsToNode: this method takes: XmlCursor, QName[] and String[].
+ * adds an element for each corresponding QName and String value for each property.
+ */
+ private void addItemsToNode(QName[] qList, XmlCursor cursor, String[] propList) throws IllegalArgumentException {
+
+ if(qList.length != propList.length){
+ throw new IllegalArgumentException("QName array and Property array must be the same size!");
+ }
+
+ //store away reference to original cursor location
+ XmlCursor origCursorLocation = cursor.newCursor();
+
+ for (int i = 0; i < propList.length; i++) {
+ XmlCursor listCursorPosition = origCursorLocation.newCursor();
+ cursor = origCursorLocation.newCursor();
+
+ cursor.insertElementWithText(qList[i],propList[i]);
+ System.out.println("Val:"+cursor.getName());
+ System.out.println("Val:"+listCursorPosition.getName());
+// cursor.toChild(price);
+ boolean suc = cursor.toParent();
+ System.out.println("To Par:"+suc);
+ System.out.println("Val:"+cursor.getName());
+ System.out.println("Val:"+listCursorPosition.getName());
+ cursor.toChild(qList[i]);
+ System.out.println("Val-q:"+cursor.getName());
+
+ listCursorPosition.toNextToken();
+// cursor.moveXml(curPos);
+ cursor.copyXml(listCursorPosition);
+ System.out.println("Val-q:"+cursor.getName());
+ cursor.removeXml();
+
+// listCursorPosition.removeXml();
+
+ //get the new cursor location
+// query.
+// cursor
+
+ cursor.dispose();
+ listCursorPosition.dispose();
+
+ }
+ }
// public XmlObject[] getMetric(QName testmetric) throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
// LOG.info("getting Metric value "+testmetric+" from " + this.epr.getAddress());
@@ -333,4 +736,126 @@
// return parts;
// }
+
+ public static void validateXmlBean(XmlObject requestXBean) throws ParseException{
+ XmlOptions validateOptions = new XmlOptions( );
+ List errorList = new ArrayList( );
+ validateOptions.setErrorListener( errorList );
+ boolean isValid = requestXBean.validate( validateOptions );
+ if ( !isValid )
+ {
+ QName bodyElemName = XmlBeanUtils.getName( requestXBean );
+ StringBuffer strBuf = new StringBuffer( "Request body element " );
+ strBuf.append( bodyElemName);
+ strBuf.append( " is not valid as per its schema: \n\n" );
+ for ( int i = 0; i < errorList.size( ); i++ )
+ {
+ strBuf.append( "\t\t" );
+ strBuf.append( i + 1 );
+ strBuf.append( ") " );
+ strBuf.append( errorList.get( i ) );
+ strBuf.append( "\n" );
+ }
+
+ strBuf.append( "\n" );
+ throw new ParseException(
+ strBuf.toString( ),0 );
+ }
+
+ }
+
+ /* SetPropertiesRequest: stores each Insert, Update and Delete request
+ * and the order that it was requested.
+ */
+ public class SetPropertiesRequest{
+
+ //Stores all setResource requests(Insert,Update,Delete) in order
+ ArrayList allSetResourceRequests = new ArrayList();
+ int allResourcesIndex = 0;
+
+ /* addInsertRequest: all insert values must use the same QName.
+ * Ex. <Insert><rns:Price>0.0</rns:Price></Insert>
+ * Ex. <Insert>
+ * <rns:Comment>comment1</rns:Comment>
+ * <rns:Comment>comment2</rns:Comment>
+ * </Insert>
+ */
+ boolean addInsertRequest(QName prop, String[] propValues){
+ boolean success = false;
+ for (int i = 0; i < propValues.length; i++) {
+ //populate each update request value
+ InsertOrUpdateRequest modRequest = new InsertOrUpdateRequest();
+ modRequest.setInsert(true);
+ modRequest.setProperty(prop);
+ modRequest.setPropetyValues(propValues);
+ //add this request to allSetResourceRequests
+ allSetResourceRequests.add(allResourcesIndex,modRequest);
+ allResourcesIndex++;
+ }
+ return success;
+ }
+
+ /* addUpdateRequest: all update values must use the same QName.
+ * Ex. <Update><rns:Price>0.0</rns:Price></Update>
+ * Ex. <Update>
+ * <rns:Comment>comment1</rns:Comment>
+ * <rns:Comment>comment2</rns:Comment>
+ * </Update>
+ */
+ boolean addUpdateRequest(QName prop, String[] propValues){
+ boolean success = false;
+ for (int i = 0; i < propValues.length; i++) {
+ //populate each update request value
+ InsertOrUpdateRequest modRequest = new InsertOrUpdateRequest();
+ modRequest.setUpdate(true);
+ modRequest.setProperty(prop);
+ modRequest.setPropetyValues(propValues);
+ //add this request to allSetResourceRequests
+ allSetResourceRequests.add(allResourcesIndex,modRequest);
+ allResourcesIndex++;
+ }
+ return success;
+ }
+
+ /*Takes the QName identifying the resource to delete */
+ boolean addDeleteRequest(QName propToDelete){
+ boolean success = false;
+ //Add the delete Request
+ allSetResourceRequests.add(allResourcesIndex,propToDelete);
+ allResourcesIndex++;
+ return success;
+ }
+ }
+
+ /* Includes all data relevant to and insert or update request. */
+ class InsertOrUpdateRequest{
+ QName property = null;
+ String[] propetyValues = null;
+ boolean isInsert = false;
+ boolean isUpdate = false;
+ public boolean isInsert() {
+ return isInsert;
+ }
+ public void setInsert(boolean isInsert) {
+ this.isInsert = isInsert;
+ }
+ public boolean isUpdate() {
+ return isUpdate;
+ }
+ public void setUpdate(boolean isUpdate) {
+ this.isUpdate = isUpdate;
+ }
+ public QName getProperty() {
+ return property;
+ }
+ public void setProperty(QName property) {
+ this.property = property;
+ }
+ public String[] getPropetyValues() {
+ return propetyValues;
+ }
+ public void setPropetyValues(String[] propetyValue) {
+ this.propetyValues = propetyValue;
+ }
+ }
}
Added: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/ChangeNotificationImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/ChangeNotificationImpl.java?rev=290478&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/ChangeNotificationImpl.java (added)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/ChangeNotificationImpl.java Tue Sep 20 08:55:05 2005
@@ -0,0 +1,13 @@
+package org.apache.ws.client.muse.client.impl.notification;
+
+import org.apache.ws.client.muse.client.model.ChangeNotification;
+
+
+public class ChangeNotificationImpl implements ChangeNotification {
+
+ public ChangeNotificationImpl() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+}
Modified: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationConsumerImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationConsumerImpl.java?rev=290478&r1=290477&r2=290478&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationConsumerImpl.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationConsumerImpl.java Tue Sep 20 08:55:05 2005
@@ -37,6 +37,7 @@
import org.apache.ws.addressing.XmlBeansEndpointReference;
import org.apache.ws.client.muse.client.NotificationConsumer;
import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+import org.apache.ws.client.muse.client.model.Notification;
import org.apache.xmlbeans.XmlException;
/**
@@ -236,9 +237,9 @@
*/
private void deliverNotification(String notificationText, HttpHeader header) throws XmlException, UnexpectedServerResponseException {
hasChanged();
- NotificationImpl[] notifications = NotificationImpl.createNotifications(notificationText,header);
+ Notification[] notifications = NotificationImpl.createNotifications(notificationText,header);
for (int i = 0; i < notifications.length; i++) {
- NotificationImpl notification = notifications[i];
+ Notification notification = notifications[i];
notifyObservers(notification);
}
clearChanged();
Modified: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationImpl.java?rev=290478&r1=290477&r2=290478&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationImpl.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotificationImpl.java Tue Sep 20 08:55:05 2005
@@ -6,10 +6,14 @@
import org.apache.ws.addressing.EndpointReference;
import org.apache.ws.addressing.XmlBeansEndpointReference;
import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+import org.apache.ws.client.muse.client.model.ChangeNotification;
+import org.apache.ws.client.muse.client.model.Notification;
+import org.apache.ws.client.muse.client.model.Situation;
import org.apache.ws.client.muse.client.model.TopicExpression;
import org.apache.ws.util.XmlBeanUtils;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ComponentAddressType;
import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ComponentType;
import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.impl.ManagementEventTypeImpl;
@@ -20,7 +24,7 @@
import org.xmlsoap.schemas.soap.envelope.Body;
import org.xmlsoap.schemas.soap.envelope.EnvelopeDocument;
-public class NotificationImpl {
+public class NotificationImpl implements Notification {
//private String notificationText;
private HttpHeader header;
private GetCurrentMessageResponse response;
@@ -64,7 +68,7 @@
NotificationMessageHolderType message = messages[i];
notifications.add(new NotificationImpl(message,header));
}
- return (NotificationImpl[]) notifications.toArray(new NotificationImpl[0]);
+ return (NotificationImpl[]) notifications.toArray(new Notification[0]);
}
public void validate(){
@@ -118,7 +122,6 @@
ComponentAddressType[] eprArry = getSource().getComponentAddressArray();
for (int i = 0; i < eprArry.length; i++) {
ComponentAddressType type = eprArry[i];
-
}
return null;
@@ -143,5 +146,15 @@
return null;
}
+
+ public Situation getSituation(){
+ return null;
+ }
+ public ChangeNotification getChangeNotification(){
+ return null;
+ }
+ public XmlObject[] getNotificationPayload(){
+ return null;
+ }
}
Modified: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceImpl.java?rev=290478&r1=290477&r2=290478&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceImpl.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceImpl.java Tue Sep 20 08:55:05 2005
@@ -31,6 +31,7 @@
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.model.Notification;
import org.apache.ws.client.muse.client.model.Query;
import org.apache.ws.client.muse.client.model.TopicExpression;
import org.apache.ws.muws.v1_0.impl.advertiser.ResourceAdvertiserPropertyQNames;
@@ -202,7 +203,7 @@
/* (non-Javadoc)
* @see org.apache.ws.client.muse.client.impl.notification.NotifyableResource#getCurrentMessage(org.apache.ws.client.muse.client.impl.notification.TopicExpressionImpl)
*/
- public NotificationImpl getCurrentMessage(TopicExpression topic) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
+ public Notification getCurrentMessage(TopicExpression topic) throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
//TODO This is not finished.
// Construct request
GetCurrentMessageDocument cmd=GetCurrentMessageDocument.Factory.newInstance();
Added: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/SituationImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/SituationImpl.java?rev=290478&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/SituationImpl.java (added)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/SituationImpl.java Tue Sep 20 08:55:05 2005
@@ -0,0 +1,12 @@
+package org.apache.ws.client.muse.client.impl.notification;
+
+import org.apache.ws.client.muse.client.model.Situation;
+
+public class SituationImpl implements Situation {
+
+ public SituationImpl() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+}
Added: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/ChangeNotification.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/ChangeNotification.java?rev=290478&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/ChangeNotification.java (added)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/ChangeNotification.java Tue Sep 20 08:55:05 2005
@@ -0,0 +1,5 @@
+package org.apache.ws.client.muse.client.model;
+
+public interface ChangeNotification {
+
+}
\ No newline at end of file
Added: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Notification.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Notification.java?rev=290478&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Notification.java (added)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Notification.java Tue Sep 20 08:55:05 2005
@@ -0,0 +1,46 @@
+package org.apache.ws.client.muse.client.model;
+
+import java.util.Calendar;
+
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ComponentType;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.impl.ManagementEventTypeImpl;
+
+public interface Notification {
+
+ public abstract EndpointReference getProducerReference();
+
+ public abstract XmlObject getNotificationMessage();
+
+ // MUWS ----------------------------------------------
+
+ public abstract ManagementEventTypeImpl getManagementEvent();
+
+ public abstract String getEventId();
+
+ public abstract Calendar getReportTime();
+
+ public abstract ComponentType getSource();
+
+ public abstract String getSourceId();
+
+ // TODO Implementation of this will have to wait until the unit test
+ public abstract EndpointReference[] getSourceEndpointReferences();
+
+ public abstract ComponentType getReporter();
+
+ public abstract String getReporterId();
+
+ public abstract String getReporterEndpointReference();
+
+ // TODO Implementation of this will have to wait until the unit test
+ public abstract EndpointReference[] getReporterEndpointReferences();
+
+ public abstract Situation getSituation();
+
+ public abstract ChangeNotification getChangeNotification();
+
+ public abstract XmlObject[] getNotificationPayload();
+
+}
\ No newline at end of file
Added: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Situation.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Situation.java?rev=290478&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Situation.java (added)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Situation.java Tue Sep 20 08:55:05 2005
@@ -0,0 +1,5 @@
+package org.apache.ws.client.muse.client.model;
+
+public interface Situation {
+
+}
\ No newline at end of file