}
//Ensure that a configuration with the standalone configuration name
//does not already exist.
Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);
Configs configs = domain.getConfigs();
Config newConfig = configs.getConfigByName(newConfigName);
if (newConfig != null) {
throw new ConfigException(_strMgr.getString(
"configurationAlreadyExists", newConfigName));
}
//"domain" is a restricted name
if ("domain".equals(newConfigName)) {
throw new ConfigException(_strMgr.getString(
"configurationNameRestricted", newConfigName));
}
// Ensure that the name is a valid target meaning that there are no
// servers and clusters with the same name
Servers servers = domain.getServers();
Server server = servers.getServerByName(newConfigName);
if (server != null) {
throw new ConfigException(_strMgr.getString(
"configurationNameAlreadyExistsAsServer", newConfigName));
}
Clusters clusters = domain.getClusters();
Cluster cluster = clusters.getClusterByName(newConfigName);
if (cluster != null) {
throw new ConfigException(_strMgr.getString(
"configurationNameAlreadyExistsAsCluster", newConfigName));
}
NodeAgents nas = domain.getNodeAgents();
NodeAgent na = nas.getNodeAgentByName(newConfigName);
if (na != null) {
throw new ConfigException(_strMgr.getString(
"configurationNameAlreadyExistsAsNodeAgent", newConfigName));
}
//Clone the source configuration to make the new configuration.
newConfig = (Config)sourceConfig.clone();
newConfig.setConfigContext(sourceConfig.getConfigContext());
//Add/override properties in the cloned configuration
addConfigurationProperties(newConfig, props);
//Copy the configuration directory from the central repository
EEDomainsManager mgr = new EEDomainsManager();
mgr.copyConfigururation(new RepositoryConfig(),
sourceConfigName, newConfigName);
//Set the name of the newly created standalone configuration and add it to the
//list of configurations
newConfig.setName(newConfigName);
configs.addConfig(newConfig, OVERWRITE);
try {
ConfigContext ctx = getConfigContext();
if (ctx.isChanged())
ctx.flush();
new AdminNotificationHelper(AdminService.getAdminService().getAdminContext()).sendNotification();