]> git.argeo.org Git - gpl/argeo-slc.git/blob - core/process/WebServiceSlcExecutionNotifier.java
Prepare next development cycle
[gpl/argeo-slc.git] / core / process / WebServiceSlcExecutionNotifier.java
1 package org.argeo.slc.core.process;
2
3 import java.util.List;
4
5 import org.springframework.ws.client.core.WebServiceTemplate;
6 import org.springframework.ws.soap.client.SoapFaultClientException;
7
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10
11 import org.argeo.slc.msg.process.SlcExecutionRequest;
12 import org.argeo.slc.msg.process.SlcExecutionStepsRequest;
13 import org.argeo.slc.ws.client.WebServiceUtils;
14
15 public class WebServiceSlcExecutionNotifier implements SlcExecutionNotifier {
16 private WebServiceTemplate template;
17
18 private Log log = LogFactory.getLog(getClass());
19
20 public void newExecution(SlcExecution slcExecution) {
21 SlcExecutionRequest req = new SlcExecutionRequest();
22 req.setSlcExecution(slcExecution);
23 try {
24 WebServiceUtils.marshalSendAndReceive(template, req);
25 if (log.isTraceEnabled())
26 log.trace("Notified creation of slc execution "
27 + slcExecution.getUuid());
28 } catch (SoapFaultClientException e) {
29 WebServiceUtils.manageSoapException(e);
30 }
31 }
32
33 public void updateExecution(SlcExecution slcExecution) {
34 SlcExecutionRequest req = new SlcExecutionRequest();
35 req.setSlcExecution(slcExecution);
36 try {
37 WebServiceUtils.marshalSendAndReceive(template, req);
38 if (log.isTraceEnabled())
39 log.trace("Notified update of slc execution "
40 + slcExecution.getUuid());
41 } catch (SoapFaultClientException e) {
42 WebServiceUtils.manageSoapException(e);
43 }
44 }
45
46 public void addSteps(SlcExecution slcExecution,
47 List<SlcExecutionStep> additionalSteps) {
48 SlcExecutionStepsRequest req = new SlcExecutionStepsRequest();
49 req.setSlcExecutionUuid(slcExecution.getUuid());
50 req.setSteps(additionalSteps);
51 if (log.isTraceEnabled()) {
52 for (SlcExecutionStep step : additionalSteps) {
53 log.trace("Step " + step.getUuid() + ": " + step.logAsString());
54 }
55 }
56
57 try {
58 WebServiceUtils.marshalSendAndReceive(template, req);
59 if (log.isTraceEnabled())
60 log.trace("Added steps to slc execution "
61 + slcExecution.getUuid());
62 } catch (SoapFaultClientException e) {
63 WebServiceUtils.manageSoapException(e);
64 }
65 }
66
67 public void setTemplate(WebServiceTemplate template) {
68 this.template = template;
69 }
70
71 }