]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/mvc/process/NewSlcExecutionController.java
Notify directly the new execution
[gpl/argeo-slc.git] / runtime / org.argeo.slc.server / src / main / java / org / argeo / slc / web / mvc / process / NewSlcExecutionController.java
index 682c2b906d0a7b8148223ad6fbf476a37b0b3105..2e19764e6bb1f38f9c5410c697f19f95fd89e8c2 100644 (file)
@@ -11,6 +11,7 @@ import org.argeo.slc.msg.MsgConstants;
 import org.argeo.slc.process.SlcExecution;\r
 import org.argeo.slc.runtime.SlcAgent;\r
 import org.argeo.slc.runtime.SlcAgentFactory;\r
+import org.argeo.slc.services.process.SlcExecutionService;\r
 import org.argeo.slc.web.mvc.AbstractServiceController;\r
 import org.springframework.oxm.Unmarshaller;\r
 import org.springframework.web.servlet.ModelAndView;\r
@@ -23,15 +24,16 @@ public class NewSlcExecutionController extends AbstractServiceController {
 \r
        private SlcAgentFactory agentFactory;\r
        private Unmarshaller unmarshaller;\r
+       private SlcExecutionService slcExecutionService;\r
 \r
        @Override\r
        protected void handleServiceRequest(HttpServletRequest request,\r
                        HttpServletResponse response, ModelAndView modelAndView)\r
                        throws Exception {\r
-               \r
-               if(log.isDebugEnabled()){\r
-                       log.debug("Content-Type: "+request.getContentType());\r
-                       log.debug("Content-Length: "+request.getContentLength());\r
+\r
+               if (log.isTraceEnabled()) {\r
+                       log.debug("Content-Type: " + request.getContentType());\r
+                       log.debug("Content-Length: " + request.getContentLength());\r
                }\r
 \r
                String agentId = request\r
@@ -43,20 +45,22 @@ public class NewSlcExecutionController extends AbstractServiceController {
                        BufferedReader reader = request.getReader();\r
                        StringBuffer buffer = new StringBuffer();\r
                        String line = null;\r
-                       while (((line = reader.readLine())!=null)) {\r
+                       while (((line = reader.readLine()) != null)) {\r
                                buffer.append(line);\r
-                               buffer.append("\n");\r
                        }\r
                        answer = buffer.toString();\r
                }\r
 \r
-               if (log.isDebugEnabled())\r
+               if (log.isTraceEnabled())\r
                        log.debug("Received message:\n" + answer);\r
 \r
                StringSource source = new StringSource(answer);\r
                SlcExecution slcExecution = (SlcExecution) unmarshaller\r
                                .unmarshal(source);\r
 \r
+               slcExecution.setStatus(SlcExecution.STATUS_SCHEDULED);\r
+               slcExecutionService.newExecution(slcExecution);\r
+\r
                SlcAgent agent = agentFactory.getAgent(agentId);\r
                agent.runSlcExecution(slcExecution);\r
        }\r
@@ -69,4 +73,8 @@ public class NewSlcExecutionController extends AbstractServiceController {
                this.agentFactory = agentFactory;\r
        }\r
 \r
+       public void setSlcExecutionService(SlcExecutionService slcExecutionService) {\r
+               this.slcExecutionService = slcExecutionService;\r
+       }\r
+\r
 }\r