You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2007/10/10 19:48:59 UTC
svn commit: r583555 - in /ode/trunk:
axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
axis2/src/main/wsdl/pmapi.wsdl
bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
Author: mriou
Date: Wed Oct 10 10:48:56 2007
New Revision: 583555
URL: http://svn.apache.org/viewvc?rev=583555&view=rev
Log:
Better faults from management API.
Modified:
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
ode/trunk/axis2/src/main/wsdl/pmapi.wsdl
ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java?rev=583555&r1=583554&r2=583555&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java Wed Oct 10 10:48:56 2007
@@ -21,6 +21,8 @@
import java.io.File;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -38,8 +40,7 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.*;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisOperation;
@@ -60,6 +61,8 @@
import org.apache.ode.bpel.pmapi.InstanceManagement;
import org.apache.ode.bpel.pmapi.ProcessInfoCustomizer;
import org.apache.ode.bpel.pmapi.ProcessManagement;
+import org.apache.ode.bpel.pmapi.ManagementException;
+import org.apache.ode.utils.Namespaces;
import org.apache.xmlbeans.XmlObject;
import org.w3c.dom.Node;
@@ -108,33 +111,38 @@
String methodName = msgContext.getAxisOperation().getName().getLocalPart();
try {
+ MessageContext outMsgContext = Utils.createOutMessageContext(msgContext);
+ outMsgContext.getOperationContext().addMessageContext(outMsgContext);
+
+ SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
+ outMsgContext.setEnvelope(envelope);
+
// Our services are defined in WSDL which requires operation names to be different
Method invokedMethod = findMethod(mgmtClass, methodName);
Object[] params = extractParams(invokedMethod, msgContext.getEnvelope().getBody().getFirstElement());
- Object result = invokedMethod.invoke(mgmtObject, params);
-
- if (hasResponse(msgContext.getAxisOperation())) {
- MessageContext outMsgContext = Utils.createOutMessageContext(msgContext);
- outMsgContext.getOperationContext().addMessageContext(outMsgContext);
-
- SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
- outMsgContext.setEnvelope(envelope);
-
- OMElement wrapper = soapFactory.createOMElement(new QName("http://www.apache.org/ode/pmapi", methodName+"Response"));
- OMElement parts = convertToOM(soapFactory, result);
- parts = stripNamespace(soapFactory, parts);
- wrapper.addChild(parts);
- envelope.getBody().addChild(wrapper);
-
- if (__log.isDebugEnabled()) {
- __log.debug("Reply mgmt for " + msgContext.getAxisService().getName() +
- "." + msgContext.getAxisOperation().getName());
- __log.debug("Reply mgmt message " + outMsgContext.getEnvelope());
+ Object result = null;
+ try {
+ result = invokedMethod.invoke(mgmtObject, params);
+ if (hasResponse(msgContext.getAxisOperation())) {
+ OMElement wrapper = soapFactory.createOMElement(new QName("http://www.apache.org/ode/pmapi", methodName+"Response"));
+ OMElement parts = convertToOM(soapFactory, result);
+ parts = stripNamespace(soapFactory, parts);
+ wrapper.addChild(parts);
+ envelope.getBody().addChild(wrapper);
+
+ if (__log.isDebugEnabled()) {
+ __log.debug("Reply mgmt for " + msgContext.getAxisService().getName() +
+ "." + msgContext.getAxisOperation().getName());
+ __log.debug("Reply mgmt message " + outMsgContext.getEnvelope());
+ }
}
- AxisEngine engine = new AxisEngine(
- msgContext.getOperationContext().getServiceContext().getConfigurationContext());
- engine.send(outMsgContext);
+ } catch (ManagementException e) {
+ // Building a nicely formatted fault
+ envelope.getBody().addFault(toSoapFault(e, soapFactory));
}
+ AxisEngine engine = new AxisEngine(
+ msgContext.getOperationContext().getServiceContext().getConfigurationContext());
+ engine.send(outMsgContext);
} catch (IllegalAccessException e) {
throw new OdeFault("Couldn't invoke method named " + methodName + " in management interface!", e);
} catch (InvocationTargetException e) {
@@ -237,6 +245,22 @@
case WSDLConstants.MEP_CONSTANT_ROBUST_OUT_ONLY: return true;
default: return false;
}
+ }
+
+ private static SOAPFault toSoapFault(ManagementException e, SOAPFactory soapFactory) {
+ SOAPFault fault = soapFactory.createSOAPFault();
+ SOAPFaultCode code = soapFactory.createSOAPFaultCode(fault);
+ code.setText(new QName(Namespaces.SOAP_ENV_NS, "Server"));
+ SOAPFaultReason reason = soapFactory.createSOAPFaultReason(fault);
+ reason.setText(e.toString());
+
+ OMElement detail = soapFactory.createOMElement(new QName(Namespaces.ODE_PMAPI, e.getClass().getSimpleName()));
+ StringWriter stack = new StringWriter();
+ e.printStackTrace(new PrintWriter(stack));
+ detail.setText(stack.toString());
+ SOAPFaultDetail soapDetail = soapFactory.createSOAPFaultDetail(fault);
+ soapDetail.addDetailEntry(detail);
+ return fault;
}
class ProcessMessageReceiver extends AbstractMessageReceiver {
Modified: ode/trunk/axis2/src/main/wsdl/pmapi.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/wsdl/pmapi.wsdl?rev=583555&r1=583554&r2=583555&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/wsdl/pmapi.wsdl (original)
+++ ode/trunk/axis2/src/main/wsdl/pmapi.wsdl Wed Oct 10 10:48:56 2007
@@ -46,6 +46,11 @@
<xsd:element name="iid" type="xsd:long"/>
</xsd:all>
</xsd:complexType>
+ <xsd:complexType name="faultType">
+ <xsd:all>
+ <xsd:element name="ManagementFault" type="xsd:string"/>
+ </xsd:all>
+ </xsd:complexType>
</xsd:schema>
</types>
@@ -221,47 +226,60 @@
<message name="recoverActivityOutput">
<part name="instance-info" type="typ:tInstanceInfo"/>
</message>
+ <message name="managementFault">
+ <part name="managementFault" type="typ:ManagementFault"/>
+ </message>
<portType name="ProcessManagementPortType">
<operation name="listProcesses">
<input message="tns:listProcessesInput"/>
<output message="tns:listProcessesOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="listAllProcesses">
<input message="tns:listAllProcessesInput"/>
<output message="tns:listAllProcessesOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="listProcessesCustom">
<input message="tns:listProcessesCustomInput"/>
<output message="tns:listProcessesCustomOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="getProcessInfo">
<input message="tns:getProcessInfoInput"/>
<output message="tns:getProcessInfoOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="getProcessInfoCustom">
<input message="tns:getProcessInfoCustomInput"/>
<output message="tns:getProcessInfoCustomOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="setProcessProperty">
<input message="tns:setProcessPropertyInput"/>
<output message="tns:setProcessPropertyOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="setProcessPropertyNode">
<input message="tns:setProcessPropertyNodeInput"/>
<output message="tns:setProcessPropertyNodeOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="getExtensibilityElements">
<input message="tns:getExtensibilityElementsInput"/>
<output message="tns:getExtensibilityElementsOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="activate">
<input message="tns:activateInput"/>
<output message="tns:activateOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="setRetired">
<input message="tns:setRetiredInput"/>
<output message="tns:setRetiredOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
</portType>
@@ -269,66 +287,82 @@
<operation name="listInstances">
<input message="tns:listInstancesInput"/>
<output message="tns:listInstancesOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="queryInstances">
<input message="tns:queryInstancesInput"/>
<output message="tns:queryInstancesOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="listAllInstances">
<input message="tns:listAllInstancesInput"/>
<output message="tns:listAllInstancesOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="listAllInstancesWithLimit">
<input message="tns:listAllInstancesWithLimitInput"/>
<output message="tns:listAllInstancesWithLimitOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="getInstanceInfo">
<input message="tns:getInstanceInfoInput"/>
<output message="tns:getInstanceInfoOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="getScopeInfo">
<input message="tns:getScopeInfoInput"/>
<output message="tns:getScopeInfoOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="getScopeInfoWithActivity">
<input message="tns:getScopeInfoWithActivityInput"/>
<output message="tns:getScopeInfoWithActivityOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="getVariableInfo">
<input message="tns:getVariableInfoInput"/>
<output message="tns:getVariableInfoOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="listEvents">
<input message="tns:listEventsInput"/>
<output message="tns:listEventsOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="getEventTimeline">
<input message="tns:getEventTimelineInput"/>
<output message="tns:getEventTimelineOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="suspend">
<input message="tns:suspendInput"/>
<output message="tns:suspendOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="resume">
<input message="tns:resumeInput"/>
<output message="tns:resumeOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="terminate">
<input message="tns:terminateInput"/>
<output message="tns:terminateOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="fault">
<input message="tns:faultInput"/>
<output message="tns:faultOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="delete">
<input message="tns:deleteInput"/>
<output message="tns:deleteOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
<operation name="recoverActivity">
<input message="tns:recoverActivityInput"/>
<output message="tns:recoverActivityOutput"/>
+ <fault name="ManagementFault" message="tns:ManagementFault"/>
</operation>
</portType>
@@ -342,6 +376,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="listAllProcesses">
<soap:operation soapAction="" style="rpc"/>
@@ -351,6 +388,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="listProcessesCustom">
<soap:operation soapAction="" style="rpc"/>
@@ -360,6 +400,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="getProcessInfo">
<soap:operation soapAction="" style="rpc"/>
@@ -369,6 +412,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="getProcessInfoCustom">
<soap:operation soapAction="" style="rpc"/>
@@ -378,6 +424,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="getExtensibilityElements">
<soap:operation soapAction="" style="rpc"/>
@@ -387,6 +436,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="setProcessProperty">
<soap:operation soapAction="" style="rpc"/>
@@ -396,6 +448,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="setProcessPropertyNode">
<soap:operation soapAction="" style="rpc"/>
@@ -405,6 +460,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="activate">
<soap:operation soapAction="" style="rpc"/>
@@ -414,6 +472,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="setRetired">
<soap:operation soapAction="" style="rpc"/>
@@ -423,6 +484,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
</binding>
@@ -436,6 +500,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="queryInstances">
<soap:operation soapAction="" style="rpc"/>
@@ -445,6 +512,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="listAllInstances">
<soap:operation soapAction="" style="rpc"/>
@@ -454,6 +524,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="listAllInstancesWithLimit">
<soap:operation soapAction="" style="rpc"/>
@@ -463,6 +536,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="getInstanceInfo">
<soap:operation soapAction="" style="rpc"/>
@@ -472,6 +548,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="getScopeInfo">
<soap:operation soapAction="" style="rpc"/>
@@ -481,6 +560,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="getScopeInfoWithActivity">
<soap:operation soapAction="" style="rpc"/>
@@ -490,6 +572,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="getVariableInfo">
<soap:operation soapAction="" style="rpc"/>
@@ -499,6 +584,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="listEvents">
<soap:operation soapAction="" style="rpc"/>
@@ -508,6 +596,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="getEventTimeline">
<soap:operation soapAction="" style="rpc"/>
@@ -517,6 +608,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="suspend">
<soap:operation soapAction="" style="rpc"/>
@@ -526,6 +620,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="resume">
<soap:operation soapAction="" style="rpc"/>
@@ -535,6 +632,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="terminate">
<soap:operation soapAction="" style="rpc"/>
@@ -544,6 +644,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="fault">
<soap:operation soapAction="" style="rpc"/>
@@ -553,6 +656,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="delete">
<soap:operation soapAction="" style="rpc"/>
@@ -562,6 +668,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
<operation name="recoverActivity">
<soap:operation soapAction="" style="rpc"/>
@@ -571,6 +680,9 @@
<output>
<soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
+ <fault>
+ <soap:fault name="ManagementFault" use="literal"/>
+ </fault>
</operation>
</binding>
Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java?rev=583555&r1=583554&r2=583555&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java Wed Oct 10 10:48:56 2007
@@ -518,7 +518,7 @@
BpelProcess process = _server.getBpelProcess(procid);
if (process == null)
- throw new InvalidRequestException("The process \"" + procid + "\" is available.");
+ throw new ProcessNotFoundException("The process \"" + procid + "\" does not exist.");
return process._debugger;
}