use of alien4cloud.model.application.Application 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();
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationEnvironmentController method getApplicationEnvironment.
/**
* Get application environment from its id
*
* @param applicationId The application id
* @param applicationEnvironmentId the environment for which to get the status
* @return A {@link RestResponse} that contains the application environment {@link ApplicationEnvironment}.
*/
@ApiOperation(value = "Get an application environment from its id", notes = "Returns the application environment. Roles required: Application environment [ APPLICATION_USER | DEPLOYMENT_MANAGER ], or application [APPLICATION_MANAGER]")
@RequestMapping(value = "/{applicationEnvironmentId:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<ApplicationEnvironmentDTO> getApplicationEnvironment(@PathVariable String applicationId, @PathVariable String applicationEnvironmentId) {
Application application = applicationService.checkAndGetApplication(applicationId);
ApplicationEnvironment environment = applicationEnvironmentService.getOrFail(applicationEnvironmentId);
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment, ApplicationEnvironmentRole.values());
return RestResponseBuilder.<ApplicationEnvironmentDTO>builder().data(dtoBuilder.getApplicationEnvironmentDTO(environment)).build();
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationEnvironmentGitController method checkEnvironmentAuthorization.
private void checkEnvironmentAuthorization(String applicationId, String environmentId) {
ApplicationEnvironment environment = environmentService.getOrFail(environmentId);
if (!environment.getApplicationId().equals(applicationId)) {
throw new NotFoundException("Cannot find environement <" + environmentId + "> for application <" + applicationId + ">.");
}
Application application = applicationService.getOrFail(applicationId);
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationEnvironmentRolesController method handleRemoveGrpRoleOnApplication.
/**
* Handle group roles on the targeted application
*
* @param applicationId
* @param groupId
*/
private void handleRemoveGrpRoleOnApplication(String applicationId, String groupId) {
Application application = applicationService.getOrFail(applicationId);
// Check if group has at least one role on the application or the environments
Set<String> applicationRoles = application.getGroupRoles() != null ? application.getGroupRoles().get(groupId) : new HashSet<>();
List<Set<String>> environmentRoles = Arrays.stream(applicationEnvironmentService.getByApplicationId(applicationId)).map(applicationEnvironment -> applicationEnvironment.getGroupRoles() != null ? applicationEnvironment.getGroupRoles().get(groupId) : null).filter(roles -> roles != null).collect(Collectors.toList());
if (mustRemoveApplicationUserRole(applicationRoles, environmentRoles)) {
// If we are here, it means that we must take out the APPLICATION_USER role for application as group does not have any other role than that
resourceRoleService.removeGroupRole(application, groupId, ApplicationRole.APPLICATION_USER.toString());
}
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationEnvironmentRolesController method handleAddUserRoleOnApplication.
/**
* Handle user roles on the targeted application
* Any role on an environment implies APPLICATION_USER role on the linked application
*
* @param applicationId
* @param username
*/
private void handleAddUserRoleOnApplication(String applicationId, String username) {
Application application = applicationService.getOrFail(applicationId);
resourceRoleService.addUserRole(application, username, ApplicationRole.APPLICATION_USER.toString());
}
Aggregations