KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > status > BackupStatus


1 /*
2  * BackupStatus.java
3  *
4  * Created on December 13, 2000, 6:52 AM
5  */

6
7 package com.sun.enterprise.config.backup.status;
8
9 import java.util.Date JavaDoc;
10 import com.sun.enterprise.config.backup.BackupException;
11 import com.sun.enterprise.config.backup.utils.BackupHelper;
12 import com.sun.enterprise.config.backup.utils.FactoryHelper;
13
14 /**
15  * Backup Status is used to keep the status for
16  * the backup action.
17  * @author sridatta
18  */

19 public class BackupStatus extends Status {
20     
21     private String JavaDoc _absoluteBackupFileName;
22    
23     /** directory where the backup file is stored .
24      */

25     private String JavaDoc _backupDir;
26     
27     /** Size of the backup file */
28     private long _backupFileSize;
29     
30     /** user entered extra info */
31     private String JavaDoc _userInfo;
32     
33     /** Creates a new instance of BackupStatus */
34     public BackupStatus() {
35     }
36     
37     public BackupStatus(String JavaDoc userInfo, boolean initialize) throws BackupException {
38         super(initialize);
39         _userInfo = userInfo;
40         if(initialize) {
41             init();
42         }
43     }
44     
45     /**
46      * Determine the next number to be created
47      * Managed the max numbers.
48      * Delete the oldest one if required
49      * get the prefix
50      * add timestamp
51      * create fileName = dir/prefix + timestamp+ number
52      *
53      * Update BackupNumber, TargetFile in BackupStatus
54      * update source files, etc
55      */

56     private void init() throws BackupException {
57         setBackupDirectory(getDirectory());
58         setAbsoluteBackupFileName(getAbsoluteName(getCreationTimeStamp()));
59     }
60     
61     protected String JavaDoc getDirectory() throws BackupException {
62         return FactoryHelper.getEnv().getDirectoryToStoreBackupFiles();
63     }
64     
65     private String JavaDoc getAbsoluteName(long ts) {
66         return BackupHelper.getAbsoluteBackupFileName(ts);
67     }
68     
69    public String JavaDoc getAbsoluteBackupFileName() {
70         return _absoluteBackupFileName;
71     }
72     
73     public String JavaDoc getBackupDirectory() {
74         return _backupDir;
75     }
76        
77     public long getBackupFileSize() {
78         return _backupFileSize;
79     }
80     
81     public void setBackupFileSize(long size) {
82         _backupFileSize = size;
83     }
84     
85     public String JavaDoc getUserInfo() {
86         return _userInfo;
87     }
88     
89     protected void setUserInfo(String JavaDoc s) {
90         _userInfo = s;
91     }
92     
93     public void setAbsoluteBackupFileName(String JavaDoc name) {
94         _absoluteBackupFileName = name;
95     }
96     
97     
98     private void setBackupDirectory(String JavaDoc dir) {
99         _backupDir = dir;
100     }
101     
102     protected String JavaDoc thisToString() {
103         
104        String JavaDoc result =
105             "Backup FileName " + _absoluteBackupFileName + ", " +
106             "Backup File Size " + _backupFileSize;
107        
108               String JavaDoc userInfo = getUserInfo();
109         
110         if(userInfo != null && !userInfo.equals("") ) {
111             result += ", User Info=" + userInfo;
112         }
113               
114        return result;
115     }
116     
117     public String JavaDoc getOperation() {
118         return "backup";
119     }
120    
121     public String JavaDoc[] getDirectoriesToBackup() {
122         return FactoryHelper.getEnv().getDirectoriesToBackup();
123     }
124 }
125
Popular Tags