]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedAnswer.java
Allow to refresh a comma separated list of bundles
[gpl/argeo-slc.git] / runtime / org.argeo.slc.detached / src / main / java / org / argeo / slc / detached / DetachedAnswer.java
1 package org.argeo.slc.detached;
2
3 import java.util.Properties;
4
5 /** An answer returned by the detached server. Always related to a request. */
6 public class DetachedAnswer implements DetachedCommunication {
7 static final long serialVersionUID = 1l;
8
9 public final static int UNKOWN = -1;
10 public final static int PROCESSED = 0;
11 public final static int ERROR = 1;
12 public final static int SKIPPED = 2;
13 public final static int CLOSED_SESSION = 10;
14
15 private Properties properties = new Properties();
16 private int status = UNKOWN;
17 private String log;
18 private String uuid;
19
20 public DetachedAnswer() {
21
22 }
23
24 public DetachedAnswer(DetachedRequest request) {
25 uuid = request.getUuid();
26 }
27
28 public DetachedAnswer(DetachedRequest request, String message) {
29 this(request);
30 log = message;
31 status = PROCESSED;
32 }
33
34 public Properties getProperties() {
35 return properties;
36 }
37
38 public void setProperties(Properties outputParameters) {
39 this.properties = outputParameters;
40 }
41
42 public int getStatus() {
43 return status;
44 }
45
46 public void setStatus(int outputStatus) {
47 this.status = outputStatus;
48 }
49
50 public String getLog() {
51 return log;
52 }
53
54 public void setLog(String log) {
55 this.log = log;
56 }
57
58 public void addToLog(String msg) {
59 this.log = new StringBuffer(this.log).append(msg).toString();
60 }
61
62 /** The unique identifier of this answer. */
63 public String getUuid() {
64 return uuid;
65 }
66
67 public void setUuid(String uuid) {
68 this.uuid = uuid;
69 }
70
71 public String getStatusAsString() {
72 return convertStatus(getStatus());
73 }
74
75 public static String convertStatus(int status) {
76 switch (status) {
77 case UNKOWN:
78 return "UNKOWN";
79 case PROCESSED:
80 return "PROCESSED";
81 case SKIPPED:
82 return "SKIPPED";
83 case ERROR:
84 return "ERROR";
85 case CLOSED_SESSION:
86 return "CLOSED_SESSION";
87 default:
88 throw new DetachedException("Unkown status " + status);
89 }
90 }
91
92 public String toString() {
93 StringBuffer buf = new StringBuffer(getClass().getName());
94 buf.append('#').append(uuid);
95 buf.append(" status=").append(convertStatus(status));
96 buf.append(" properties=").append(properties);
97 buf.append(" log=").append(log);
98 return buf.toString();
99 }
100
101 }