]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/main/java/org/argeo/slc/core/process/WebServiceSlcExecutionNotifier.java
Updates required by deploy
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / core / process / WebServiceSlcExecutionNotifier.java
index 09e37122d684e0443e5e3a00b22335320f463d00..9692344877fde1bdbecc46ce750bc858464acf53 100644 (file)
@@ -2,6 +2,7 @@ package org.argeo.slc.core.process;
 \r
 import java.util.List;\r
 \r
+import org.springframework.ws.client.WebServiceIOException;\r
 import org.springframework.ws.client.core.WebServiceTemplate;\r
 import org.springframework.ws.soap.client.SoapFaultClientException;\r
 \r
@@ -9,6 +10,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;\r
 \r
 import org.argeo.slc.msg.process.SlcExecutionRequest;\r
+import org.argeo.slc.msg.process.SlcExecutionStatusRequest;\r
 import org.argeo.slc.msg.process.SlcExecutionStepsRequest;\r
 import org.argeo.slc.ws.client.WebServiceUtils;\r
 \r
@@ -17,7 +19,12 @@ public class WebServiceSlcExecutionNotifier implements SlcExecutionNotifier {
 \r
        private Log log = LogFactory.getLog(getClass());\r
 \r
+       private Boolean cannotConnect = false;\r
+\r
        public void newExecution(SlcExecution slcExecution) {\r
+               if (cannotConnect)\r
+                       return;\r
+\r
                SlcExecutionRequest req = new SlcExecutionRequest();\r
                req.setSlcExecution(slcExecution);\r
                try {\r
@@ -27,10 +34,15 @@ public class WebServiceSlcExecutionNotifier implements SlcExecutionNotifier {
                                                + slcExecution.getUuid());\r
                } catch (SoapFaultClientException e) {\r
                        WebServiceUtils.manageSoapException(e);\r
+               } catch (WebServiceIOException e) {\r
+                       manageIoException(e);\r
                }\r
        }\r
 \r
        public void updateExecution(SlcExecution slcExecution) {\r
+               if (cannotConnect)\r
+                       return;\r
+\r
                SlcExecutionRequest req = new SlcExecutionRequest();\r
                req.setSlcExecution(slcExecution);\r
                try {\r
@@ -40,11 +52,35 @@ public class WebServiceSlcExecutionNotifier implements SlcExecutionNotifier {
                                                + slcExecution.getUuid());\r
                } catch (SoapFaultClientException e) {\r
                        WebServiceUtils.manageSoapException(e);\r
+               } catch (WebServiceIOException e) {\r
+                       manageIoException(e);\r
+               }\r
+       }\r
+\r
+       public void updateStatus(SlcExecution slcExecution, String oldStatus,\r
+                       String newStatus) {\r
+               if (cannotConnect)\r
+                       return;\r
+\r
+               SlcExecutionStatusRequest req = new SlcExecutionStatusRequest(\r
+                               slcExecution.getUuid(), newStatus);\r
+               try {\r
+                       WebServiceUtils.marshalSendAndReceive(template, req);\r
+                       if (log.isTraceEnabled())\r
+                               log.trace("Notified status update of slc execution "\r
+                                               + slcExecution.getUuid());\r
+               } catch (SoapFaultClientException e) {\r
+                       WebServiceUtils.manageSoapException(e);\r
+               } catch (WebServiceIOException e) {\r
+                       manageIoException(e);\r
                }\r
        }\r
 \r
        public void addSteps(SlcExecution slcExecution,\r
                        List<SlcExecutionStep> additionalSteps) {\r
+               if (cannotConnect)\r
+                       return;\r
+\r
                SlcExecutionStepsRequest req = new SlcExecutionStepsRequest();\r
                req.setSlcExecutionUuid(slcExecution.getUuid());\r
                req.setSteps(additionalSteps);\r
@@ -61,6 +97,8 @@ public class WebServiceSlcExecutionNotifier implements SlcExecutionNotifier {
                                                + slcExecution.getUuid());\r
                } catch (SoapFaultClientException e) {\r
                        WebServiceUtils.manageSoapException(e);\r
+               } catch (WebServiceIOException e) {\r
+                       manageIoException(e);\r
                }\r
        }\r
 \r
@@ -68,4 +106,12 @@ public class WebServiceSlcExecutionNotifier implements SlcExecutionNotifier {
                this.template = template;\r
        }\r
 \r
+       protected void manageIoException(WebServiceIOException e) {\r
+               if (!cannotConnect) {\r
+                       log.error("Cannot connect to " + template.getDefaultUri()\r
+                                       + ". Won't try again.", e);\r
+                       cannotConnect = true;\r
+               }\r
+       }\r
+\r
 }\r