1 6 7 package com.sun.enterprise.config.backup.status; 8 9 import java.io.Serializable ; 10 import java.util.Date ; 11 import com.sun.enterprise.config.backup.BackupException; 12 import com.sun.enterprise.config.backup.utils.FactoryHelper; 13 14 24 public abstract class Status implements StatusConstants, Serializable { 25 26 private StatusCode _statusCode = new StatusCode(); 27 private Exception _exception; 28 private ExecutionType _executionType = new ExecutionType(); 29 private long _creationTimeStamp = System.currentTimeMillis(); 30 31 private String _backupStorageType; 32 33 private String _extraInfo; 34 35 36 public Status() { 37 } 38 39 public Status(boolean initialize) throws BackupException { 40 if(initialize) { 41 init(); 42 } 43 } 44 45 56 private void init() throws BackupException { 57 setExecutionType(FactoryHelper.getEnv().getExecutionType()); 58 setBackupStorageType(FactoryHelper.getEnv().getBackupStorageType()); 59 } 60 61 public long getCreationTimeStamp() { 62 return _creationTimeStamp; 63 } 64 65 66 public String getBackupStorageType() { 67 return _backupStorageType; 68 } 69 70 public void setBackupStorageType(String type) { 71 _backupStorageType = type; 72 } 73 public String getStatusCode() { 74 return _statusCode.getStatusCode(); 75 } 76 77 public Exception getException() { 78 return _exception; 79 } 80 81 public String getExecutionType() { 82 return _executionType.getExecutionType(); 83 } 84 85 public void setStatusCode(String status) throws BackupException { 86 _statusCode.setStatus(status); 87 } 88 89 public void setExecutionType(String executionType) throws BackupException { 90 _executionType.setExecutionType(executionType); 91 } 92 93 public void setException(Exception e) throws BackupException { 94 _exception = e; 95 _statusCode.setStatus(STATUS_FAILURE); 96 } 97 98 private String baseToString() { 99 100 String exceptionMessages = (_exception == null)?"": 101 ", ExceptionType= " + _exception.getClass().getName() + 102 ", ExceptionMessage= " + _exception.getMessage(); 103 104 String creationTime = ", Created Time= " + getCreationDate(); 105 String result = 106 getOperation() + ":Status= " + _statusCode + 107 ", ExecutionType= " + _executionType + 108 ", Backup File Type " + _backupStorageType + 109 110 exceptionMessages + creationTime; 111 112 return result; 113 } 114 115 public String toString() { 116 String result = " {" + 117 baseToString() + ", " + 118 thisToString() + 119 "}"; 120 return result; 121 } 122 123 private String getCreationDate() { 124 return new Date (_creationTimeStamp).toString(); 125 } 126 127 public boolean isSuccess() { 128 return STATUS_SUCCESS.equals(_statusCode.getStatusCode()); 129 } 130 131 public String getExtraInfo() { 132 return _extraInfo; 133 } 134 135 public void setExtraInfo(String s) { 136 _extraInfo = s; 137 } 138 139 public abstract String getOperation(); 140 protected abstract String thisToString(); 141 } 142 | Popular Tags |