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
\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.isTraceEnabled()) {\r
+ log.debug("Content-Type: " + request.getContentType());\r
+ log.debug("Content-Length: " + request.getContentLength());\r
+ }\r
+\r
String agentId = request\r
.getParameter(MsgConstants.PROPERTY_SLC_AGENT_ID);\r
\r
String answer = request.getParameter("body");\r
- if (answer == null && "text/xml".equals(request.getContentType())) {\r
+ if (answer == null) {\r
// lets read the message body instead\r
BufferedReader reader = request.getReader();\r
StringBuffer buffer = new StringBuffer();\r
- while (true) {\r
- String line = reader.readLine();\r
- if (line == null) {\r
- break;\r
- }\r
+ String line = 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
this.agentFactory = agentFactory;\r
}\r
\r
+ public void setSlcExecutionService(SlcExecutionService slcExecutionService) {\r
+ this.slcExecutionService = slcExecutionService;\r
+ }\r
+\r
}\r