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/28 17:04:29 UTC
svn commit: r292204 - in
/webservices/muse/trunk/src/examples/client/src/java: ./
org/apache/ws/client/muse/client/impl/notification/
org/apache/ws/client/muse/client/model/
Author: wire
Date: Wed Sep 28 08:04:22 2005
New Revision: 292204
URL: http://svn.apache.org/viewcvs?rev=292204&view=rev
Log:
Finishing up notification for change and situtation
Modified:
webservices/muse/trunk/src/examples/client/src/java/Sample2.java
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/NotificationImpl.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/Sample2.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/Sample2.java?rev=292204&r1=292203&r2=292204&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/Sample2.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/Sample2.java Wed Sep 28 08:04:22 2005
@@ -123,11 +123,21 @@
// What is the content of the Change Notification?
Notification notification = (Notification) notificationObject;
- ChangeNotification changeNotification = notification
- .getChangeNotification();
+ try {
+ ChangeNotification changeNotification = notification
+ .getChangeNotification();
+ } catch (UnexpectedServerResponseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
// What is the situation?
- Situation situation = notification.getSituation();
+ try {
+ Situation situation = notification.getSituation();
+ } catch (UnexpectedServerResponseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
// What is the raw text of the notification?
String text = notification.getNotificationMessage().toString();
Modified: 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=292204&r1=292203&r2=292204&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/ChangeNotificationImpl.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/ChangeNotificationImpl.java Wed Sep 28 08:04:22 2005
@@ -1,13 +1,104 @@
package org.apache.ws.client.muse.client.impl.notification;
+import javax.xml.namespace.QName;
+
+import org.apache.axis.utils.BeanUtils;
+import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+import org.apache.ws.client.muse.client.impl.wsrf.InsertOrUpdateRequest;
+import org.apache.ws.client.muse.client.impl.wsrf.SetPropertiesRequestImpl;
import org.apache.ws.client.muse.client.model.ChangeNotification;
+import org.apache.ws.client.muse.client.model.SetPropertiesRequest;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.impl.ManagementEventTypeImpl;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.ResourcePropertyValueChangeNotificationType;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.ResourcePropertyValueChangeNotificationType.OldValue;
public class ChangeNotificationImpl implements ChangeNotification {
- public ChangeNotificationImpl() {
+ private ResourcePropertyValueChangeNotificationType propChange;
+
+ public ChangeNotificationImpl(ManagementEventTypeImpl manEvt) throws UnexpectedServerResponseException {
super();
- // TODO Auto-generated constructor stub
+ XmlObject[] childElements = XmlBeanUtils.getChildElements(manEvt);
+ for (int i = 0; i < childElements.length; i++) {
+ if(childElements[i] instanceof ResourcePropertyValueChangeNotificationType)
+ {
+ propChange =
+ (ResourcePropertyValueChangeNotificationType) childElements[i];
+ return;
+ }
+ }
+
+ throw new UnexpectedServerResponseException("Could not locate ResourcePropertyValueChangeNotification inside this notification.");
+
+ }
+
+ public XmlObject[] getOldValuesPayload(){
+ return XmlBeanUtils.getChildElements(propChange.getOldValue());
+ }
+ public XmlObject[] getNewValuesPayload(){
+ return XmlBeanUtils.getChildElements(propChange.getNewValue());
+ }
+ public SetPropertiesRequest getOldValues(){
+ SetPropertiesRequestImpl setProp = new SetPropertiesRequestImpl();
+ XmlObject[] arryVals = getOldValuesPayload();
+ for (int i = 0; i < arryVals.length; i++) {
+ XmlObject object = arryVals[i];
+ setProp.addUpdateRequest(XmlBeanUtils.getName(object),new String[]{XmlBeanUtils.getValue(object)});
+ }
+ return setProp;
+ }
+
+ public SetPropertiesRequest getNewValues(){
+ XmlObject[] arryVals = getNewValuesPayload();
+ SetPropertiesRequestImpl setProp = new SetPropertiesRequestImpl();
+ for (int i = 0; i < arryVals.length; i++) {
+ XmlObject object = arryVals[i];
+ setProp.addUpdateRequest(XmlBeanUtils.getName(object),new String[]{XmlBeanUtils.getValue(object)});
+ }
+ return setProp;
}
+
+ public String getNewValueAsString(){
+ SetPropertiesRequest props = getNewValues();
+ if(props.getAllResourcesIndex()>0){
+ InsertOrUpdateRequest req = (InsertOrUpdateRequest)props.getAllSetResourceRequests().get(0);
+ return req.getPropetyValues()[0];
+ } else {
+ return null;
+ }
+ }
+
+ public String getOldValueAsString(){
+ SetPropertiesRequest props = getOldValues();
+ if(props.getAllResourcesIndex()>0){
+ InsertOrUpdateRequest req = (InsertOrUpdateRequest)props.getAllSetResourceRequests().get(0);
+ return req.getPropetyValues()[0];
+ } else {
+ return null;
+ }
+ }
+
+ public QName getNewValueName(){
+ SetPropertiesRequest props = getNewValues();
+ if(props.getAllResourcesIndex()>0){
+ InsertOrUpdateRequest req = (InsertOrUpdateRequest)props.getAllSetResourceRequests().get(0);
+ return req.getProperty();
+ } else {
+ return null;
+ }
+ }
+ public QName getOldValueName(){
+ SetPropertiesRequest props = getOldValues();
+ if(props.getAllResourcesIndex()>0){
+ InsertOrUpdateRequest req = (InsertOrUpdateRequest)props.getAllSetResourceRequests().get(0);
+ return req.getProperty();
+ } else {
+ return null;
+ }
+
+ }
}
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=292204&r1=292203&r2=292204&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 Wed Sep 28 08:04:22 2005
@@ -221,18 +221,17 @@
return eprArry;
}
- // TODO Needs to be implemented
- public Situation getSituation(){
- return null;
+ public Situation getSituation() throws UnexpectedServerResponseException{
+ return new SituationImpl(getManagementEvent());
}
- // TODO Needs to be implemented
- public ChangeNotification getChangeNotification(){
- return null;
+
+ public ChangeNotification getChangeNotification() throws UnexpectedServerResponseException{
+ return new ChangeNotificationImpl(getManagementEvent());
}
- // TODO Needs to be implemented
+
public XmlObject[] getNotificationPayload(){
- return null;
+ return XmlBeanUtils.getChildElements(getManagementEvent());
}
}
Modified: 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=292204&r1=292203&r2=292204&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/SituationImpl.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/notification/SituationImpl.java Wed Sep 28 08:04:22 2005
@@ -1,12 +1,90 @@
package org.apache.ws.client.muse.client.impl.notification;
+import java.util.Calendar;
+
+import javax.xml.namespace.QName;
+
+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.Situation;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.impl.ManagementEventTypeImpl;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.SituationCategoryType;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.impl.SituationTypeImpl;
public class SituationImpl implements Situation {
- public SituationImpl() {
+ private SituationTypeImpl situation;
+
+ public SituationImpl(ManagementEventTypeImpl manEvt) throws UnexpectedServerResponseException {
super();
- // TODO Auto-generated constructor stub
+ XmlObject[] childElements = XmlBeanUtils.getChildElements(manEvt);
+ for (int i = 0; i < childElements.length; i++) {
+ if(childElements[i] instanceof SituationTypeImpl)
+ {
+ situation =
+ (SituationTypeImpl) childElements[i];
+ return;
+ }
+ }
+
+ throw new UnexpectedServerResponseException("Could not locate Situation inside this notification.");
+
+ }
+
+
+ public QName getAvailabilitySituation(){
+ SituationCategoryType catagory = situation.getSituationCategory();
+ return XmlBeanUtils.getName(catagory);
+ }
+
+ public String getSuccessDisposition(){
+ return situation.getSuccessDisposition().toString();
+ }
+
+ public Calendar getTime(){
+ return situation.getSituationTime();
+ }
+
+ public short getPriotity(){
+ return situation.getPriority();
+ }
+
+ public short getSeverity(){
+ return situation.getSeverity();
+ }
+
+ public String getMessage(){
+ return situation.getMessage().getStringValue();
}
+ public String getMessageLang(){
+ return situation.getMessage().getLang();
+ }
+
+ public XmlObject getSubsitutableMessage(){
+ return situation.getSubstitutableMsg();
+ }
+
+ public static void main(String[] args) {
+ String message="<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Header><wsa03:To soapenv:actor=\"http://schemas.xmlsoap.org/soap/actor/next\" soapenv:mustUnderstand=\"0\" xmlns:wsa03=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\">http://localhost:8089/endpoint/wsmgr?a=/11310</wsa03:To><wsa03:Action soapenv:actor=\"http://schemas.xmlsoap.org/soap/actor/next\" soapenv:mustUnderstand=\"0\" xmlns:wsa03=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\">http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.wsdl/Notify</wsa03:Action></soapenv:Header><soapenv:Body><wsn:Notify xmlns:wsn=\"http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd\"><wsn:NotificationMessage><wsn:Topic xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2-events.xml\" Dialect=\"http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Simple\">wsdm:OperationalStatusCapability</wsn:Topic><wsn:ProducerReference><add:Address xmlns:add=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\">http://192.168.1.241:8080/muse/services/weather-station</add:Address><add:ReferenceProperties xmlns:add=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\"><weat:ResourceIdentifier xmlns:weat=\"http://wsdmdemo.org/service/weather-station\">weather-station-1</weat:ResourceIdentifier></add:ReferenceProperties><add:PortType xmlns:weat=\"http://wsdmdemo.org/service/weather-station\" xmlns:add=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\">weat:WeatherStationPortType</add:PortType><add:ServiceName xmlns:weat=\"http://wsdmdemo.org/service/weather-station\" xmlns:add=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\" PortName=\"weather-station\">weat:weather-station</add:ServiceName></wsn:ProducerReference><wsn:Message><wsdm:ManagementEvent xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part1.xsd\" ReportTime=\"2005-09-19T11:50:31.660-04:00\"><wsdm:EventId>40d8345e-7e7f-4a60-b544-67e77c2ea6ad</wsdm:EventId><wsdm:SourceComponent/><wsdm:ReporterComponent/><wsdm:Situation xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd\"><wsdm:SituationCategory><muws-p2-xs:OtherSituation xmlns:muws-p2-xs=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd\"/></wsdm:SituationCategory></wsdm:Situation><wsrf:ResourcePropertyValueChangeNotification xmlns:wsrf=\"http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd\"><wsrf:OldValue><wsdm:OperationalStatus xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd\">Available</wsdm:OperationalStatus></wsrf:OldValue><wsrf:NewValue><wsdm:OperationalStatus xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd\">Unavailable</wsdm:OperationalStatus></wsrf:NewValue></wsrf:ResourcePropertyValueChangeNotification></wsdm:ManagementEvent></wsn:Message></wsn:NotificationMessage></wsn:Notify></soapenv:Body></soapenv:Envelope>";
+ Notification[] notifications=null;
+ try {
+ notifications = NotificationImpl.create(message,null);
+ } catch (XmlException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (UnexpectedServerResponseException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ try {
+ new SituationImpl(notifications[0].getManagementEvent());
+ } catch (UnexpectedServerResponseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
Modified: 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=292204&r1=292203&r2=292204&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/ChangeNotification.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/ChangeNotification.java Wed Sep 28 08:04:22 2005
@@ -1,5 +1,16 @@
package org.apache.ws.client.muse.client.model;
-public interface ChangeNotification {
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlObject;
+public interface ChangeNotification {
+ public XmlObject[] getOldValuesPayload();
+ public XmlObject[] getNewValuesPayload();
+ public SetPropertiesRequest getOldValues();
+ public SetPropertiesRequest getNewValues();
+ public String getNewValueAsString();
+ public String getOldValueAsString();
+ public QName getNewValueName();
+ public QName getOldValueName();
}
Modified: 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=292204&r1=292203&r2=292204&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Notification.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Notification.java Wed Sep 28 08:04:22 2005
@@ -3,6 +3,7 @@
import java.util.Calendar;
import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
import org.apache.xmlbeans.XmlObject;
import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ComponentAddressType;
import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ComponentType;
@@ -35,9 +36,9 @@
public abstract ComponentAddressType[] getReporterComponentAddresses();
- public abstract Situation getSituation();
+ public abstract Situation getSituation() throws UnexpectedServerResponseException;
- public abstract ChangeNotification getChangeNotification();
+ public abstract ChangeNotification getChangeNotification() throws UnexpectedServerResponseException;
public abstract XmlObject[] getNotificationPayload();
Modified: 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=292204&r1=292203&r2=292204&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Situation.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/model/Situation.java Wed Sep 28 08:04:22 2005
@@ -1,5 +1,57 @@
package org.apache.ws.client.muse.client.model;
+import java.util.Calendar;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlObject;
+
public interface Situation {
+ public static final QName SITUATION_AVAILABILITY=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","AvailabilitySituation");
+ public static final QName SITUATION_CAPABILITY=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","CapabilitySituation");
+ public static final QName SITUATION_CONFIGURE=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","ConfigureSituation");
+ public static final QName SITUATION_STOP=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","StopSituation");
+ public static final QName SITUATION_START=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","StartSituation");
+ public static final QName SITUATION_REQUEST=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","RequestSituation");
+ public static final QName SITUATION_CREATE=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","CreateSituation");
+ public static final QName SITUATION_DEPENDENCY=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","DependencySituation");
+ public static final QName SITUATION_CONNECT=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","ConnectSituation");
+ public static final QName SITUATION_REPORT=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","ReportSituation");
+ public static final QName SITUATION_OTHER=new QName("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd","OtherSituation");
+ public static final String DISPOSITION_SUCCESSFUL="Successful";
+ public static final String DISPOSITION_UNSUCCESSFUL="Unsuccessful";
+ public static final short PRIORITY_LOW=10;
+ public static final short PRIORITY_MEDIUM=50;
+ public static final short PRIORITY_HIGH=70;
+ /** a condition is unrecoverable and the service is no longer available. */
+ public static final short SEVERITY_FATAL=6;
+ /** a condition affecting the service has occurred. Immediate corrective action is required. */
+ public static final short SEVERITY_CRITICAL=5;
+ /** a problem of relatively high severity has occurred. It is likely that normal use of the service is impeded. */
+ public static final short SEVERITY_MAJOR=4;
+ /** A problem of relatively low severity has occurred. It is unlikely that normal use
+ of the service is impeded. */
+ public static final short SEVERITY_MINOR=3;
+ /** A problem affecting the service may occur. Diagnostic and corrective action
+ is recommended. */
+ public static final short SEVERITY_WARNING=2;
+ /** A message output considered as normal and expected. For example, a process begins, a process finishes, or status information is displayed.*/
+ public static final short SEVERITY_INFORMATION=1;
+ /** A severity level cannot be determined.*/
+ public static final short SEVERITY_UNKNOWN=0;
+
+ public QName getAvailabilitySituation();
+
+ public String getSuccessDisposition();
+
+ public Calendar getTime();
+
+ public short getPriotity();
+ public short getSeverity();
+
+ public String getMessage();
+ public String getMessageLang();
+
+ public XmlObject getSubsitutableMessage();
}