Search in sources :

Example 1 with EnvironmentStatusDTO

use of alien4cloud.rest.application.model.EnvironmentStatusDTO in project alien4cloud by alien4cloud.

the class ApplicationDeploymentController method getApplicationsStatuses.

@ApiOperation(value = "Deprecated Get the deployment status for the environements that the current user is allowed to see for a given application.", notes = "Returns the current status of an application list from the PaaS it is deployed on for all environments.")
@RequestMapping(value = "/statuses", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Deprecated
public RestResponse<Map<String, Map<String, EnvironmentStatusDTO>>> getApplicationsStatuses(@RequestBody List<String> applicationIds) {
    Map<String, Map<String, EnvironmentStatusDTO>> statuses = Maps.newHashMap();
    for (String applicationId : applicationIds) {
        Map<String, EnvironmentStatusDTO> environmentStatuses = Maps.newHashMap();
        Application application = applicationService.checkAndGetApplication(applicationId);
        // get all environments status for the current application
        ApplicationEnvironment[] environments = applicationEnvironmentService.getByApplicationId(application.getId());
        for (ApplicationEnvironment env : environments) {
            if (AuthorizationUtil.hasAuthorizationForEnvironment(application, env, ApplicationEnvironmentRole.values())) {
                DeploymentStatus status = DeploymentStatus.UNKNOWN;
                try {
                    status = applicationEnvironmentService.getStatus(env);
                } catch (Exception e) {
                    log.debug("Getting status for the environment <" + env.getId() + "> failed because the associated orchestrator seems disabled. Returned status is UNKNOWN.", e);
                }
                // TODO: include environment roles in the DTO to help display on ui
                environmentStatuses.put(env.getId(), new EnvironmentStatusDTO(env.getName(), status));
            }
        }
        statuses.put(applicationId, environmentStatuses);
    }
    return RestResponseBuilder.<Map<String, Map<String, EnvironmentStatusDTO>>>builder().data(statuses).build();
}
Also used : EnvironmentStatusDTO(alien4cloud.rest.application.model.EnvironmentStatusDTO) Map(java.util.Map) Application(alien4cloud.model.application.Application) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) DeploymentStatus(alien4cloud.paas.model.DeploymentStatus) PaaSDeploymentException(alien4cloud.paas.exception.PaaSDeploymentException) MaintenanceModeException(alien4cloud.paas.exception.MaintenanceModeException) OrchestratorDisabledException(alien4cloud.paas.exception.OrchestratorDisabledException) AlreadyExistException(alien4cloud.exception.AlreadyExistException) NotFoundException(alien4cloud.exception.NotFoundException) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AlreadyExistException (alien4cloud.exception.AlreadyExistException)1 NotFoundException (alien4cloud.exception.NotFoundException)1 Application (alien4cloud.model.application.Application)1 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)1 MaintenanceModeException (alien4cloud.paas.exception.MaintenanceModeException)1 OrchestratorDisabledException (alien4cloud.paas.exception.OrchestratorDisabledException)1 PaaSDeploymentException (alien4cloud.paas.exception.PaaSDeploymentException)1 DeploymentStatus (alien4cloud.paas.model.DeploymentStatus)1 EnvironmentStatusDTO (alien4cloud.rest.application.model.EnvironmentStatusDTO)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Map (java.util.Map)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1