1 21 22 package org.continuent.sequoia.console.text.commands.dbadmin; 23 24 import org.continuent.sequoia.common.i18n.ConsoleTranslate; 25 import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean; 26 import org.continuent.sequoia.console.text.formatter.TableFormatter; 27 import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin; 28 29 36 public class ViewBackupers extends AbstractAdminCommand 37 { 38 39 44 public ViewBackupers(VirtualDatabaseAdmin module) 45 { 46 super(module); 47 } 48 49 52 public void parse(String commandText) throws Exception 53 { 54 VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(dbName, user, 55 password); 56 String [] backuperNames = vdjc.getBackuperNames(); 57 if (backuperNames.length == 0) 58 { 59 console.printError(ConsoleTranslate.get("admin.command.view.backupers.nobackuper")); return; 61 } 62 String [] dumpFormats = new String [backuperNames.length]; 63 for (int i = 0; i < backuperNames.length; i++) 64 { 65 String backuperName = backuperNames[i]; 66 String dumpFormat = vdjc.getDumpFormatForBackuper(backuperName); 67 if (dumpFormat == null) 68 { 69 dumpFormat = ""; } 71 dumpFormats[i] = dumpFormat; 72 } 73 String formattedBackupers = TableFormatter.format(getBackupersHeaders(), 74 getBackupersAsCells(backuperNames, dumpFormats), true); 75 console.println(formattedBackupers); 76 } 77 78 81 public String getCommandName() 82 { 83 return "show backupers"; } 85 86 89 public String getCommandDescription() 90 { 91 return ConsoleTranslate.get("admin.command.view.backupers.description"); } 93 94 private static String [][] getBackupersAsCells(String [] backuperNames, String [] dumpFormats) 95 { 96 String [][] backupersTable = new String [backuperNames.length][2]; 97 for (int i = 0; i < backupersTable.length; i++) 98 { 99 backupersTable[i][0] = backuperNames[i]; 100 backupersTable[i][1] = dumpFormats[i]; 101 } 102 return backupersTable; 103 } 104 105 private static String [] getBackupersHeaders() 106 { 107 return new String [] { 108 ConsoleTranslate.get("admin.command.view.backupers.prop.name"), ConsoleTranslate.get("admin.command.view.backupers.prop.dump.format") }; 111 } 112 } | Popular Tags |