KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > ui > BackupUI


1 /*
2  * BackupUI.java
3  *
4  * Created on January 15, 2004, 10:48 PM
5  */

6
7 package com.sun.enterprise.config.backup.ui;
8 import java.io.*;
9 import com.sun.enterprise.util.Console;
10 import com.sun.enterprise.config.backup.status.StatusConstants;
11 import com.sun.enterprise.config.backup.BackupRequest;
12 import com.sun.enterprise.config.backup.appserver.BackupManager;
13 /**
14  *
15  * @author bnevins
16  */

17 public class BackupUI
18 {
19     public BackupUI()
20     {
21     }
22  
23     public static void main(String JavaDoc[] args)
24     {
25         String JavaDoc s;
26         String JavaDoc userInfo = "qberry";
27         String JavaDoc execType = StatusConstants.STORAGE_TYPE_ZIP;
28         //String execType = StatusConstants.STORAGE_TYPE_DIRECTORY;
29
String JavaDoc fromDir = "C:/temp/domains/domain1/applications,C:/temp/domains/domain1/config,C:/temp/domains/domain1/generated";
30         //String fromDir = "C:/tmp/domains/domain1/applications,C:/tmp/domains/domain1/generated,C:/tmp/domains/domain1/config";
31
//String fromDir = "C:/tmp/domains/domain1/applications";
32
String JavaDoc toDir = "c:/temp/backuprestore";
33         String JavaDoc command = "backup";
34         boolean ask = false;
35         
36         new File(toDir).mkdirs();
37         
38         if(ask)
39         {
40             s = Console.readLine("User Info [" + userInfo + "]");
41
42             if(s.length() > 0)
43                 userInfo = s;
44
45             if(userInfo.length() < 1)
46                 userInfo = null;
47
48             s = Console.readLine("Backup Storage Type D|Z [" + execType + "]").toLowerCase();
49
50             if(s != null && s.length() > 0)
51             {
52                 if(s.charAt(0) == 'z')
53                     execType = StatusConstants.STORAGE_TYPE_ZIP;
54                 else
55                     execType = StatusConstants.STORAGE_TYPE_DIRECTORY;
56             }
57
58             s = Console.readLine("Directory to backup: [" + fromDir + "]");
59
60             if(s.length() > 0)
61                 fromDir = s;
62
63             s = Console.readLine("Directory to store backup files: [" + toDir + "]");
64
65             if(s.length() > 0)
66                 toDir = s;
67
68
69             s = Console.readLine("Command: [" + command + "]");
70
71             if(s.length() > 0)
72                 command = s;
73         }
74         BackupRequest request = new BackupRequest();
75         
76         request.setDirToStoreBackupFiles(toDir);
77         request.setDirsToBackup(new String JavaDoc[] { fromDir });
78         request.setBackupStorageType(execType);
79         request.setCommand(command);
80         request.setUserInfo(userInfo);
81         request.verify();
82         BackupManager mgr = new BackupManager();
83
84         mgr.execute(request);
85     }
86 }
Popular Tags