An abstract method that Executes the command
validateOptions();
try
{
MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(),
getUser(), getPassword());
DomainRoot domainRoot = ProxyFactory.getInstance(mbsc).getDomainRoot();
//final Set s = domainRoot.getQueryMgr().queryJ2EETypeSet(XTypes.WEB_SERVICE_ENDPOINT_CONFIG);
String webServiceName = getOption(WEB_SERVICE_OPTION);
validateWebServiceName(webServiceName, true);
WebServiceEndpointConfig wsc =
getWebServiceEndpointConfig(mbsc, webServiceName, true);
if (wsc == null)
throw new CommandException(getLocalizedString("CannotFindWebservice"));
String ruleName = (String) getOperands().get(0);
String ruleLocation = getOption(RULE_LOCATION_OPTION);
boolean enabled = getBooleanOption(ENABLED_OPTION);
String applyTo = getOption(APPLY_TO_OPTION);
// please remember the file needs to uploaded to the location mentioned, then only
// transformation rule can be active.
File ruleFile = new File(ruleLocation);
String msg = null;
if (! ruleFile.exists())
msg = getLocalizedString("FileDoesNotExist", new Object[] {ruleLocation});
else if(ruleFile.length() <= 0)
msg = getLocalizedString("FileIsEmpty", new Object[] {ruleLocation});
else if(! ruleFile.canRead())
msg = getLocalizedString("FileNotReadable", new Object[] {ruleLocation});
if(msg != null)
throw new CommandValidationException(msg);
String remoteLocation = uploadFileToServer(mbsc);
//File uploadedFile = uploadFile(domainRoot, ruleLocation);
CLILogger.getInstance().printDebugMessage("uploadedFile = " +
remoteLocation);
wsc.createTransformationRuleConfig(ruleName,
remoteLocation, enabled, applyTo, null);
CLILogger.getInstance().printDetailMessage(getLocalizedString(
"CommandSuccessful",
new Object[] {name}));
}
catch(Exception e)
{
displayExceptionMessage(e);
}