Search in sources :

Example 1 with ApplicationVersionNotFoundException

use of alien4cloud.exception.ApplicationVersionNotFoundException in project alien4cloud by alien4cloud.

the class ApplicationEnvironmentController method getTopologyId.

@Deprecated
@ApiOperation(value = "Deprecated: Get the id of the topology linked to the environment", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ]")
@RequestMapping(value = "/{applicationEnvironmentId:.+}/topology", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<String> getTopologyId(@PathVariable String applicationId, @PathVariable String applicationEnvironmentId) {
    Application application = applicationService.getOrFail(applicationId);
    ApplicationEnvironment environment = applicationEnvironmentService.getOrFail(applicationEnvironmentId);
    AuthorizationUtil.checkAuthorizationForEnvironment(application, environment, ApplicationEnvironmentRole.values());
    String topologyId = applicationEnvironmentService.getTopologyId(applicationEnvironmentId);
    if (topologyId == null) {
        throw new ApplicationVersionNotFoundException("An application version is required by an application environment.");
    }
    return RestResponseBuilder.<String>builder().data(topologyId).build();
}
Also used : ApplicationVersionNotFoundException(alien4cloud.exception.ApplicationVersionNotFoundException) Application(alien4cloud.model.application.Application) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

ApplicationVersionNotFoundException (alien4cloud.exception.ApplicationVersionNotFoundException)1 Application (alien4cloud.model.application.Application)1 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)1 ApiOperation (io.swagger.annotations.ApiOperation)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1