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