use of alien4cloud.orchestrators.locations.events.BeforeLocationDeleted in project alien4cloud by alien4cloud.
the class LocationService method delete.
/**
* Delete a locations.
*
* @param id id of the locations to delete.
* @return true if the location was successfully , false if not.
*/
public synchronized boolean delete(String orchestratorId, String id) {
Orchestrator orchestrator = orchestratorService.getOrFail(orchestratorId);
if (alienDAO.count(Deployment.class, null, fromKeyValueCouples("orchestratorId", orchestratorId, "locationIds", id, "endDate", null)) > 0) {
return false;
}
Location location = getOrFail(id);
publisher.publishEvent(new BeforeLocationDeleted(this, location.getId()));
// delete all location resources for the given location
alienDAO.delete(LocationResourceTemplate.class, QueryBuilders.termQuery("locationId", id));
// delete the location
alienDAO.delete(Location.class, id);
// delete all archives associated with this location only, if possible of course
Map<Csar, List<Usage>> usages = locationArchiveIndexer.deleteArchives(orchestrator, location);
if (MapUtils.isNotEmpty(usages)) {
// TODO what to do when some archives were not deleted?
log.warn("Some archives for location were not deleted! \n" + usages);
}
publisher.publishEvent(new AfterLocationDeleted(this, location.getId()));
return true;
}
Aggregations