Author: mriou
Date: Wed Oct 10 10:49:10 2007
New Revision: 583556
URL: http://svn.apache.org/viewvc?rev=583556&view=rev
Log:
Better faults from management API.
Modified:
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
ode/branches/APACHE_ODE_1.1/axis2/src/main/wsdl/pmapi.wsdl
ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java?rev=583556&r1=583555&r2=583556&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/service/ManagementService.java Wed Oct 10 10:49:10 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) {
@@ -227,6 +235,22 @@
parent.addChild(child);
}
return parent;
+ }
+
+ 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;
}
private static boolean hasResponse(AxisOperation op) {
Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/wsdl/pmapi.wsdl
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/wsdl/pmapi.wsdl?rev=583556&r1=583555&r2=583556&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/wsdl/pmapi.wsdl (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/wsdl/pmapi.wsdl Wed Oct 10 10:49:10 2007
@@ -46,6 +46,11 @@
+
+
+
+
+
@@ -221,47 +226,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -269,66 +287,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -342,6 +376,9 @@
+
+
+
@@ -351,6 +388,9 @@
+
+
+
@@ -360,6 +400,9 @@
+
+
+
@@ -369,6 +412,9 @@
+
+
+
@@ -378,6 +424,9 @@
+
+
+
@@ -387,6 +436,9 @@
+
+
+
@@ -396,6 +448,9 @@
+
+
+
@@ -405,6 +460,9 @@
+
+
+
@@ -414,6 +472,9 @@
+
+
+
@@ -423,6 +484,9 @@
+
+
+
@@ -436,6 +500,9 @@
+
+
+
@@ -445,6 +512,9 @@
+
+
+
@@ -454,6 +524,9 @@
+
+
+
@@ -463,6 +536,9 @@
+
+
+
@@ -472,6 +548,9 @@
+
+
+
@@ -481,6 +560,9 @@
+
+
+
@@ -490,6 +572,9 @@
+
+
+
@@ -499,6 +584,9 @@
+
+
+
@@ -508,6 +596,9 @@
+
+
+
@@ -517,6 +608,9 @@
+
+
+
@@ -526,6 +620,9 @@
+
+
+
@@ -535,6 +632,9 @@
+
+
+
@@ -544,6 +644,9 @@
+
+
+
@@ -553,6 +656,9 @@
+
+
+
@@ -562,6 +668,9 @@
+
+
+
@@ -571,6 +680,9 @@
+
+
+
Modified: ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java?rev=583556&r1=583555&r2=583556&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java (original)
+++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java Wed Oct 10 10:49:10 2007
@@ -518,7 +518,7 @@
BpelProcess process = _server._engine._activeProcesses.get(procid);
if (process == null)
- throw new InvalidRequestException("The process \"" + procid + "\" is available.");
+ throw new ProcessNotFoundException("The process \"" + procid + "\" does not exist.");
return process._debugger;
}