use of org.alien4cloud.alm.events.BeforeApplicationTopologyVersionDeleted in project alien4cloud by alien4cloud.
the class ApplicationVersionService method deleteVersion.
private void deleteVersion(ApplicationVersion version) {
// Call delete archive
for (Map.Entry<String, ApplicationTopologyVersion> topologyVersionEntry : version.getTopologyVersions().entrySet()) {
publisher.publishEvent(new BeforeApplicationTopologyVersionDeleted(this, version.getApplicationId(), version.getId(), topologyVersionEntry.getKey()));
csarService.deleteCsar(topologyVersionEntry.getValue().getArchiveId());
}
publisher.publishEvent(new BeforeApplicationVersionDeleted(this, version.getApplicationId(), version.getId()));
alienDAO.delete(ApplicationVersion.class, version.getId());
publisher.publishEvent(new AfterApplicationVersionDeleted(this, version.getApplicationId(), version.getId()));
for (Map.Entry<String, ApplicationTopologyVersion> topologyVersionEntry : version.getTopologyVersions().entrySet()) {
publisher.publishEvent(new AfterApplicationTopologyVersionDeleted(this, version.getApplicationId(), version.getId(), topologyVersionEntry.getKey()));
}
}
use of org.alien4cloud.alm.events.BeforeApplicationTopologyVersionDeleted in project alien4cloud by alien4cloud.
the class ApplicationVersionService method deleteTopologyVersion.
/**
* Delete an Application Topology version from a given application version.
*
* @param applicationId The application Id.
* @param versionId The version id of the application version.
* @param topologyVersion The version (not archive id) of the topology version.
*/
public void deleteTopologyVersion(String applicationId, String versionId, String topologyVersion) {
ApplicationVersion applicationVersion = getOrFail(versionId);
ApplicationTopologyVersion applicationTopologyVersion = applicationVersion.getTopologyVersions().get(topologyVersion);
if (applicationTopologyVersion == null) {
throw new NotFoundException("Topology version [" + topologyVersion + "] does not exist in the application version [" + versionId + "] for application [" + applicationId + "]");
}
if (applicationVersion.getTopologyVersions().size() == 1) {
throw new DeleteLastApplicationVersionException("Application topology version [" + topologyVersion + "] for application version [" + versionId + "] can't be be deleted as it is the last topology version for this application version.");
}
ApplicationEnvironment usage = findAnyApplicationTopologyVersionUsage(applicationId, topologyVersion);
if (usage != null) {
throw new DeleteReferencedObjectException("Application topology version with id [" + topologyVersion + "] could not be deleted as it is used by environment [" + usage.getName() + "]");
}
ApplicationTopologyVersion deleted = applicationVersion.getTopologyVersions().remove(topologyVersion);
publisher.publishEvent(new BeforeApplicationTopologyVersionDeleted(this, applicationVersion.getApplicationId(), applicationVersion.getId(), topologyVersion));
csarService.deleteCsar(deleted.getArchiveId());
alienDAO.save(applicationVersion);
publisher.publishEvent(new AfterApplicationTopologyVersionDeleted(this, applicationVersion.getApplicationId(), applicationVersion.getId(), topologyVersion));
}
Aggregations