String msg = resBundle.getString("InvalidNumber");
throw new IllegalArgumentException(msg);
}
try {
DeployedItemRefConfig dRef = null;
// disables cluster if target is a cluster
if (isCluster(target)) {
//get the clusterConfig for this cluster
Map<String,ClusterConfig> clusterConfigs = mDomainConfig.getClusterConfigMap();
ClusterConfig clusterConfig = clusterConfigs.get(target);
//get the deployed item object corresponding to the given appName
dRef = clusterConfig.getDeployedItemRefConfigMap().get(appName);
} else { // target is a server
//get the standalone serverConfig
Map<String,StandaloneServerConfig> ssConfigMap =
mDomainConfig.getStandaloneServerConfigMap();
StandaloneServerConfig ssc = ssConfigMap.get(target);
if (ssc == null) {
//get the clustered server config
ClusteredServerConfig s = mDomainConfig.getClusteredServerConfigMap().get(target);
//get the deployed item object corresponding to the given appName
dRef = s.getDeployedItemRefConfigMap().get(appName);
}else{
//get the deployed item object corresponding to the given appName
dRef = ssc.getDeployedItemRefConfigMap().get(appName);
}
}
if (dRef == null) {
mLogger.log(Level.FINEST," server " + target +
" does not exist in any cluster in the domain");
String msg = formatter.format(resBundle.getString("AppRefNotDefined"),
target);
throw new MBeanException(new RuntimeException(msg));
}
int curTout = Integer.parseInt(
dRef.getDisableTimeoutInMinutes());
//check if the app is already in the state desired
boolean enabled = dRef.getLBEnabled();
if(!status){
if ((enabled == false) && (curTout == timeout)) {
String msg = resBundle.getString("AppDisabledOnServer"
);
throw new MBeanException(new Exception(msg));
}
//set the disable timeout
dRef.setDisableTimeoutInMinutes( "" + timeout );
//disable the app
dRef.setLBEnabled(false);
mLogger.log(Level.INFO,resBundle.getString(
"http_lb_admin.ApplicationDisabled"));
}else{
if (enabled == true) {
String msg = resBundle.getString("AppEnabledOnServer"
);
throw new MBeanException(new Exception(msg));
}
//enable the app
dRef.setLBEnabled(true);
mLogger.log(Level.INFO,resBundle.getString(
"http_lb_admin.ApplicationEnabled"));
}
} catch(Exception ce) {
throw new RuntimeException(ce);