Search in sources :

Example 1 with DeleteApplicationVersions

use of alien4cloud.application.ApplicationVersionService.DeleteApplicationVersions 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;
}
Also used : DeleteApplicationEnvironments(alien4cloud.application.ApplicationEnvironmentService.DeleteApplicationEnvironments) BeforeApplicationDeleted(org.alien4cloud.alm.events.BeforeApplicationDeleted) DeleteApplicationVersions(alien4cloud.application.ApplicationVersionService.DeleteApplicationVersions) Deployment(alien4cloud.model.deployment.Deployment) AfterApplicationDeleted(org.alien4cloud.alm.events.AfterApplicationDeleted) Application(alien4cloud.model.application.Application)

Aggregations

DeleteApplicationEnvironments (alien4cloud.application.ApplicationEnvironmentService.DeleteApplicationEnvironments)1 DeleteApplicationVersions (alien4cloud.application.ApplicationVersionService.DeleteApplicationVersions)1 Application (alien4cloud.model.application.Application)1 Deployment (alien4cloud.model.deployment.Deployment)1 AfterApplicationDeleted (org.alien4cloud.alm.events.AfterApplicationDeleted)1 BeforeApplicationDeleted (org.alien4cloud.alm.events.BeforeApplicationDeleted)1