package org.ovirt.engine.core.common.businessentities;

import java.io.Serializable;

import org.ovirt.engine.core.compat.StringHelper;

public class AsyncTaskStatus implements Serializable {
    private static final long serialVersionUID = -7569773307084259828L;

    public AsyncTaskStatus() {
        this(AsyncTaskStatusEnum.unknown);
    }

    public AsyncTaskStatus(AsyncTaskStatusEnum status) {
        setStatus(status);
        setResult(AsyncTaskResultEnum.success);
        setMessage("");
    }

    private AsyncTaskStatusEnum privateStatus;

    public AsyncTaskStatusEnum getStatus() {
        return privateStatus;
    }

    public void setStatus(AsyncTaskStatusEnum value) {
        privateStatus = value;
    }

    private AsyncTaskResultEnum privateResult;

    public AsyncTaskResultEnum getResult() {
        return privateResult;
    }

    public void setResult(AsyncTaskResultEnum value) {
        privateResult = value;
    }

    private RuntimeException privateException;

    public RuntimeException getException() {
        return privateException;
    }

    public void setException(RuntimeException value) {
        privateException = value;
    }

    private String _message;

    public String getMessage() {
        if (getTaskIsRunning() || getTaskEndedSuccessfully()) {
            // No message is relevant:
            return "";
        }
        return (!StringHelper.isNullOrEmpty(_message)) ? (_message) : ((getException() != null && !StringHelper
                .isNullOrEmpty(getException().getMessage())) ? (getException().getMessage())
                : ("Asynchronous Task unknown error"));
    }

    public void setMessage(String value) {
        _message = value;
    }

    public boolean getTaskIsRunning() {
        return getStatus() != AsyncTaskStatusEnum.finished && getStatus() != AsyncTaskStatusEnum.unknown;
    }

    public boolean getTaskIsInUnusualState() {
        return (getStatus() == AsyncTaskStatusEnum.unknown || getStatus() == AsyncTaskStatusEnum.aborting);
    }

    public boolean getTaskEndedSuccessfully() {
        return getStatus() == AsyncTaskStatusEnum.finished && getResult() == AsyncTaskResultEnum.success
                && getException() == null;
    }

    @Override
    public String toString() {
        return "(status = " + getStatus() + ", result = " + getResult() + ", exception = " + getException() + ", msg = " +getMessage() + ")";
    }
}

@@ -258,16 +258,165 @@
 9828L;%0A%0A
+    private AsyncTaskStatusEnum status;%0A    private AsyncTaskResultEnum result;%0A    private RuntimeException exception;%0A    private String message;%0A%0A
     publ
@@ -655,56 +655,8 @@
  %7D%0A%0A
-    private AsyncTaskStatusEnum privateStatus;%0A%0A
     
@@ -711,24 +711,17 @@
  return 
-privateS
+s
 tatus;%0A 
@@ -768,29 +768,30 @@
 kStatusEnum 
-value
+status
 ) %7B%0A        
@@ -794,24 +794,22 @@
     
-privateS
+this.s
 tatus = 
 valu
@@ -804,21 +804,22 @@
 tatus = 
-value
+status
 ;%0A    %7D%0A
@@ -823,56 +823,8 @@
  %7D%0A%0A
-    private AsyncTaskResultEnum privateResult;%0A%0A
     
@@ -879,24 +879,17 @@
  return 
-privateR
+r
 esult;%0A 
@@ -940,21 +940,22 @@
 ultEnum 
-value
+result
 ) %7B%0A    
@@ -962,24 +962,22 @@
     
-privateR
+this.r
 esult = 
 valu
@@ -972,21 +972,22 @@
 esult = 
-value
+result
 ;%0A    %7D%0A
@@ -991,56 +991,8 @@
  %7D%0A%0A
-    private RuntimeException privateException;%0A%0A
     
@@ -1047,24 +1047,17 @@
  return 
-privateE
+e
 xception
@@ -1132,16 +1132,14 @@
     
-privateE
+this.e
 xcep
@@ -1163,38 +1163,8 @@
  %7D%0A%0A
-    private String _message;%0A%0A
     
@@ -1372,17 +1372,16 @@
 OrEmpty(
-_
 message)
@@ -1385,17 +1385,16 @@
 ge)) ? (
-_
 message)
@@ -1420,16 +1420,32 @@
  != null
+%0A               
  && !Str
@@ -1453,33 +1453,16 @@
 ngHelper
-%0A                
 .isNullO
@@ -1627,20 +1627,22 @@
 (String 
-valu
+messag
 e) %7B%0A   
@@ -1650,9 +1650,13 @@
     
-_
+this.
 mess
@@ -1661,20 +1661,22 @@
 ssage = 
-valu
+messag
 e;%0A    %7D
@@ -2351,23 +2351,44 @@
 on()
+%0A               
  + %22, m
-sg
+essage
  = %22 +
+ 
 getM

Standardize AsyncTaskStatus