use of org.alien4cloud.alm.events.AfterApplicationDeleted in project alien4cloud by alien4cloud.
the class ApplicationService method delete.
/**
* Delete an existing application from it's id. This method ensures first that there is no running deployment of the application.
*
* @param applicationId The id of the application to remove.
* @return True if the application has been removed, false if not.
*/
public boolean delete(String applicationId) {
// Removal of a deployed application is not authorized
if (alienDAO.count(Deployment.class, null, fromKeyValueCouples("sourceId", applicationId, "endDate", null)) > 0) {
return false;
}
// Ensure that application related resources can be removed.
Application application = getOrFail(applicationId);
DeleteApplicationVersions deleteApplicationVersions = applicationVersionService.prepareDeleteByApplication(applicationId);
DeleteApplicationEnvironments deleteApplicationEnvironments = applicationEnvironmentService.prepareDeleteByApplication(applicationId);
// Delete the application.
deleteApplicationVersions.delete();
deleteApplicationEnvironments.delete();
publisher.publishEvent(new BeforeApplicationDeleted(this, applicationId));
alienDAO.delete(Application.class, applicationId);
if (application != null && StringUtils.isNotBlank(application.getImageId())) {
imageDAO.deleteAll(application.getImageId());
}
publisher.publishEvent(new AfterApplicationDeleted(this, applicationId));
return true;
}
Aggregations