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.console.text.ColorPrinter; 29 import org.objectweb.cjdbc.console.text.formatter.TableFormatter; 30 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin; 31 32 39 public class ViewBackupers extends AbstractAdminCommand 40 { 41 42 47 public ViewBackupers(VirtualDatabaseAdmin module) 48 { 49 super(module); 50 } 51 52 55 public void parse(String commandText) throws Exception 56 { 57 VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(dbName, user, 58 password); 59 String [] backuperNames = vdjc.getBackuperNames(); 60 if (backuperNames.length == 0) 61 { 62 console.printError(ConsoleTranslate.get("admin.command.view.backupers.nobackuper")); 63 return; 64 } 65 String [] dumpFormats = new String [backuperNames.length]; 66 for (int i = 0; i < backuperNames.length; i++) 67 { 68 String backuperName = backuperNames[i]; 69 String dumpFormat = vdjc.getDumpFormatForBackuper(backuperName); 70 if (dumpFormat == null) 71 { 72 dumpFormat = ""; 73 } 74 dumpFormats[i] = dumpFormat; 75 } 76 String formattedBackupers = TableFormatter.format(getBackupersHeaders(), 77 getBackupersAsCells(backuperNames, dumpFormats), true); 78 console.println(formattedBackupers, ColorPrinter.STATUS); 79 } 80 81 84 public String getCommandName() 85 { 86 return "show backupers"; 87 } 88 89 92 public String getCommandDescription() 93 { 94 return ConsoleTranslate.get("admin.command.view.backupers.description"); 95 } 96 97 private static String [][] getBackupersAsCells(String [] backuperNames, String [] dumpFormats) 98 { 99 String [][] backupersTable = new String [backuperNames.length][2]; 100 for (int i = 0; i < backupersTable.length; i++) 101 { 102 backupersTable[i][0] = backuperNames[i]; 103 backupersTable[i][1] = dumpFormats[i]; 104 } 105 return backupersTable; 106 } 107 108 private static String [] getBackupersHeaders() 109 { 110 return new String [] { 111 ConsoleTranslate.get("admin.command.view.backupers.prop.name"), 112 ConsoleTranslate.get("admin.command.view.backupers.prop.dump.format") 113 }; 114 } 115 } | Popular Tags |