1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 import java.util.Map ; 28 29 import java.util.Date ; 30 import java.util.ArrayList ; 31 import java.util.List ; 32 import java.util.logging.Level ; 33 import java.util.Iterator ; 34 import javax.management.Attribute ; 35 import javax.management.AttributeList ; 36 37 public class DisplayLogRecordsCommand extends GenericCommand 38 { 39 40 private final static String TIMESTAMP_OPTION = "timestamp"; 41 private final static String MODULEID_OPTION = "moduleid"; 42 private final static String LEVEL_OPTION = "errorlevel"; 43 private final static String MODULE_DELIMITER = ":"; 44 45 protected Object [] getParamsInfo()throws CommandException, CommandValidationException 46 { 47 Object [] paramsInfo = new Object [11]; 48 long timestamp = new Long (getOption(TIMESTAMP_OPTION)).longValue(); 49 String errorLevel = getOption(LEVEL_OPTION); 50 51 paramsInfo[0] = null; 52 paramsInfo[1] = null; 53 paramsInfo[2] = Boolean.FALSE; 54 paramsInfo[3] = Boolean.FALSE; 55 paramsInfo[4] = new Integer (1000); 56 paramsInfo[5] = new Date (timestamp); 57 paramsInfo[6] = new Date (timestamp + 3600000); 58 paramsInfo[7] = (errorLevel == null) ? Level.WARNING.toString() : errorLevel; 59 paramsInfo[8] = (errorLevel != null) ? Boolean.TRUE : Boolean.FALSE; 60 paramsInfo[9] = getModuleIds(); 61 paramsInfo[10] = null; 62 for (Object param : paramsInfo) 63 { 64 if (param != null) 65 CLILogger.getInstance().printDebugMessage(param.toString()); 66 else 67 CLILogger.getInstance().printDebugMessage("null"); 68 } 69 return paramsInfo; 70 } 71 72 73 protected void handleReturnValue(Object retVal) 74 { 75 final AttributeList results = (AttributeList ) retVal; 77 List headerRow = (List )(((Attribute )results.get(0)).getValue()); 78 List rowList = (List )(((Attribute )results.get(1)).getValue()); 79 List row; 80 81 Iterator it = rowList.iterator(); 82 if (it.hasNext()) 83 { 84 CLILogger.getInstance().printDetailMessage( 85 "----------------------------------------------------------------------"); 86 87 } 88 else 89 { 90 CLILogger.getInstance().printDetailMessage( 91 getLocalizedString("NoElementsToList")); 92 } 93 while (it.hasNext()) 94 { 95 row = (List )it.next(); 96 if (row.size() != headerRow.size()) { 97 CLILogger.getInstance().printDebugMessage( 99 "Row had '"+row.size()+"' columns, header has '"+ 100 headerRow.size()+"' columns!"); 101 } 102 103 CLILogger.getInstance().printMessage(getLocalizedString("LogRecNumber") 104 + " = " + row.get(0)); 105 CLILogger.getInstance().printMessage(getLocalizedString("LogDateTime") 106 + " = " + row.get(1)); 107 CLILogger.getInstance().printMessage(getLocalizedString("LogMsgId") 108 + " = " + row.get(6)); 109 CLILogger.getInstance().printMessage(getLocalizedString("LogLevel") 110 + " = " + row.get(2)); 111 CLILogger.getInstance().printMessage(getLocalizedString("LogProductName") 112 + " = " + row.get(3)); 113 CLILogger.getInstance().printMessage(getLocalizedString("LogLogger") 114 + " = " + row.get(4)); 115 CLILogger.getInstance().printMessage(getLocalizedString("Lognvp") 116 + " = " + row.get(5)); 117 CLILogger.getInstance().printMessage(getLocalizedString("LogMessage") 118 + " = " + row.get(7)); 119 CLILogger.getInstance().printDetailMessage( 120 "----------------------------------------------------------------------"); 121 } 122 } 123 124 125 129 protected List getModuleIds() 130 throws CommandException, CommandValidationException 131 { 132 final List moduleIds = new ArrayList (); 133 134 String modulesStr = (String ) getOperands().get(0); 135 final CLITokenizer modulesTok = new CLITokenizer(modulesStr, MODULE_DELIMITER); 136 while (modulesTok.hasMoreTokens()) { 137 moduleIds.add(modulesTok.nextToken()); 138 } 139 return moduleIds; 140 } 141 } 142 | Popular Tags |