You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by bo...@apache.org on 2007/01/24 01:52:13 UTC
svn commit: r499199 - in /incubator/ode/trunk/axis2/src:
main/java/org/apache/ode/axis2/service/ main/wsdl/
test/java/org/apache/ode/axis2/management/
Author: boisvert
Date: Tue Jan 23 16:52:12 2007
New Revision: 499199
URL: http://svn.apache.org/viewvc?view=rev&rev=499199
Log:
Update deployment service and associated test case after versioning changes
Modified:
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java
incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java
Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java?view=diff&rev=499199&r1=499198&r2=499199
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/service/DeploymentWebService.java Tue Jan 23 16:52:12 2007
@@ -19,6 +19,25 @@
package org.apache.ode.axis2.service;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.activation.DataHandler;
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMText;
@@ -37,21 +56,10 @@
import org.apache.ode.axis2.hooks.ODEAxisService;
import org.apache.ode.axis2.util.OMUtils;
import org.apache.ode.bpel.iapi.BpelServer;
+import org.apache.ode.bpel.iapi.ProcessConf;
import org.apache.ode.bpel.iapi.ProcessStore;
import org.apache.ode.utils.fs.FileUtils;
-import javax.activation.DataHandler;
-import javax.wsdl.Definition;
-import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-import java.io.*;
-import java.util.Collection;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
/**
* Axis wrapper for process deployment.
*/
@@ -59,16 +67,21 @@
private static final Log __log = LogFactory.getLog(DeploymentWebService.class);
+ private final OMNamespace _pmapi;
+
private File _deployPath;
private DeploymentPoller _poller;
private ProcessStore _store;
- private BpelServer _server;
+
+
+ public DeploymentWebService() {
+ _pmapi = OMAbstractFactory.getOMFactory().createOMNamespace("http://www.apache.org/ode/pmapi","pmapi");
+ }
public void enableService(AxisConfiguration axisConfig, BpelServer server, ProcessStore store,
DeploymentPoller poller, String rootpath, String workPath) {
_deployPath = new File(workPath, "processes");
_store = store;
- _server = server;
Definition def;
try {
@@ -93,7 +106,6 @@
public void receive(MessageContext messageContext) throws AxisFault {
String operation = messageContext.getAxisOperation().getName().getLocalPart();
SOAPFactory factory = getSOAPFactory(messageContext);
- OMNamespace depns = factory.createOMNamespace("http://www.apache.org/ode/pmapi","deployapi");
boolean unknown = false;
try {
@@ -129,6 +141,7 @@
"descriptor in its root directory named deploy.xml, aborting.");
Collection<QName> deployed = _store.deploy(dest);
+
File deployedMarker = new File(_deployPath, dest.getName() + ".deployed");
deployedMarker.createNewFile();
@@ -137,8 +150,19 @@
_poller.markAsDeployed(dest);
__log.info("Deployment of artifact " + dest.getName() + " successful.");
- OMElement response = factory.createOMElement("response", depns);
- response.setText("true");
+ OMElement response = factory.createOMElement("response", null);
+
+ if (__log.isDebugEnabled()) __log.debug("Deployed package: "+dest.getName());
+ OMElement d = factory.createOMElement("name", null);
+ d.setText(dest.getName());
+ response.addChild(d);
+
+ for (QName pid : deployed) {
+ if (__log.isDebugEnabled()) __log.debug("Deployed PID: "+pid);
+ d = factory.createOMElement("id", null);
+ d.setText(pid);
+ response.addChild(d);
+ }
sendResponse(factory, messageContext, "deployResponse", response);
} finally {
_poller.release();
@@ -146,10 +170,10 @@
} else if (operation.equals("undeploy")) {
OMElement part = messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
- String elmtStr = part.getText();
- File deploymentDir = new File(_deployPath, elmtStr);
+ String pkg = part.getText();
+ File deploymentDir = new File(_deployPath, pkg);
if (!deploymentDir.exists())
- throw new AxisFault("Couldn't find deployment package " + elmtStr + " in directory " + _deployPath);
+ throw new AxisFault("Couldn't find deployment package " + pkg + " in directory " + _deployPath);
try {
// We're going to create a directory under the deployment root and put
@@ -159,11 +183,11 @@
Collection<QName> undeployed = _store.undeploy(deploymentDir);
- File deployedMarker = new File(_deployPath, elmtStr + ".deployed");
+ File deployedMarker = new File(_deployPath, pkg + ".deployed");
deployedMarker.delete();
- FileUtils.deepDelete(new File(_deployPath, elmtStr));
+ FileUtils.deepDelete(new File(_deployPath, pkg));
- OMElement response = factory.createOMElement("response", depns);
+ OMElement response = factory.createOMElement("response", null);
response.setText("" + (undeployed.size() > 0));
sendResponse(factory, messageContext, "undeployResponse", response);
_poller.markAsUndeployed(deploymentDir);
@@ -172,9 +196,9 @@
}
} else if (operation.equals("listDeployedPackages")) {
Collection<String> packageNames = _store.getPackages();
- OMElement response = factory.createOMElement("deployedPackages", depns);
+ OMElement response = factory.createOMElement("deployedPackages", null);
for (String name : packageNames) {
- OMElement nameElmt = factory.createOMElement("name", depns);
+ OMElement nameElmt = factory.createOMElement("name", null);
nameElmt.setText(name);
response.addChild(nameElmt);
}
@@ -182,17 +206,21 @@
} else if (operation.equals("listProcesses")) {
OMElement namePart = messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
List<QName> processIds = _store.listProcesses(namePart.getText());
- OMElement response = factory.createOMElement("processIds", depns);
+ OMElement response = factory.createOMElement("processIds", null);
for (QName qname : processIds) {
- OMElement nameElmt = factory.createOMElement("id", depns);
+ OMElement nameElmt = factory.createOMElement("id", null);
nameElmt.setText(qname);
response.addChild(nameElmt);
}
sendResponse(factory, messageContext, "listProcessResponse", response);
} else if (operation.equals("getProcessPackage")) {
OMElement qnamePart = messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
+ ProcessConf process = _store.getProcessConfiguration(OMUtils.getTextAsQName(qnamePart));
+ if (process == null) {
+ throw new AxisFault("Could not find process: " + qnamePart.getTextAsQName());
+ }
String packageName = _store.getProcessConfiguration(OMUtils.getTextAsQName(qnamePart)).getPackage();
- OMElement response = factory.createOMElement("packageName", depns);
+ OMElement response = factory.createOMElement("packageName", null);
response.setText(packageName);
sendResponse(factory, messageContext, "getProcessPackageResponse", response);
} else unknown = true;
@@ -200,6 +228,7 @@
// Trying to extract a meaningful message
Throwable source = t;
while (source.getCause() != null && source.getCause() != source) source = source.getCause();
+ __log.warn("Invocation of operation " + operation + " failed", t);
throw new AxisFault("Invocation of operation " + operation + " failed: " + source.toString(), t);
}
if (unknown) throw new AxisFault("Unknown operation: '"
@@ -243,8 +272,7 @@
SOAPEnvelope envelope = factory.getDefaultEnvelope();
outMsgContext.setEnvelope(envelope);
- OMNamespace depns = factory.createOMNamespace("http://www.apache.org/ode/pmapi","deployapi");
- OMElement responseOp = factory.createOMElement(op, depns);
+ OMElement responseOp = factory.createOMElement(op, _pmapi);
responseOp.addChild(response);
envelope.getBody().addChild(response);
AxisEngine engine = new AxisEngine(
Modified: incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl?view=diff&rev=499199&r1=499198&r2=499199
==============================================================================
--- incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl (original)
+++ incubator/ode/trunk/axis2/src/main/wsdl/deploy.wsdl Tue Jan 23 16:52:12 2007
@@ -43,6 +43,12 @@
<xsd:element name="id" type="xsd:QName"/>
</xsd:all>
</xsd:complexType>
+ <xsd:complexType name="deployUnit">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="id" type="xsd:QName" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
</types>
<message name="deployInput">
@@ -50,10 +56,10 @@
<part name="package" type="tns:package"/>
</message>
<message name="deployOutput">
- <part name="response" type="xsd:boolean"/>
+ <part name="response" type="tns:deployUnit"/>
</message>
<message name="undeployInput">
- <part name="processName" type="xsd:QName"/>
+ <part name="packageName" type="xsd:QName"/>
</message>
<message name="undeployOutput">
<part name="response" type="xsd:boolean"/>
@@ -103,46 +109,46 @@
<operation name="deploy">
<soap:operation soapAction="" style="rpc"/>
<input>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</input>
<output>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
</operation>
<operation name="undeploy">
<soap:operation soapAction="" style="rpc"/>
<input>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</input>
<output>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
</operation>
<operation name="listDeployedPackages">
<soap:operation soapAction="" style="rpc"/>
<input>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</input>
<output>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
</operation>
<operation name="listProcesses">
<soap:operation soapAction="" style="rpc"/>
<input>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</input>
<output>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
</operation>
<operation name="getProcessPackage">
<soap:operation soapAction="" style="rpc"/>
<input>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</input>
<output>
- <soap:body namespace="http://www.apache.org/ode/pmapi" use="encoded"/>
+ <soap:body namespace="http://www.apache.org/ode/pmapi" use="literal"/>
</output>
</operation>
</binding>
Modified: incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java?view=diff&rev=499199&r1=499198&r2=499199
==============================================================================
--- incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java (original)
+++ incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/DeploymentTest.java Tue Jan 23 16:52:12 2007
@@ -19,7 +19,15 @@
package org.apache.ode.axis2.management;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
import junit.framework.TestCase;
+
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
@@ -30,53 +38,72 @@
import org.apache.ode.axis2.service.ServiceClientUtil;
import org.apache.ode.utils.Namespaces;
-import javax.xml.namespace.QName;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-
public class DeploymentTest extends TestCase {
private OMFactory _factory;
private ServiceClientUtil _client;
+ private ArrayList<QName> _deployed = new ArrayList<QName>();
+ private String _package;
+
public void testDeployUndeploy() throws Exception {
// Setup and tear down are doing ost of the job here, just checking in the middle
// Check deployment
- OMElement listRoot = _client.buildMessage("listProcesses", new String[] {"filter", "orderKeys"},
- new String[] {"name=DynPartnerMain", ""});
+ OMElement listRoot = _client.buildMessage("listProcesses", new String[0], new String[0]);
OMElement result = sendToPM(listRoot);
- // Ensures that there's only 2 process-info string (ending and closing tags) and hence only one process
- assert(result.toString().split("process-info").length == 3);
+
+ // look for DynPartnerMain-xxx
+ listRoot = _client.buildMessage("listProcesses", new String[] {"filter", "orderKeys"},
+ new String[] {"name="+_deployed.get(0).getLocalPart(), ""});
+ result = sendToPM(listRoot);
+
+ assertEquals("process-info-list", result.getLocalName());
+ OMElement child = result.getFirstElement();
+ assertNotNull("Missing deployed process", child);
+ assertEquals("process-info", child.getLocalName());
+ OMElement pid = child.getFirstElement();
+ assertEquals(_deployed.get(0).toString(), pid.getTextAsQName().toString());
+
+ // look for DynPartnerResponder-xxx
listRoot = _client.buildMessage("listProcesses", new String[] {"filter", "orderKeys"},
- new String[] {"name=DynPartnerResponder", ""});
+ new String[] {"name="+_deployed.get(1).getLocalPart(), ""});
result = sendToPM(listRoot);
- assert(result.toString().split("process-info").length == 3);
+ assertEquals("process-info-list", result.getLocalName());
+ child = result.getFirstElement();
+ assertNotNull("Missing deployed process", child);
+ assertEquals("process-info", child.getLocalName());
+ assertEquals("process-info", child.getLocalName());
+ pid = child.getFirstElement();
+ assertEquals(_deployed.get(1).toString(), pid.getTextAsQName().toString());
}
public void testListDeployedPackages() throws Exception {
OMElement root = _client.buildMessage("listDeployedPackages", new String[] {}, new String[] {});
OMElement result = sendToDeployment(root);
- assert(result.getFirstElement().getFirstElement().getText().equals("DynPartner"));
+ assertEquals(_package, result.getFirstElement().getText());
}
public void testListProcesses() throws Exception {
OMElement root = _client.buildMessage("listProcesses", new String[] {"packagesNames"},
- new String[] {"DynPartner"});
+ new String[] {_package});
OMElement result = sendToDeployment(root);
- assert(result.toString().indexOf("http://ode/bpel/unit-test")>=0);
- assert(result.toString().indexOf("DynPartnerMain")>=0);
- assert(result.toString().indexOf("http://ode/bpel/responder")>=0);
- assert(result.toString().indexOf("DynPartnerResponder")>=0);
- System.out.println(result);
+ assertTrue(result.toString().indexOf("http://ode/bpel/unit-test")>=0);
+ assertTrue(result.toString().indexOf("DynPartnerMain")>=0);
+ assertTrue(result.toString().indexOf("http://ode/bpel/responder")>=0);
+ assertTrue(result.toString().indexOf("DynPartnerResponder")>=0);
}
public void testGetProcessPackage() throws Exception {
OMElement root = _client.buildMessage("getProcessPackage", new String[] {"processId"},
- new Object[] { new QName("http://ode/bpel/unit-test", "DynPartnerMain") });
+ new Object[] { _deployed.get(0) } );
OMElement result = sendToDeployment(root);
- assert(result.getText().equals("DynPartner"));
- System.out.println(result);
+ assertEquals(_package, result.getText());
+
+ OMElement root2 = _client.buildMessage("getProcessPackage", new String[] {"processId"},
+ new Object[] { _deployed.get(1) } );
+ OMElement result2 = sendToDeployment(root2);
+ assertEquals(_package, result2.getText());
}
protected void setUp() throws Exception {
@@ -95,8 +122,10 @@
// Add the zip to deploy
InputStream is = this.getClass().getClassLoader().getResourceAsStream("DynPartner.zip");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- for (int b = is.read(); b >= 0; b = is.read()) {
- outputStream.write((byte) b);
+ byte[] buffer = new byte[4096];
+ int len;
+ while((len = is.read(buffer)) >= 0) {
+ outputStream.write(buffer, 0, len);
}
String base64Enc = Base64.encode(outputStream.toByteArray());
OMText zipContent = _factory.createOMText(base64Enc, "application/zip", true);
@@ -106,15 +135,30 @@
zipElmt.addChild(zipContent);
// Deploy
- sendToDeployment(root);
+ OMElement result = sendToDeployment(root);
+
+ _deployed.clear();
+ _package = null;
+ Iterator iter = result.getChildElements();
+ while (iter.hasNext()) {
+ OMElement e = (OMElement) iter.next();
+ if (e.getLocalName().equals("name")) {
+ _package = e.getText();
+ }
+ if (e.getLocalName().equals("id")) {
+ _deployed.add(e.getTextAsQName());
+ }
+ }
+ assertNotNull(_package);
+ assertEquals(2, _deployed.size());
}
protected void tearDown() throws Exception {
// Prepare undeploy message
OMNamespace depns = _factory.createOMNamespace(Namespaces.ODE_PMAPI, "deployapi");
OMElement root = _factory.createOMElement("undeploy", depns);
- OMElement part = _factory.createOMElement("processName", null);
- part.setText("DynPartner");
+ OMElement part = _factory.createOMElement("packageName", null);
+ part.setText(_package);
root.addChild(part);
// Undeploy
@@ -123,7 +167,7 @@
OMElement listRoot = _client.buildMessage("listProcesses", new String[] {"filter", "orderKeys"},
new String[] {"name=DynPartnerMain", ""});
OMElement result = sendToPM(listRoot);
- assert(result.toString().indexOf("process-info") < 0);
+ assertNull("Leftover process after undeployment", result.getFirstElement());
}
Modified: incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java?view=diff&rev=499199&r1=499198&r2=499199
==============================================================================
--- incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java (original)
+++ incubator/ode/trunk/axis2/src/test/java/org/apache/ode/axis2/management/ProcessManagementTest.java Tue Jan 23 16:52:12 2007
@@ -128,12 +128,12 @@
_client = new ServiceClientUtil();
// Use the factory to create three elements
- OMNamespace depns = _factory.createOMNamespace(Namespaces.ODE_PMAPI, "deployapi");
- OMElement root = _factory.createOMElement("deploy", null);
- OMElement namePart = _factory.createOMElement("name", depns);
+ OMNamespace pmapi = _factory.createOMNamespace("http://www.apache.org/ode/pmapi", "pmapi");
+ OMElement root = _factory.createOMElement("deploy", pmapi); // qualified operation name
+ OMElement namePart = _factory.createOMElement("name", null);
namePart.setText("DynPartner");
- OMElement zipPart = _factory.createOMElement("package", depns);
- OMElement zipElmt = _factory.createOMElement("zip", depns);
+ OMElement zipPart = _factory.createOMElement("package", null);
+ OMElement zipElmt = _factory.createOMElement("zip", null);
// Add the zip to deploy
InputStream is = this.getClass().getClassLoader().getResourceAsStream("DynPartner.zip");
@@ -154,9 +154,9 @@
protected void tearDown() throws Exception {
// Prepare undeploy message
- OMNamespace depns = _factory.createOMNamespace(Namespaces.ODE_PMAPI, "deployapi");
- OMElement root = _factory.createOMElement("undeploy", depns);
- OMElement part = _factory.createOMElement("processName", null);
+ OMNamespace pmapi = _factory.createOMNamespace("http://www.apache.org/ode/pmapi", "pmapi");
+ OMElement root = _factory.createOMElement("undeploy", pmapi); // qualified operation name
+ OMElement part = _factory.createOMElement("processName", pmapi);
part.setText("DynPartner");
root.addChild(part);