Return-Path: Delivered-To: apmail-ode-commits-archive@www.apache.org Received: (qmail 38153 invoked from network); 10 Oct 2007 18:02:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Oct 2007 18:02:53 -0000 Received: (qmail 90372 invoked by uid 500); 10 Oct 2007 17:49:39 -0000 Delivered-To: apmail-ode-commits-archive@ode.apache.org Received: (qmail 90359 invoked by uid 500); 10 Oct 2007 17:49:39 -0000 Mailing-List: contact commits-help@ode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ode.apache.org Delivered-To: mailing list commits@ode.apache.org Received: (qmail 90350 invoked by uid 99); 10 Oct 2007 17:49:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Oct 2007 10:49:39 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Oct 2007 17:49:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1E5731A9832; Wed, 10 Oct 2007 10:49:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Wed, 10 Oct 2007 17:48:59 -0000 To: commits@ode.apache.org From: mriou@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071010174900.1E5731A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ + + + + + @@ -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/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; }