1 package org
.argeo
.slc
.web
.mvc
.process
;
3 import java
.io
.BufferedReader
;
5 import javax
.servlet
.http
.HttpServletRequest
;
6 import javax
.servlet
.http
.HttpServletResponse
;
8 import org
.apache
.commons
.logging
.Log
;
9 import org
.apache
.commons
.logging
.LogFactory
;
10 import org
.argeo
.slc
.msg
.MsgConstants
;
11 import org
.argeo
.slc
.process
.SlcExecution
;
12 import org
.argeo
.slc
.runtime
.SlcAgent
;
13 import org
.argeo
.slc
.runtime
.SlcAgentFactory
;
14 import org
.argeo
.slc
.services
.process
.SlcExecutionService
;
15 import org
.argeo
.slc
.web
.mvc
.AbstractServiceController
;
16 import org
.springframework
.oxm
.Unmarshaller
;
17 import org
.springframework
.web
.servlet
.ModelAndView
;
18 import org
.springframework
.xml
.transform
.StringSource
;
20 /** Send a new SlcExecution. */
21 public class NewSlcExecutionController
extends AbstractServiceController
{
22 private final static Log log
= LogFactory
23 .getLog(NewSlcExecutionController
.class);
25 private SlcAgentFactory agentFactory
;
26 private Unmarshaller unmarshaller
;
27 private SlcExecutionService slcExecutionService
;
30 protected void handleServiceRequest(HttpServletRequest request
,
31 HttpServletResponse response
, ModelAndView modelAndView
)
34 if (log
.isTraceEnabled()) {
35 log
.debug("Content-Type: " + request
.getContentType());
36 log
.debug("Content-Length: " + request
.getContentLength());
39 String agentId
= request
40 .getParameter(MsgConstants
.PROPERTY_SLC_AGENT_ID
);
42 String answer
= request
.getParameter("body");
44 // lets read the message body instead
45 BufferedReader reader
= request
.getReader();
46 StringBuffer buffer
= new StringBuffer();
48 while (((line
= reader
.readLine()) != null)) {
51 answer
= buffer
.toString();
54 if (log
.isTraceEnabled())
55 log
.debug("Received message:\n" + answer
);
57 StringSource source
= new StringSource(answer
);
58 SlcExecution slcExecution
= (SlcExecution
) unmarshaller
61 slcExecution
.setStatus(SlcExecution
.STATUS_SCHEDULED
);
62 slcExecutionService
.newExecution(slcExecution
);
64 SlcAgent agent
= agentFactory
.getAgent(agentId
);
65 agent
.runSlcExecution(slcExecution
);
68 public void setUnmarshaller(Unmarshaller unmarshaller
) {
69 this.unmarshaller
= unmarshaller
;
72 public void setAgentFactory(SlcAgentFactory agentFactory
) {
73 this.agentFactory
= agentFactory
;
76 public void setSlcExecutionService(SlcExecutionService slcExecutionService
) {
77 this.slcExecutionService
= slcExecutionService
;