@Override
public synchronized void copyServerTemplate(String serverTemplateId,
String newServerTemplateId,
String newServerTemplateName) {
final ServerTemplate serverTemplate = templateStorage.load(serverTemplateId);
if (serverTemplate == null) {
throw new KieServerControllerIllegalArgumentException("No server template found for id " + serverTemplateId);
}
final Map<Capability, ServerConfig> configMap = new HashMap<Capability, ServerConfig>(serverTemplate.getConfigs().size());
for (final Map.Entry<Capability, ServerConfig> entry : serverTemplate.getConfigs().entrySet()) {
configMap.put(entry.getKey(), copy(entry.getValue()));
}
final Collection<ContainerSpec> containerSpecs = new ArrayList<ContainerSpec>(serverTemplate.getContainersSpec().size());
for (final ContainerSpec entry : serverTemplate.getContainersSpec()) {
containerSpecs.add(copy(entry, newServerTemplateId, newServerTemplateName));
}
final ServerTemplate copy = new ServerTemplate(newServerTemplateId,
newServerTemplateName,
serverTemplate.getCapabilities(),
configMap,
containerSpecs);
templateStorage.store(copy);
}