package org.zstack.header.message;

import org.zstack.header.errorcode.ErrorCode;

public class MessageReply extends Message {
    /**
     * @desc indicate the failure or success. Client should evaluate this field before evaluating
     * inventory field
     * @choices - true
     * - false
     */
    private boolean success = true;
    /**
     * @desc sometimes we just cancel this msg execution, neither success or failed
     */
    private boolean canceled = false;
    /**
     * @desc indicate the reason of api failure. It presents only if success = false
     * @nullable
     */
    private ErrorCode error;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public ErrorCode getError() {
        return error;
    }

    public void setError(ErrorCode error) {
        this.error = error;
        this.setSuccess(false);
    }

    public boolean isCanceled() {
        return canceled;
    }

    public void setCanceled(ErrorCode error) {
        this.error = error;
        this.canceled = true;
        this.setSuccess(false);
    }

    public String getCorrelationId() {
        return getHeaderEntry("correlationId");
    }

    public <T> T castReply() {
        return (T) this;
    }
}

@@ -79,52 +79,244 @@
 de;%0A
-%0Apublic class MessageReply extends Message %7B
+import org.zstack.header.rest.APINoSee;%0Aimport org.zstack.utils.Utils;%0Aimport org.zstack.utils.logging.CLogger;%0A%0Apublic class MessageReply extends Message %7B%0A    private static final CLogger logger = Utils.getLogger(MessageReply.class);%0A
 %0A   
@@ -615,32 +615,46 @@
  failed%0A     */%0A
+    @APINoSee%0A
     private bool
@@ -1251,32 +1251,138 @@
 orCode error) %7B%0A
+        logger.debug(String.format(%22message has been canceled, %5BcorrelationId=%25s%5D%22, getCorrelationId()));%0A
         this.err

set cancel as APINoSee, and log it if happened