1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 import javax.management.AttributeList ; 28 import javax.management.Attribute ; 29 import javax.management.MBeanServerConnection ; 30 import javax.management.ObjectName ; 31 32 33 39 40 public class CallflowCommand extends S1ASCommand 41 { 42 private static final String FILTER_TYPE_OPTION = "filtertype"; 43 private static final String CALLER_IPFILTER = "CallerIPFilter"; 44 private static final String CALLER_PRINCIPALFILTER = "CallerPrincipalFilter"; 45 private static final String ENABLED = "Enabled"; 46 private static final String FILTER_TYPE_USER = "user"; 47 private static final String FILTER_TYPE_IP = "ip"; 48 private static final String START_CALL_FLOW= "start-callflow-monitoring"; 49 private String sFilterIP = null; 50 private String sFilterUserID = null; 51 52 53 57 public void runCommand() throws CommandException, CommandValidationException 58 { 59 if (!validateOptions()) 60 throw new CommandValidationException("Validation is false"); 61 62 MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 64 getUser(), getPassword()); 65 final String objectName = getObjectName(); 66 67 try 69 { 70 mbsc.setAttributes(new ObjectName (objectName), 71 createCallflowAttributeList()); 72 } 73 catch(Exception e) 74 { 75 displayExceptionMessage(e); 76 } 77 78 CLILogger.getInstance().printDetailMessage(getLocalizedString( 79 "CommandSuccessful", 80 new Object [] {name})); 81 } 82 83 84 88 private AttributeList createCallflowAttributeList() 89 throws CommandException, CommandValidationException 90 { 91 validateFilterType(); 92 final boolean bEnable = name.equals(START_CALL_FLOW)?true:false; 93 94 AttributeList attrList = new AttributeList (); 95 attrList.add(new Attribute (ENABLED, bEnable)); 96 if (sFilterIP != null) 97 attrList.add(new Attribute (CALLER_IPFILTER, sFilterIP)); 98 if (sFilterUserID != null) 99 attrList.add(new Attribute (CALLER_PRINCIPALFILTER, sFilterUserID)); 100 return attrList; 101 } 102 103 104 105 115 private void validateFilterType() throws CommandException, CommandValidationException 116 { 117 if (getOption(FILTER_TYPE_OPTION) != null) { 118 final String filterType = getOption(FILTER_TYPE_OPTION); 119 120 final CLITokenizer filterTypeTok = new CLITokenizer(filterType, PROPERTY_DELIMITER); 121 while (filterTypeTok.hasMoreTokens()) { 122 final String nameAndvalue = filterTypeTok.nextToken(); 123 final CLITokenizer nameTok = new CLITokenizer(nameAndvalue, PARAM_VALUE_DELIMITER); 124 if (nameTok.countTokens() == 2) 125 { 126 final String sName = nameTok.nextTokenWithoutEscapeAndQuoteChars(); 127 final String sValue = nameTok.nextTokenWithoutEscapeAndQuoteChars(); 128 if (sName.equals(FILTER_TYPE_IP)) 129 sFilterIP = sValue; 130 else if (sName.equals(FILTER_TYPE_USER)) 131 sFilterUserID = sValue; 132 else 133 throw new CommandValidationException(getLocalizedString("InvalidFilterName", new Object [] {sName})); 134 } else { 135 throw new CommandValidationException(getLocalizedString("InvalidFilterType", new Object [] {filterType})); 136 } 137 138 } 139 } 140 } 141 142 143 } 144 | Popular Tags |