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/18 04:06:12 UTC
svn commit: r432465 - in
/webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache: muse/
muse/ws/ muse/ws/dm/ muse/ws/dm/muws/ muse/ws/dm/muws/events/
muse/ws/dm/muws/events/impl/ ws/
Author: danj
Date: Thu Aug 17 19:06:09 2006
New Revision: 432465
URL: http://svn.apache.org/viewvc?rev=432465&view=rev
Log:
Fix for MUSE-66 - added the extra level of directory needed to have the path match the package.
Added:
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/AbstractExtendedElements.java
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponent.java
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponentAddress.java
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleManagementEvent.java
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSituation.java
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSubstitutableMessage.java
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleWefFactory.java
Removed:
webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/ws/
Added: webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/AbstractExtendedElements.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/AbstractExtendedElements.java?rev=432465&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/AbstractExtendedElements.java (added)
+++ webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/AbstractExtendedElements.java Thu Aug 17 19:06:09 2006
@@ -0,0 +1,86 @@
+/*=============================================================================*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.dm.muws.events.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.dm.muws.events.ExtendedElements;
+
+/**
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class AbstractExtendedElements implements ExtendedElements
+{
+ private Collection _extendedElements = new ArrayList();
+
+ public final void addExtendedElement(Element xml)
+ {
+ _extendedElements.add(xml);
+ }
+
+ public final void addExtendedElement(QName elementName, Object elementValue)
+ {
+ addExtendedElement(XmlUtils.createElement(elementName, elementValue));
+ }
+
+ public final Collection getExtendedElements()
+ {
+ return _extendedElements;
+ }
+
+ public final Collection getExtendedElements(QName elementName)
+ {
+ Collection results = new ArrayList();
+
+ Iterator i = getExtendedElements().iterator();
+
+ while (i.hasNext())
+ {
+ Element next = (Element)i.next();
+ QName nextName = XmlUtils.getElementQName(next);
+
+ if (nextName.equals(elementName))
+ results.add(next);
+ }
+
+ return results;
+ }
+
+ protected void appendExtendedElements(Element xml)
+ {
+ Document doc = xml.getOwnerDocument();
+ Iterator i = getExtendedElements().iterator();
+
+ while (i.hasNext())
+ {
+ Element next = (Element)i.next();
+ next = (Element)doc.importNode(next, true);
+ xml.appendChild(next);
+ }
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponent.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponent.java?rev=432465&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponent.java (added)
+++ webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponent.java Thu Aug 17 19:06:09 2006
@@ -0,0 +1,127 @@
+/*=============================================================================*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.dm.muws.events.impl;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.dm.muws.events.Component;
+import org.apache.muse.ws.dm.muws.events.ComponentAddress;
+import org.apache.muse.ws.dm.muws.events.WefConstants;
+import org.apache.muse.ws.dm.muws.events.WefFactory;
+
+/**
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleComponent
+ extends AbstractExtendedElements implements Component
+{
+ private ComponentAddress _address = null;
+
+ private QName _name = null;
+
+ private String _resourceID = null;
+
+ public SimpleComponent()
+ {
+ //
+ // no default action - allow people to create "blank"
+ // components and validate in toXML()
+ //
+ }
+
+ public SimpleComponent(Element xml, WefFactory factory)
+ {
+ _name = XmlUtils.getElementQName(xml);
+
+ Element addressXML = XmlUtils.getElement(xml, WefConstants.COMP_ADDRESS_QNAME);
+ _address = factory.createComponentAddress(addressXML);
+ }
+
+ public ComponentAddress getAddress()
+ {
+ return _address;
+ }
+
+ public QName getName()
+ {
+ return _name;
+ }
+
+ public String getResourceID()
+ {
+ return _resourceID;
+ }
+
+ public void setAddress(ComponentAddress address)
+ {
+ _address = address;
+ }
+
+ public void setName(QName name)
+ {
+ _name = name;
+ }
+
+ public void setResourceID(String resourceID)
+ {
+ _resourceID = resourceID;
+ }
+
+ public String toString()
+ {
+ return XmlUtils.toString(toXML(), false);
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document factory)
+ {
+ QName name = getName();
+
+ if (name == null)
+ throw new RuntimeException("Invalid component type: no root name.");
+
+ Element componentXML = XmlUtils.createElement(factory, name);
+
+ ComponentAddress address = getAddress();
+
+ if (address != null)
+ {
+ Element addressXML = address.toXML(factory);
+ componentXML.appendChild(addressXML);
+ }
+
+ String resourceID = getResourceID();
+
+ if (resourceID != null)
+ XmlUtils.setElement(componentXML, WefConstants.RESOURCE_ID_QNAME, resourceID);
+
+ appendExtendedElements(componentXML);
+
+ return componentXML;
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponentAddress.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponentAddress.java?rev=432465&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponentAddress.java (added)
+++ webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleComponentAddress.java Thu Aug 17 19:06:09 2006
@@ -0,0 +1,66 @@
+/*=============================================================================*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.dm.muws.events.impl;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.dm.muws.events.ComponentAddress;
+import org.apache.muse.ws.dm.muws.events.WefConstants;
+
+/**
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleComponentAddress
+ extends AbstractExtendedElements implements ComponentAddress
+{
+ private Element _contents = null;
+
+ public SimpleComponentAddress()
+ {
+ this(null);
+ }
+
+ public SimpleComponentAddress(Element contents)
+ {
+ _contents = contents;
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document factory)
+ {
+ Element addressXML = XmlUtils.createElement(factory, WefConstants.COMP_ADDRESS_QNAME);
+
+ if (_contents != null)
+ {
+ Element copy = (Element)factory.importNode(_contents, true);
+ addressXML.appendChild(copy);
+ }
+
+ appendExtendedElements(addressXML);
+
+ return addressXML;
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleManagementEvent.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleManagementEvent.java?rev=432465&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleManagementEvent.java (added)
+++ webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleManagementEvent.java Thu Aug 17 19:06:09 2006
@@ -0,0 +1,252 @@
+/*=============================================================================*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.dm.muws.events.impl;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.uuid.RandomUuidFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.util.xml.XsdUtils;
+import org.apache.muse.ws.dm.muws.events.Component;
+import org.apache.muse.ws.dm.muws.events.ManagementEvent;
+import org.apache.muse.ws.dm.muws.events.Situation;
+import org.apache.muse.ws.dm.muws.events.WefFactory;
+import org.apache.muse.ws.dm.muws.events.WefConstants;
+
+/**
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleManagementEvent
+ extends AbstractExtendedElements implements ManagementEvent
+{
+ private String _eventID = RandomUuidFactory.getInstance().createUUID();
+
+ private Component _reporter = null;
+
+ private Date _reportTime = new Date();
+
+ private long _sequenceNumber = -1;
+
+ private Component _source = null;
+
+ private Situation _situation = null;
+
+ public SimpleManagementEvent()
+ {
+ //
+ // no action - allow people to construct WEFs starting with
+ // a blank event. toXML() will validate before serializing
+ //
+ }
+
+ public SimpleManagementEvent(Element xml, WefFactory factory)
+ {
+ //
+ // NOTE: we can call public get/set methods in the constructor
+ // because these methods are final
+ //
+
+ String sequenceString = xml.getAttributeNS(WefConstants.MUWS_P2_URI, WefConstants.SEQUENCE_NUMBER);
+
+ if (sequenceString != null && sequenceString.length() > 0)
+ _sequenceNumber = Long.parseLong(sequenceString);
+
+ String timeString = xml.getAttribute(WefConstants.REPORT_TIME);
+
+ try
+ {
+ if (timeString != null && timeString.length() > 0)
+ setReportTime(XsdUtils.getLocalTime(timeString));
+ }
+
+ catch (ParseException error)
+ {
+ throw new RuntimeException(error.getMessage(), error);
+ }
+
+ //
+ // keep track of all elements in the MUWS namespaces - the
+ // ones leftover are the "extended elements"
+ //
+ Set alreadySeen = new HashSet();
+
+ Element idXML = XmlUtils.getElement(xml, WefConstants.EVENT_ID_QNAME);
+
+ if (idXML != null)
+ {
+ setEventID(XmlUtils.extractText(idXML));
+ alreadySeen.add(idXML);
+ }
+
+ Element reporterXML = XmlUtils.getElement(xml, WefConstants.REPORTER_COMP_QNAME);
+ Component reporter = factory.createComponent(reporterXML);
+ setReporter(reporter);
+ alreadySeen.add(reporterXML);
+
+ Element sourceXML = XmlUtils.getElement(xml, WefConstants.SOURCE_COMP_QNAME);
+ Component source = factory.createComponent(sourceXML);
+ setSource(source);
+ alreadySeen.add(sourceXML);
+
+ Element situationXML = XmlUtils.getElement(xml, WefConstants.SITUATION_QNAME);
+
+ if (situationXML != null)
+ {
+ Situation situation = factory.createSituation(situationXML);
+ setSituation(situation);
+ alreadySeen.add(situationXML);
+ }
+
+ Element[] children = XmlUtils.getAllElements(xml);
+
+ for (int n = 0; n < children.length; ++n)
+ if (!alreadySeen.contains(children[n]))
+ addExtendedElement(children[n]);
+ }
+
+ public final String getEventID()
+ {
+ return _eventID;
+ }
+
+ public final Component getReporter()
+ {
+ return _reporter;
+ }
+
+ public final Date getReportTime()
+ {
+ return _reportTime;
+ }
+
+ public final long getSequenceNumber()
+ {
+ return _sequenceNumber;
+ }
+
+ public final Situation getSituation()
+ {
+ return _situation;
+ }
+
+ public final Component getSource()
+ {
+ return _source;
+ }
+
+ public final void setEventID(String eventID)
+ {
+ _eventID = eventID;
+ }
+
+ public final void setReporter(Component reporter)
+ {
+ _reporter = reporter;
+ }
+
+ public final void setReportTime(Date reportTime)
+ {
+ _reportTime = reportTime;
+ }
+
+ public final void setSequenceNumber(long sequenceNumber)
+ {
+ _sequenceNumber = sequenceNumber;
+ }
+
+ public final void setSituation(Situation situation)
+ {
+ _situation = situation;
+ }
+
+ public final void setSource(Component source)
+ {
+ _source = source;
+ }
+
+ public String toString()
+ {
+ return XmlUtils.toString(toXML(), false);
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document doc)
+ {
+ Element wef = XmlUtils.createElement(doc, WefConstants.MGMT_EVENT_QNAME);
+
+ long sequence = getSequenceNumber();
+
+ if (sequence >= 0)
+ {
+ String name = WefConstants.MUWS_P2_PREFIX + ':' + WefConstants.SEQUENCE_NUMBER;
+ wef.setAttributeNS(WefConstants.MUWS_P2_URI, name, Long.toString(sequence));
+ }
+
+ Date time = getReportTime();
+
+ if (time != null)
+ wef.setAttribute(WefConstants.REPORT_TIME, XsdUtils.getLocalTimeString(time));
+
+ String eventID = getEventID();
+
+ if (eventID == null)
+ throw new RuntimeException("Invalid WEF: no EventID");
+
+ XmlUtils.setElement(wef, WefConstants.EVENT_ID_QNAME, eventID);
+
+ Component source = getSource();
+
+ if (source == null)
+ throw new RuntimeException("Invalid WEF: no source component.");
+
+ Element sourceXML = source.toXML(doc);
+ wef.appendChild(sourceXML);
+
+ Component reporter = getReporter();
+
+ if (reporter!= null)
+ {
+ Element reporterXML = reporter.toXML(doc);
+ wef.appendChild(reporterXML);
+ }
+
+ Situation situation = getSituation();
+
+ if (situation != null)
+ {
+ Element situationXML = situation.toXML(doc);
+ wef.appendChild(situationXML);
+ }
+
+ appendExtendedElements(wef);
+
+ return wef;
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSituation.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSituation.java?rev=432465&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSituation.java (added)
+++ webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSituation.java Thu Aug 17 19:06:09 2006
@@ -0,0 +1,265 @@
+/*=============================================================================*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.dm.muws.events.impl;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.dm.muws.events.Situation;
+import org.apache.muse.ws.dm.muws.events.SubstitutableMessage;
+import org.apache.muse.ws.dm.muws.events.WefConstants;
+
+/**
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleSituation implements Situation
+{
+ private QName[] _categoryType = null;
+
+ private String _message = null;
+
+ private SubstitutableMessage _subMessage = null;
+
+ private String _successDisposition = null;
+
+ private Date _situationTime = new Date();
+
+ private short _priority = -1;
+
+ private short _severity = -1;
+
+ public SimpleSituation()
+ {
+ //
+ // no action - allow users to create situations from scratch
+ //
+ }
+
+ public SimpleSituation(Element xml)
+ {
+ //
+ // NOTE: we can use public get/set methods in the constructor
+ // because they are final
+ //
+ setMessage(XmlUtils.getElementText(xml, WefConstants.MESSAGE_QNAME));
+
+ String disposition = XmlUtils.getElementText(xml, WefConstants.SUCCESS_DISPOSITION_QNAME);
+
+ if (disposition != null)
+ setSuccessDisposition(disposition);
+
+ Element priorityXML = XmlUtils.getElement(xml, WefConstants.PRIORITY_QNAME);
+
+ if (priorityXML != null)
+ _priority = XmlUtils.getShort(priorityXML).shortValue();
+
+ Element severityXML = XmlUtils.getElement(xml, WefConstants.SEVERITY_QNAME);
+
+ if (severityXML != null)
+ _severity = XmlUtils.getShort(severityXML).shortValue();
+
+ Element timeXML = XmlUtils.getElement(xml, WefConstants.SITUATION_TIME_QNAME);
+
+ try
+ {
+ if (timeXML != null)
+ _situationTime = XmlUtils.getDate(timeXML);
+ }
+
+ catch (ParseException error)
+ {
+ throw new RuntimeException(error.getMessage(), error);
+ }
+
+ Element categoryXML = XmlUtils.getElement(xml, WefConstants.SITUATION_CATEGORY_QNAME);
+ Element categoryTypeXML = XmlUtils.getFirstElement(categoryXML);
+
+ List hierarchy = new LinkedList();
+
+ while (categoryTypeXML != null)
+ {
+ QName categoryName = XmlUtils.getElementQName(categoryTypeXML);
+ hierarchy.add(categoryName);
+ categoryTypeXML = XmlUtils.getElement(categoryTypeXML, WefConstants.SITUATION_CATEGORY_QNAME);
+ }
+
+ _categoryType = new QName[hierarchy.size()];
+ _categoryType = (QName[])hierarchy.toArray(_categoryType);
+ }
+
+ public final short getPriority()
+ {
+ return _priority;
+ }
+
+ public final short getSeverity()
+ {
+ return _severity;
+ }
+
+ public final Date getSituationTime()
+ {
+ return _situationTime;
+ }
+
+ public final SubstitutableMessage getSubstitutableMessage()
+ {
+ return _subMessage;
+ }
+
+ public final String getSuccessDisposition()
+ {
+ return _successDisposition;
+ }
+
+ public final void setPriority(short priority)
+ {
+ if (priority < LOWEST_PRIORITY || priority > HIGHEST_PRIORITY)
+ throw new IllegalArgumentException("Priority out of bounds: " + priority);
+
+ _priority = priority;
+ }
+
+ public final void setSeverity(short severity)
+ {
+ if (severity < UNKNOWN_SEVERITY || severity > FATAL_SEVERITY)
+ throw new IllegalArgumentException("Severity out of bounds: " + severity);
+
+ _severity = severity;
+ }
+
+ public final void setSituationTime(Date situationTime)
+ {
+ _situationTime = situationTime;
+ }
+
+ public final void setSubstitutableMessage(SubstitutableMessage message)
+ {
+ _subMessage = message;
+ }
+
+ public final void setSuccessDisposition(String disposition)
+ {
+ if (!UNSUCCESSFUL.equals(disposition) && !SUCCESSFUL.equals(disposition))
+ throw new IllegalArgumentException("Invalid disposition: " + disposition);
+
+ _successDisposition = disposition;
+ }
+
+ public final String getMessage()
+ {
+ return _message;
+ }
+
+ public final void setMessage(String message)
+ {
+ _message = message;
+ }
+
+ public final QName[] getCategoryType()
+ {
+ return _categoryType;
+ }
+
+ public final void setCategoryType(QName categoryType)
+ {
+ setCategoryType(new QName[]{ categoryType });
+ }
+
+ public final void setCategoryType(QName[] categoryType)
+ {
+ if (categoryType == null || categoryType.length == 0)
+ throw new RuntimeException("Invalid Situation: no category type");
+
+ _categoryType = categoryType;
+ }
+
+ public String toString()
+ {
+ return XmlUtils.toString(toXML(), false);
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document factory)
+ {
+ Element situation = XmlUtils.createElement(factory, WefConstants.SITUATION_QNAME);
+
+ QName[] type = getCategoryType();
+
+ if (type == null || type.length == 0)
+ throw new RuntimeException("Invalid Situation: no category type");
+
+ Element categoryType = XmlUtils.createElement(factory, WefConstants.SITUATION_CATEGORY_QNAME);
+ situation.appendChild(categoryType);
+
+ Element parent = categoryType;
+
+ for (int n = 0; n < type.length; ++n)
+ {
+ Element nextPart = XmlUtils.createElement(factory, type[n]);
+ parent.appendChild(nextPart);
+ parent = nextPart;
+ }
+
+ String disposition = getSuccessDisposition();
+
+ if (disposition != null)
+ XmlUtils.setElement(situation, WefConstants.SUCCESS_DISPOSITION_QNAME, disposition);
+
+ Date time = getSituationTime();
+
+ if (time != null)
+ XmlUtils.setElement(situation, WefConstants.SITUATION_TIME_QNAME, time);
+
+ short priority = getPriority();
+
+ if (priority >= 0)
+ XmlUtils.setElement(situation, WefConstants.PRIORITY_QNAME, new Short(priority));
+
+ short severity = getSeverity();
+
+ if (severity >= 0)
+ XmlUtils.setElement(situation, WefConstants.SEVERITY_QNAME, new Short(severity));
+
+ String message = getMessage();
+
+ if (message != null)
+ XmlUtils.setElement(situation, WefConstants.MESSAGE_QNAME, message);
+
+ SubstitutableMessage subMessage = getSubstitutableMessage();
+
+ if (subMessage != null)
+ XmlUtils.setElement(situation, WefConstants.SUBSTITUTABLE_MSG_QNAME, subMessage);
+
+ return situation;
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSubstitutableMessage.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSubstitutableMessage.java?rev=432465&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSubstitutableMessage.java (added)
+++ webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleSubstitutableMessage.java Thu Aug 17 19:06:09 2006
@@ -0,0 +1,111 @@
+/*=============================================================================*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.dm.muws.events.impl;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.dm.muws.events.SubstitutableMessage;
+import org.apache.muse.ws.dm.muws.events.WefConstants;
+
+/**
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleSubstitutableMessage implements SubstitutableMessage
+{
+ private static final String[] _EMPTY_VALUES = new String[0];
+
+ private String _msgId = null;
+
+ private String _msgIdType = null;
+
+ private String[] _values = _EMPTY_VALUES;
+
+ public SimpleSubstitutableMessage()
+ {
+ //
+ // no action - allow users to create situations from scratch
+ //
+ }
+
+ public SimpleSubstitutableMessage(Element messageXML)
+ {
+ _msgId = messageXML.getAttribute(WefConstants.MSG_ID);
+ _msgIdType = messageXML.getAttribute(WefConstants.MSG_ID_TYPE);
+ _values = XmlUtils.getElementsText(messageXML, WefConstants.VALUE_QNAME);
+ }
+
+ public String getMessageId()
+ {
+ return _msgId;
+ }
+
+ public String getMessageIdType()
+ {
+ return _msgIdType;
+ }
+
+ public String[] getValues()
+ {
+ return _values;
+ }
+
+ public void setMessageId(String id)
+ {
+ _msgId = id;
+ }
+
+ public void setMessageIdType(String idType)
+ {
+ _msgIdType = idType;
+ }
+
+ public void setValues(String[] values)
+ {
+ if (values == null)
+ values = _EMPTY_VALUES;
+
+ _values = values;
+ }
+
+ public Element toXML()
+ {
+ return null;
+ }
+
+ public Element toXML(Document doc)
+ {
+ Element root = XmlUtils.createElement(doc, WefConstants.SUBSTITUTABLE_MSG_QNAME);
+
+ root.setAttribute(WefConstants.MSG_ID, getMessageId());
+ root.setAttribute(WefConstants.MSG_ID_TYPE, getMessageIdType());
+
+ String[] values = getValues();
+
+ for (int n = 0; n < values.length; ++n)
+ {
+ Element next = XmlUtils.createElement(doc, WefConstants.VALUE_QNAME, values[n]);
+ root.appendChild(next);
+ }
+
+ return root;
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleWefFactory.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleWefFactory.java?rev=432465&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleWefFactory.java (added)
+++ webservices/muse/trunk/modules/muse-wsdm-wef-impl/src/org/apache/muse/ws/dm/muws/events/impl/SimpleWefFactory.java Thu Aug 17 19:06:09 2006
@@ -0,0 +1,94 @@
+/*=============================================================================*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.dm.muws.events.impl;
+
+import org.apache.muse.util.xml.XmlSerializable;
+import org.apache.muse.ws.dm.muws.events.Component;
+import org.apache.muse.ws.dm.muws.events.ComponentAddress;
+import org.apache.muse.ws.dm.muws.events.ManagementEvent;
+import org.apache.muse.ws.dm.muws.events.Situation;
+import org.apache.muse.ws.dm.muws.events.SubstitutableMessage;
+import org.apache.muse.ws.dm.muws.events.WefFactory;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * SimpleWefFactory is the default implementation of the WefFactory component.
+ * The objects it creates are all instantiated from classes defined in this
+ * same package (org.apache.muse.ws.dm.muws.events.impl).
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SimpleWefFactory implements WefFactory
+{
+ public Component createComponent()
+ {
+ return new SimpleComponent();
+ }
+
+ public Component createComponent(Element componentXML)
+ {
+ return new SimpleComponent(componentXML, this);
+ }
+
+ public ComponentAddress createComponentAddress()
+ {
+ return new SimpleComponentAddress();
+ }
+
+ public ComponentAddress createComponentAddress(Element addressXML)
+ {
+ return new SimpleComponentAddress(addressXML);
+ }
+
+ public ComponentAddress createComponentAddress(XmlSerializable addressData)
+ {
+ return new SimpleComponentAddress(addressData.toXML());
+ }
+
+ public ManagementEvent createEvent()
+ {
+ return new SimpleManagementEvent();
+ }
+
+ public ManagementEvent createEvent(Element eventXML)
+ {
+ return new SimpleManagementEvent(eventXML, this);
+ }
+
+ public Situation createSituation()
+ {
+ return new SimpleSituation();
+ }
+
+ public Situation createSituation(Element situationXML)
+ {
+ return new SimpleSituation(situationXML);
+ }
+
+ public SubstitutableMessage createSubstitutableMessage()
+ {
+ return new SimpleSubstitutableMessage();
+ }
+
+ public SubstitutableMessage createSubstitutableMessage(Element messageXML)
+ {
+ return new SimpleSubstitutableMessage(messageXML);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org