1 package org
.argeo
.slc
.core
.process
;
5 import org
.springframework
.ws
.client
.WebServiceIOException
;
6 import org
.springframework
.ws
.client
.core
.WebServiceTemplate
;
7 import org
.springframework
.ws
.soap
.client
.SoapFaultClientException
;
9 import org
.apache
.commons
.logging
.Log
;
10 import org
.apache
.commons
.logging
.LogFactory
;
12 import org
.argeo
.slc
.msg
.process
.SlcExecutionRequest
;
13 import org
.argeo
.slc
.msg
.process
.SlcExecutionStatusRequest
;
14 import org
.argeo
.slc
.msg
.process
.SlcExecutionStepsRequest
;
15 import org
.argeo
.slc
.ws
.client
.WebServiceUtils
;
17 public class WebServiceSlcExecutionNotifier
implements SlcExecutionNotifier
{
18 private WebServiceTemplate template
;
20 private Log log
= LogFactory
.getLog(getClass());
22 private Boolean cannotConnect
= false;
24 public void newExecution(SlcExecution slcExecution
) {
28 SlcExecutionRequest req
= new SlcExecutionRequest();
29 req
.setSlcExecution(slcExecution
);
31 WebServiceUtils
.marshalSendAndReceive(template
, req
);
32 if (log
.isTraceEnabled())
33 log
.trace("Notified creation of slc execution "
34 + slcExecution
.getUuid());
35 } catch (SoapFaultClientException e
) {
36 WebServiceUtils
.manageSoapException(e
);
37 } catch (WebServiceIOException e
) {
42 public void updateExecution(SlcExecution slcExecution
) {
46 SlcExecutionRequest req
= new SlcExecutionRequest();
47 req
.setSlcExecution(slcExecution
);
49 WebServiceUtils
.marshalSendAndReceive(template
, req
);
50 if (log
.isTraceEnabled())
51 log
.trace("Notified update of slc execution "
52 + slcExecution
.getUuid());
53 } catch (SoapFaultClientException e
) {
54 WebServiceUtils
.manageSoapException(e
);
55 } catch (WebServiceIOException e
) {
60 public void updateStatus(SlcExecution slcExecution
, String oldStatus
,
65 SlcExecutionStatusRequest req
= new SlcExecutionStatusRequest(
66 slcExecution
.getUuid(), newStatus
);
68 WebServiceUtils
.marshalSendAndReceive(template
, req
);
69 if (log
.isTraceEnabled())
70 log
.trace("Notified status update of slc execution "
71 + slcExecution
.getUuid());
72 } catch (SoapFaultClientException e
) {
73 WebServiceUtils
.manageSoapException(e
);
74 } catch (WebServiceIOException e
) {
79 public void addSteps(SlcExecution slcExecution
,
80 List
<SlcExecutionStep
> additionalSteps
) {
84 SlcExecutionStepsRequest req
= new SlcExecutionStepsRequest();
85 req
.setSlcExecutionUuid(slcExecution
.getUuid());
86 req
.setSteps(additionalSteps
);
87 if (log
.isTraceEnabled()) {
88 for (SlcExecutionStep step
: additionalSteps
) {
89 log
.trace("Step " + step
.getUuid() + ": " + step
.logAsString());
94 WebServiceUtils
.marshalSendAndReceive(template
, req
);
95 if (log
.isTraceEnabled())
96 log
.trace("Added steps to slc execution "
97 + slcExecution
.getUuid());
98 } catch (SoapFaultClientException e
) {
99 WebServiceUtils
.manageSoapException(e
);
100 } catch (WebServiceIOException e
) {
101 manageIoException(e
);
105 public void setTemplate(WebServiceTemplate template
) {
106 this.template
= template
;
109 protected void manageIoException(WebServiceIOException e
) {
110 if (!cannotConnect
) {
111 log
.error("Cannot connect to " + template
.getDefaultUri()
112 + ". Won't try again.", e
);
113 cannotConnect
= true;