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 35 public class DeleteTransformationRuleCommand extends BaseTransformationRuleCommand 36 { 37 private static final String WEB_SERVICE_OPTION = "webservicename"; 38 39 43 public void runCommand() throws CommandException, CommandValidationException 44 { 45 validateOptions(); 46 try 47 { 48 MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 49 getUser(), getPassword()); 50 String webServiceName = getOption(WEB_SERVICE_OPTION); 53 validateWebServiceName(webServiceName, true); 54 WebServiceEndpointConfig wsc = 55 getWebServiceEndpointConfig(mbsc, webServiceName, false); 56 if (wsc == null) 57 throw new CommandException(getLocalizedString("CannotFindWebservice")); 58 String ruleName = (String ) getOperands().get(0); 59 60 wsc.removeTransformationRuleConfig(ruleName); 61 62 CLILogger.getInstance().printDetailMessage(getLocalizedString( 63 "CommandSuccessful", 64 new Object [] {name})); 65 } 66 catch(Exception e) 67 { 68 displayExceptionMessage(e); 69 } 70 71 } 72 73 74 79 private WebServiceEndpointConfig getWebServiceEndpointConfig(Set s) throws CommandException 80 { 81 String fqWebServiceName = getOption(WEB_SERVICE_OPTION); 83 int firstHashIdx = fqWebServiceName.indexOf("#"); 85 String wsName= null; 86 if ( firstHashIdx != -1 ) { 87 if ( firstHashIdx+1 == fqWebServiceName.length()) { 88 throw new CommandException(getLocalizedString("InvalidFormatForWebservice")); 90 } 91 wsName = fqWebServiceName.substring(firstHashIdx +1); 92 } 93 else 94 { 95 throw new CommandException(getLocalizedString("InvalidFormatForWebservice")); 96 } 97 final Iterator iter = s.iterator(); 98 while (iter.hasNext() ) 99 { 100 final WebServiceEndpointConfig wsc = (WebServiceEndpointConfig)iter.next(); 101 CLILogger.getInstance().printDebugMessage(wsc.getName()); 102 if (wsc.getName().equals(wsName)) 103 { 104 return wsc; 105 } 106 } 107 return null; 108 } 109 } 110 | Popular Tags |