1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 import javax.management.MBeanServerConnection ; 28 import com.sun.appserv.management.client.ProxyFactory; 29 import com.sun.appserv.management.DomainRoot; 30 import com.sun.appserv.management.base.XTypes; 31 import com.sun.appserv.management.config.WebServiceEndpointConfig; 32 import java.util.Iterator ; 33 import java.util.Set ; 34 import java.util.Map ; 35 36 public class ListTransformationRulesCommand extends BaseTransformationRuleCommand 37 { 38 private static final String WEB_SERVICE_OPTION = "webservicename"; 39 40 44 public void runCommand() throws CommandException, CommandValidationException 45 { 46 validateOptions(); 47 try 48 { 49 MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 50 getUser(), getPassword()); 51 String webServiceName = getOption(WEB_SERVICE_OPTION); 54 validateWebServiceName(webServiceName, false); 55 boolean nothingToList = listTransformationRules(mbsc); 56 if (nothingToList) 57 { 58 CLILogger.getInstance().printMessage(getLocalizedString("NoElementsToList")); 59 } 60 CLILogger.getInstance().printDetailMessage(getLocalizedString( 61 "CommandSuccessful", 62 new Object [] {name})); 63 } 64 catch(Exception e) 65 { 66 displayExceptionMessage(e); 67 } 68 69 } 70 71 72 76 private boolean listTransformationRules(MBeanServerConnection mbsc) 77 throws CommandException, CommandValidationException 78 { 79 String webServiceName = getOption(WEB_SERVICE_OPTION); 80 if (webServiceName != null) 81 { 82 WebServiceEndpointConfig wsc = 83 getWebServiceEndpointConfig(mbsc, webServiceName, false); 84 if (wsc == null) 85 throw new CommandException(getLocalizedString("CannotFindWebservice")); 86 return displayTransformationRules(wsc); 87 } 88 DomainRoot domainRoot = ProxyFactory.getInstance(mbsc).getDomainRoot(); 89 final Set s = domainRoot.getQueryMgr().queryJ2EETypeSet(XTypes.WEB_SERVICE_ENDPOINT_CONFIG); 90 final Iterator iter = s.iterator(); 91 boolean nothingToList = true; 92 while (iter.hasNext() ) 93 { 94 final WebServiceEndpointConfig wsc = (WebServiceEndpointConfig)iter.next(); 95 if (wsc.getTransformationRuleConfigMap().size() > 0) 96 { 97 CLILogger.getInstance().printMessage(wsc.getName()); 98 nothingToList = displayTransformationRules(wsc); 99 } 100 } 101 return nothingToList; 102 } 103 104 105 109 private boolean displayTransformationRules(WebServiceEndpointConfig wsc) 110 throws CommandException 111 { 112 Map rules = wsc.getTransformationRuleConfigMap(); 113 for (Object key : rules.keySet()) 114 { 115 CLILogger.getInstance().printMessage((String )key); 116 } 117 if (rules.size() > 0) 118 return false; 119 else 120 return true; 121 } 122 } 123 | Popular Tags |