1 package org
.argeo
.slc
.ws
.process
;
3 import org
.apache
.commons
.logging
.Log
;
4 import org
.apache
.commons
.logging
.LogFactory
;
6 import org
.argeo
.slc
.SlcException
;
7 import org
.argeo
.slc
.dao
.process
.SlcExecutionDao
;
8 import org
.argeo
.slc
.msg
.process
.SlcExecutionRequest
;
9 import org
.argeo
.slc
.msg
.process
.SlcExecutionStatusRequest
;
10 import org
.argeo
.slc
.process
.SlcExecution
;
12 import org
.springframework
.ws
.server
.endpoint
.AbstractMarshallingPayloadEndpoint
;
14 public class SlcExecutionRequestEp
extends AbstractMarshallingPayloadEndpoint
{
16 private Log log
= LogFactory
.getLog(getClass());
18 private final SlcExecutionDao slcExecutionDao
;
20 public SlcExecutionRequestEp(SlcExecutionDao slcExecutionDao
) {
21 this.slcExecutionDao
= slcExecutionDao
;
25 protected Object
invokeInternal(Object requestObject
) throws Exception
{
26 if (requestObject
instanceof SlcExecutionRequest
) {
28 SlcExecutionRequest msg
= (SlcExecutionRequest
) requestObject
;
29 SlcExecution slcExecutionMsg
= msg
.getSlcExecution();
31 SlcExecution slcExecutionPersisted
= slcExecutionDao
32 .getSlcExecution(slcExecutionMsg
.getUuid());
33 if (slcExecutionPersisted
== null) {
34 if (log
.isTraceEnabled())
35 log
.trace("Creating SLC execution #"
36 + slcExecutionMsg
.getUuid());
38 slcExecutionDao
.create(slcExecutionMsg
);
40 if (log
.isTraceEnabled())
41 log
.trace("Updating SLC execution #"
42 + slcExecutionMsg
.getUuid());
44 slcExecutionDao
.merge(slcExecutionMsg
);
48 } else if (requestObject
instanceof SlcExecutionStatusRequest
) {
49 SlcExecutionStatusRequest msg
= (SlcExecutionStatusRequest
) requestObject
;
50 SlcExecution slcExecution
= slcExecutionDao
.getSlcExecution(msg
51 .getSlcExecutionUuid());
52 if (slcExecution
== null)
53 throw new SlcException("Could not find SLC execution #"
54 + msg
.getSlcExecutionUuid());
56 slcExecution
.setStatus(msg
.getNewStatus());
58 if (log
.isTraceEnabled())
59 log
.trace("Updating status for SLC execution #"
60 + slcExecution
.getUuid());
62 slcExecutionDao
.update(slcExecution
);
65 throw new SlcException("Unrecognized request format: "
66 + requestObject
.getClass());