1 24 25 package org.objectweb.cjdbc.console.text.commands.dbadmin; 26 27 import java.util.ArrayList ; 28 import java.util.StringTokenizer ; 29 30 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate; 31 import org.objectweb.cjdbc.common.jmx.mbeans.VirtualDatabaseMBean; 32 import org.objectweb.cjdbc.console.text.ConsoleException; 33 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin; 34 35 44 public class Backup extends AbstractAdminCommand 45 { 46 47 52 public Backup(VirtualDatabaseAdmin module) 53 { 54 super(module); 55 } 56 57 60 public void parse(String commandText) throws Exception 61 { 62 63 StringTokenizer st = new StringTokenizer (commandText.trim()); 64 65 if (st == null || st.countTokens() < 4) 66 throw new ConsoleException("Usage: " + getCommandName() + " " 67 + getCommandParameters()); 68 69 String backendName = st.nextToken(); 70 String dumpName = st.nextToken(); 71 String backuperName = st.nextToken(); 72 String path = st.nextToken(); 73 ArrayList tables = null; 74 if (st.hasMoreTokens()) 75 { 76 tables = new ArrayList (); 77 while (st.hasMoreTokens()) 78 { 79 tables.add(st.nextToken()); 80 } 81 } 82 83 String login = console.readLine(ConsoleTranslate.get("admin.backup.user")); 84 if (login == null) 85 return; 86 87 String pwd = console.readPassword(ConsoleTranslate 88 .get("admin.backup.password")); 89 if (pwd == null) 90 return; 91 92 console.println(ConsoleTranslate.get("admin.command.backup.echo", 93 new String []{backendName, dumpName})); 94 if (tables != null) 95 console.println(ConsoleTranslate.get("admin.command.backup.tables", 96 tables)); 97 VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(dbName, user, 98 password); 99 vdjc.backupBackend(backendName, login, pwd, dumpName, backuperName, path, 100 tables); 101 } 102 103 106 public String getCommandName() 107 { 108 return "backup"; 109 } 110 111 114 public String getCommandDescription() 115 { 116 return ConsoleTranslate.get("admin.command.backup.description"); 117 } 118 119 122 public String getCommandParameters() 123 { 124 return ConsoleTranslate.get("admin.command.backup.params"); 125 } 126 127 } | Popular Tags |