use of alien4cloud.exception.MissingCSARDependenciesException in project alien4cloud by alien4cloud.
the class LocationService method createLocation.
private void createLocation(Orchestrator orchestrator, Location location, String infrastructureType) {
ensureNameUnicityAndSave(location);
// TODO checks that the infrastructure type is valid
location.setInfrastructureType(infrastructureType);
// TODO add User and Group managed by the Orchestrator security
Set<CSARDependency> dependencies = locationArchiveIndexer.indexLocationArchives(orchestrator, location);
location.setDependencies(dependencies);
// initialize meta properties
location.setMetaProperties(Maps.<String, String>newHashMap());
// add existing meta properties to the cloud
GetMultipleDataResult<MetaPropConfiguration> result = alienDAO.find(MetaPropConfiguration.class, singleKeyFilter("target", MetaPropertyTarget.LOCATION), Integer.MAX_VALUE);
for (MetaPropConfiguration element : result.getData()) {
if (Objects.equals(element.getTarget(), MetaPropertyTarget.LOCATION)) {
// we only support string values for meta properties
PropertyUtil.setScalarDefaultValueOrNull(location.getMetaProperties(), element.getId(), element.getDefault());
log.debug("Added meta property [ {} ] to the new location [ {} ] ", element.getName(), location.getName());
}
}
// save the new location
alienDAO.save(location);
try {
autoConfigure(orchestrator, location);
} catch (UnsupportedOperationException e) {
// do nothing
}
// We call the LocationRessourceService to check the dependencies
try {
locationResourceService.getLocationResourcesFromOrchestrator(location);
} catch (NotFoundException e) {
// WARN: FIXME we load orch twice !!!!!!!!!!!!!!!!!!!!!!!!!
delete(orchestrator.getId(), location.getId());
throw new MissingCSARDependenciesException(e.getMessage());
}
}
Aggregations