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
.web
.mvc
.AbstractServiceController
;
15 import org
.springframework
.oxm
.Unmarshaller
;
16 import org
.springframework
.web
.servlet
.ModelAndView
;
17 import org
.springframework
.xml
.transform
.StringSource
;
19 /** Send a new SlcExecution. */
20 public class NewSlcExecutionController
extends AbstractServiceController
{
21 private final static Log log
= LogFactory
22 .getLog(NewSlcExecutionController
.class);
24 private SlcAgentFactory agentFactory
;
25 private Unmarshaller unmarshaller
;
28 protected void handleServiceRequest(HttpServletRequest request
,
29 HttpServletResponse response
, ModelAndView modelAndView
)
32 if(log
.isDebugEnabled()){
33 log
.debug("Content-Type: "+request
.getContentType());
34 log
.debug("Content-Length: "+request
.getContentLength());
37 String agentId
= request
38 .getParameter(MsgConstants
.PROPERTY_SLC_AGENT_ID
);
40 String answer
= request
.getParameter("body");
42 // lets read the message body instead
43 BufferedReader reader
= request
.getReader();
44 StringBuffer buffer
= new StringBuffer();
46 while (((line
= reader
.readLine())!=null)) {
50 answer
= buffer
.toString();
53 if (log
.isDebugEnabled())
54 log
.debug("Received message:\n" + answer
);
56 StringSource source
= new StringSource(answer
);
57 SlcExecution slcExecution
= (SlcExecution
) unmarshaller
60 SlcAgent agent
= agentFactory
.getAgent(agentId
);
61 agent
.runSlcExecution(slcExecution
);
64 public void setUnmarshaller(Unmarshaller unmarshaller
) {
65 this.unmarshaller
= unmarshaller
;
68 public void setAgentFactory(SlcAgentFactory agentFactory
) {
69 this.agentFactory
= agentFactory
;