ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
AccessController.checkAccess(context.getServiceContext(), ACL_ADD_MBEAN_CONFIG);
MBeanConfigForm mbeanConfigForm = (MBeanConfigForm)actionForm;
ApplicationConfig applicationConfig = context.getApplicationConfig();
if(mbeanConfigForm.isApplicationCluster()){
/* mbean has to be added to the cluster */
applicationConfig = applicationConfig.getClusterConfig();
assert applicationConfig != null: "application not part of cluster";
}
String logMsg = null;
//TODO: Usage of DynaForm should clean up this.
if(request.getParameter(RequestParams.MULTI_MBEAN_CONFIG) != null){
final String[] objectNames = mbeanConfigForm.getName();
for(int mbeanCtr=0; mbeanCtr < objectNames.length; mbeanCtr++ ){
final String configName = request.getParameter(objectNames[mbeanCtr]);
if(GenericValidator.isBlankOrNull(configName) ||
applicationConfig.containsMBean(objectNames[mbeanCtr]))
continue;
applicationConfig.addMBean(new MBeanConfig(configName,
objectNames[mbeanCtr]));
ApplicationConfigManager.updateApplication(applicationConfig);
if(mbeanConfigForm.isApplicationCluster()){
logMsg = "Added "+objectNames[mbeanCtr]+" to " +
"application cluster " + applicationConfig.getName();
}else{
logMsg = "Added "+objectNames[mbeanCtr]+" to " +
"application " + applicationConfig.getName();
}
logMsg += "\n";
}
}else{
final String configName = mbeanConfigForm.getName()[0];
applicationConfig.addMBean(new MBeanConfig(configName,
mbeanConfigForm.getObjectName()));
ApplicationConfigManager.updateApplication(applicationConfig);
if(mbeanConfigForm.isApplicationCluster()){
logMsg = "Added "+mbeanConfigForm.getObjectName()+" to " +
"application cluster " + applicationConfig.getName();
}else{
logMsg = "Added "+mbeanConfigForm.getObjectName()+" to " +
"application " + applicationConfig.getName();
}
}
UserActivityLogger.getInstance().logActivity(
context.getUser().getUsername(),