KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > appserver > BackupManager


1 /*
2  * BackupManager.java
3  *
4  * Created on January 16, 2004, 11:11 AM
5  */

6
7 package com.sun.enterprise.config.backup.appserver;
8
9 import com.sun.enterprise.config.backup.*;
10 import com.sun.enterprise.config.backup.utils.*;
11 import com.sun.enterprise.config.backup.status.*;
12
13 /**
14  *
15  * @author bnevins
16  */

17 public class BackupManager
18 {
19     public BackupManager()
20     {
21     }
22     
23     public void execute(BackupRequest request)
24     {
25         request.verify();
26         String JavaDoc[] dirs = request.getDirsToBackup();
27         String JavaDoc allDirs = dirs[0];
28         
29         for(int i = 1; i < dirs.length; i++)
30             allDirs += ',' + dirs[i];
31         
32         SystemPropsHelper.setProperty(EnvironmentConstants.DIRS_TO_BACKUP, allDirs);
33         SystemPropsHelper.setProperty(EnvironmentConstants.DIR_TO_STORE_BACKUP_FILES, request.getDirToStoreBackupFiles());
34         SystemPropsHelper.setProperty(EnvironmentConstants.BACKUP_STORAGE_TYPE, request.getBackupStorageType());
35         BackupCommand cmd = request.getCommand();
36         
37         BackupRestore bri = Util.getBackupRestore();
38         Status[] statuses = new Status[1];
39         BackupHistory bh = null;
40         try
41         {
42             if(cmd == BackupCommand.backup)
43             {
44                 statuses[0] = bri.backup(request.getUserInfo());
45             }
46             else if(cmd == BackupCommand.restore)
47             {
48                 statuses[0] = bri.restore();
49             }
50             else if(cmd == BackupCommand.undorestore)
51             {
52                 statuses[0] = bri.undoRestore();
53             }
54             else if(cmd == BackupCommand.listbackups)
55             {
56                 statuses = bri.listBackups();
57             }
58             else if(cmd == BackupCommand.listhistory)
59             {
60                 // temp bnevins wbn fixme
61
statuses = null;
62                 bh = bri.getBackupHistory(6);
63             }
64         }
65         catch(BackupAbortException bae)
66         {
67             throw bae;
68         }
69         catch(BackupException be)
70         {
71             // bnevins wbn fixme temp tbd todo
72
throw new BackupAbortException("qqqqq", "wwwww", be);
73         }
74         catch(Exception JavaDoc e)
75         {
76             throw new BackupAbortException("xxx", "yyy", e);
77         }
78         
79         if(bh != null)
80         {
81             System.out.println(bh.toString());
82         }
83         if(statuses != null)
84         {
85             for(int i = 0; i < statuses.length; i++)
86             {
87                 System.out.println(statuses[i]);
88             }
89         }
90     }
91 }
92
93
94
95 /******
96  *
97  * if("backup".equals(args[0])) {
98                 String userInfo = null;
99                 if(args.length == 1) { // && (args[1] == null || "".equals(args[1]))) {
100                     s = bri.backup(null);
101                 } else if(args.length == 2) { //&& (args[2] == null || "".equals(args[2]))) {
102                     System.out.println("info=" + args[1]);
103                     s = bri.backup(args[1]);
104                 } else if(args.length == 3) {
105                     s = bri.backup(args[1], args[2]);
106                 } else {
107                     usage();
108                     return;
109                 }
110             } else if ("restore".equals(args[0])) {
111                 s = bri.restore();
112             } else if("undorestore".equals(args[0])) {
113                 s = bri.undoRestore();
114             } else if("listbackups".equals(args[0])) {
115                 BackupStatus[] bs = bri.listBackups();
116                 System.out.println("==================");
117                 
118                 printBackupStatus(bs);
119                 System.out.println("==================");
120                 
121                 return;
122             } else if("listhistory".equals(args[0])) {
123                 int n=HISTORY_NUMBER;
124                 if(args.length==2) { // && args != null && !args[1].equals("") ) {
125                     n = getHistoryNumber(args[1]);
126                 }
127                 BackupHistory bh = bri.getBackupHistory(n);
128                 System.out.println("==================");
129                 
130                 //printBackupStatus(bh);
131                 System.out.println(bh);
132                 System.out.println("==================");
133    */

134
135
Popular Tags