Allows to return HTML from serializing views
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.core / src / main / java / org / argeo / server / ServerAnswer.java
index c3e747608dcf10fc264ca87ecbdc4127c5829482..d0fc26a09508d1c1813965158a76d1b39376a474 100644 (file)
@@ -4,6 +4,7 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 
 import org.apache.commons.io.IOUtils;
+import org.argeo.ArgeoException;
 
 /** Answer to an execution of a remote service which performed changes. */
 public class ServerAnswer {
@@ -13,11 +14,13 @@ public class ServerAnswer {
        private String status = OK;
        private String message = "";
 
+       // TODO: add an exception field
+
        /** Canonical constructor */
        public ServerAnswer(String status, String message) {
                setStatus(status);
                if (message == null)
-                       throw new ArgeoServerException("Message cannot be null");
+                       throw new ArgeoException("Message cannot be null");
                this.message = message;
        }
 
@@ -31,7 +34,7 @@ public class ServerAnswer {
 
        public void setStatus(String status) {
                if (status == null || (!status.equals(OK) && !status.equals(ERROR)))
-                       throw new ArgeoServerException("Bad status format: " + status);
+                       throw new ArgeoException("Bad status format: " + status);
                this.status = status;
        }
 
@@ -69,4 +72,9 @@ public class ServerAnswer {
                return new ServerAnswer(OK, message);
        }
 
+       @Override
+       public String toString() {
+               return "ServerAnswer{status:" + status + ", message:" + message + "}";
+       }
+
 }