-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.groovy
52 lines (44 loc) · 1.71 KB
/
delete.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import eu.rssw.pdo.ws.Pdo
import eu.rssw.pdo.ws.PdoAPI
import eu.rssw.pdo.ws.Product
import eu.rssw.pdo.ws.Version
import eu.rssw.pdo.ws.StartupMode
import eu.rssw.pdo.ws.FileUploadParameter;
import eu.rssw.pdo.ws.MsiInstallerProperty;
import eu.rssw.pdo.ws.MsiInstallerPropertyArray;
import javax.activation.DataHandler;
import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.soap.SOAPBinding;
import java.net.URL;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
Pdo padeo = new Pdo(new URL(args[0] + '/ws/padeo?wsdl'))
PdoAPI srv = padeo.getPdoPort()
Binding b = ((BindingProvider) srv).getBinding();
((SOAPBinding) b).setMTOMEnabled(true);
// 30 seconds for connection timeout, and no timeout for receive operation
HTTPConduit http = (HTTPConduit) ClientProxy.getClient(srv).getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(30000);
httpClientPolicy.setReceiveTimeout(0);
httpClientPolicy.setAllowChunking(false)
http.setClient(httpClientPolicy);
Product p = null;
try {
println "Looking for product..."
p = srv.getProduct(args[1], args[2])
} catch (eu.rssw.pdo.ws.RecordNotFoundException_Exception caught) {
println "Not found, exiting..."
return 1
}
Version activeVersion = p.versions.last()
println "Last version number : " + activeVersion.versionNumber
for (Version v : p.getVersions()) {
if (v.versionNumber < activeVersion.versionNumber - args[3].toInteger()) {
println "Deleting version " + v.versionNumber
srv.deleteVersion(v.id)
}
}
println "Done !"