01: package org.concern.library.collaboration;
02:
03: import org.concern.controller.AbstractSynchronousActivity;
04: import org.concern.controller.ActivityExecutionException;
05: import org.concern.*;
06: import ognl.OgnlException;
07: import ognl.Ognl;
08:
09: import java.sql.Timestamp;
10:
11: /**
12: * @author hengels
13: * @version $Revision$
14: */
15: public class NotifyActivity extends AbstractSynchronousActivity {
16: private String message;
17: private String flag;
18: private String stamp;
19:
20: public void setMessage(String message) {
21: this .message = message;
22: }
23:
24: public void setFlag(String flag) {
25: this .flag = flag;
26: }
27:
28: public void setStamp(String stamp) {
29: this .stamp = stamp;
30: }
31:
32: public void execute(Object subject)
33: throws ActivityExecutionException {
34: try {
35: Collaboration collaboration = ControllerLookup
36: .getInstance().getCollaboration();
37: collaboration.notify(new Message(message, controller
38: .getProcessName(), this .controller.getLoader()
39: .idOf(subject)));
40: } catch (Exception e) {
41: throw new ActivityExecutionException(e);
42: }
43: mark(subject);
44: }
45:
46: protected void mark(Object subject)
47: throws ActivityExecutionException {
48: try {
49: if (flag != null)
50: Ognl.setValue(flag, subject, true);
51: } catch (OgnlException e) {
52: throw new ActivityExecutionException(flag + ": "
53: + e.getMessage());
54: }
55: try {
56: if (stamp != null)
57: Ognl.setValue(stamp, subject, new Timestamp(System
58: .currentTimeMillis()));
59: } catch (OgnlException e) {
60: throw new ActivityExecutionException(stamp + ": "
61: + e.getMessage());
62: }
63: }
64: }
|