2 * Copyright (C) 2007-2012 Mathieu Baudier
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.detached
;
18 import java
.util
.Properties
;
20 /** An answer returned by the detached server. Always related to a request. */
21 public class DetachedAnswer
implements DetachedCommunication
{
22 static final long serialVersionUID
= 1l;
24 public final static int UNKOWN
= -1;
25 public final static int PROCESSED
= 0;
26 public final static int ERROR
= 1;
27 public final static int SKIPPED
= 2;
28 public final static int CLOSED_SESSION
= 10;
30 private Properties properties
= new Properties();
31 private int status
= UNKOWN
;
35 public DetachedAnswer() {
39 public DetachedAnswer(DetachedRequest request
) {
40 uuid
= request
.getUuid();
43 public DetachedAnswer(DetachedRequest request
, String message
) {
49 public Properties
getProperties() {
53 public void setProperties(Properties outputParameters
) {
54 this.properties
= outputParameters
;
57 public int getStatus() {
61 public void setStatus(int outputStatus
) {
62 this.status
= outputStatus
;
65 public String
getLog() {
69 public void setLog(String log
) {
73 public void addToLog(String msg
) {
74 this.log
= new StringBuffer(this.log
).append(msg
).toString();
77 /** The unique identifier of this answer. */
78 public String
getUuid() {
82 public void setUuid(String uuid
) {
86 public String
getStatusAsString() {
87 return convertStatus(getStatus());
90 public static String
convertStatus(int status
) {
101 return "CLOSED_SESSION";
103 throw new DetachedException("Unkown status " + status
);
107 public String
toString() {
108 StringBuffer buf
= new StringBuffer("detached answer ");
109 buf
.append('#').append(uuid
);
110 buf
.append(" status=").append(convertStatus(status
));
111 buf
.append(" properties=").append(properties
);
112 buf
.append(" log=").append(log
);
113 return buf
.toString();