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.module.VirtualDatabaseAdmin; 33 34 42 public class Restore extends AbstractAdminCommand 43 { 44 45 50 public Restore(VirtualDatabaseAdmin module) 51 { 52 super(module); 53 } 54 55 58 public void parse(String commandText) throws Exception 59 { 60 String dumpName = null; 61 String backendName = null; 62 StringTokenizer st = new StringTokenizer (commandText.trim()); 63 64 try 65 { 66 backendName = st.nextToken(); 67 dumpName = st.nextToken(); 68 ArrayList tables = null; 69 if (st.hasMoreTokens()) 70 { 71 tables = new ArrayList (); 72 while (st.hasMoreTokens()) 73 { 74 tables.add(st.nextToken()); 75 } 76 } 77 78 String login = console.readLine(ConsoleTranslate 79 .get("admin.restore.user")); 80 if (login == null) 81 return; 82 83 String pwd = console.readPassword(ConsoleTranslate 84 .get("admin.restore.password")); 85 if (pwd == null) 86 return; 87 88 console.println(ConsoleTranslate.get("admin.command.restore.echo", 89 new String []{backendName, dumpName})); 90 VirtualDatabaseMBean vjdc = jmxClient.getVirtualDatabaseProxy(dbName, 91 user, password); 92 vjdc.restoreDumpOnBackend(backendName, login, pwd, dumpName, tables); 93 } 94 catch (Exception e) 95 { 96 if (dumpName == null) 97 { 98 console 99 .println(ConsoleTranslate.get("admin.command.restore.need.dump")); 100 } 101 if (backendName == null) 102 { 103 console.println(ConsoleTranslate 104 .get("admin.command.restore.need.backend")); 105 } 106 } 107 } 108 109 112 public String getCommandName() 113 { 114 115 return "restore backend"; 116 } 117 118 121 public String getCommandDescription() 122 { 123 return ConsoleTranslate.get("admin.command.restore.description"); 124 } 125 126 129 public String getCommandParameters() 130 { 131 return ConsoleTranslate.get("admin.command.restore.params"); 132 } 133 } | Popular Tags |