1 23 24 package org.objectweb.cjdbc.console.text.commands.dbadmin; 25 26 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate; 27 import org.objectweb.cjdbc.common.jmx.mbeans.VirtualDatabaseMBean; 28 import org.objectweb.cjdbc.common.shared.DumpInfo; 29 import org.objectweb.cjdbc.console.text.ColorPrinter; 30 import org.objectweb.cjdbc.console.text.formatter.TableFormatter; 31 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin; 32 33 41 public class ViewDumps extends AbstractAdminCommand 42 { 43 44 49 public ViewDumps(VirtualDatabaseAdmin module) 50 { 51 super(module); 52 } 53 54 57 public void parse(String commandText) throws Exception 58 { 59 VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(dbName, user, 60 password); 61 DumpInfo[] dumps = vdjc.getAvailableDumps(); 62 if (dumps.length == 0) 63 { 64 console.printError(ConsoleTranslate.get("admin.command.view.dumps.nodump")); 65 } 66 else 67 { 68 String formattedDumps = TableFormatter.format(getDumpsDescriptions(), 69 getDumpsAsStrings(dumps), true); 70 console.println(formattedDumps, ColorPrinter.STATUS); 71 } 72 } 73 74 77 public String getCommandName() 78 { 79 return "show dumps"; 80 } 81 82 85 public String getCommandDescription() 86 { 87 return ConsoleTranslate.get("admin.command.view.dumps.description"); 88 } 89 90 private static String [][] getDumpsAsStrings(DumpInfo[] dumps) 91 { 92 String [][] dumpStr = new String [dumps.length][7]; 93 for (int i = 0; i < dumpStr.length; i++) 94 { 95 DumpInfo dump = dumps[i]; 96 dumpStr[i][0] = dump.getDumpName(); 97 dumpStr[i][1] = dump.getCheckpointName(); 98 dumpStr[i][2] = dump.getDumpFormat(); 99 dumpStr[i][3] = dump.getDumpPath(); 100 dumpStr[i][4] = dump.getDumpDate(); 101 dumpStr[i][5] = dump.getBackendName(); 102 dumpStr[i][6] = dump.getTables(); 103 } 104 return dumpStr; 105 } 106 107 private static String [] getDumpsDescriptions() 108 { 109 String [] desc = new String [7]; 110 desc[0] = ConsoleTranslate.get("admin.command.view.dumps.prop.name"); 111 desc[1] = ConsoleTranslate.get("admin.command.view.dumps.prop.checkpoint"); 112 desc[2] = ConsoleTranslate.get("admin.command.view.dumps.prop.format"); 113 desc[3] = ConsoleTranslate.get("admin.command.view.dumps.prop.path"); 114 desc[4] = ConsoleTranslate.get("admin.command.view.dumps.prop.date"); 115 desc[5] = ConsoleTranslate.get("admin.command.view.dumps.prop.backend"); 116 desc[6] = ConsoleTranslate.get("admin.command.view.dumps.prop.tables"); 117 return desc; 118 } 119 } | Popular Tags |