use of alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate in project alien4cloud by alien4cloud.
the class LocationResourceService method merge.
/*
* (non-Javadoc)
*
* @see alien4cloud.orchestrators.locations.services.ILocationResourceService#merge(java.lang.Object, java.lang.String)
*/
@Override
public void merge(Object mergeRequest, String resourceId) {
AbstractLocationResourceTemplate resourceTemplate = getOrFail(resourceId);
ReflectionUtil.mergeObject(mergeRequest, resourceTemplate);
saveResource(resourceTemplate);
}
use of alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate in project alien4cloud by alien4cloud.
the class LocationResourceService method deleteResourceTemplate.
/*
* (non-Javadoc)
*
* @see alien4cloud.orchestrators.locations.services.ILocationResourceService#deleteResourceTemplate(Class, String)
*/
@Override
public void deleteResourceTemplate(String resourceId) {
AbstractLocationResourceTemplate resourceTemplate = getOrFail(resourceId);
Location location = locationService.getOrFail(resourceTemplate.getLocationId());
alienDAO.delete(resourceTemplate.getClass(), resourceId);
refreshDependencies(location);
alienDAO.save(location);
}
use of alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate in project alien4cloud by alien4cloud.
the class AbstractLocationResourcesBatchSecurityController method processRevokeForSubjectType.
private void processRevokeForSubjectType(Subject subjectType, String[] resources, String[] subjects) {
if (ArrayUtils.isEmpty(resources)) {
return;
}
Arrays.stream(resources).forEach(resourceId -> {
AbstractLocationResourceTemplate resourceTemplate = locationResourceService.getOrFail(resourceId);
resourcePermissionService.revokePermission(resourceTemplate, (resource -> locationResourceService.saveResource((AbstractLocationResourceTemplate) resource)), subjectType, subjects);
});
}
use of alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate in project alien4cloud by alien4cloud.
the class AbstractLocationResourcesSecurityController method grantAccessToUsers.
/**
*****************************************************************************************************************************
*
* SECURITY ON USERS
*
******************************************************************************************************************************
*/
/**
* Grant access to the location resoure to the user (deploy on the location)
*
* @param locationId The location's id.
* @param resourceId The location resource's id.
* @param userNames The authorized users.
* @return A {@link Void} {@link RestResponse}.
*/
@ApiOperation(value = "Grant access to the location's resource to the users, send back the new authorised users list", notes = "Only user with ADMIN role can grant access to another users.")
@RequestMapping(value = "/users", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
@Audit
public synchronized RestResponse<List<UserDTO>> grantAccessToUsers(@PathVariable String orchestratorId, @PathVariable String locationId, @PathVariable String resourceId, @RequestBody String[] userNames) {
Location location = locationService.getLocation(orchestratorId, locationId);
locationSecurityService.grantAuthorizationOnLocationIfNecessary(location, Subject.USER, userNames);
AbstractLocationResourceTemplate resourceTemplate = locationResourceService.getOrFail(resourceId);
// prefer using locationResourceService.saveResource so that the location update date is update.
// This will then trigger a deployment topology update
resourcePermissionService.grantPermission(resourceTemplate, (resource -> locationResourceService.saveResource(location, (AbstractLocationResourceTemplate) resource)), Subject.USER, userNames);
List<UserDTO> users = UserDTO.convert(resourcePermissionService.getAuthorizedUsers(resourceTemplate));
return RestResponseBuilder.<List<UserDTO>>builder().data(users).build();
}
use of alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate in project alien4cloud by alien4cloud.
the class AbstractLocationResourcesSecurityController method getAuthorizedGroups.
/**
* List all groups authorised to access the location resource.
*
* @return list of all authorised groups.
*/
@ApiOperation(value = "List all groups authorized to access the location", notes = "Only user with ADMIN role can list authorized groups to the location.")
@RequestMapping(value = "/groups", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public RestResponse<List<GroupDTO>> getAuthorizedGroups(@PathVariable String orchestratorId, @PathVariable String locationId, @PathVariable String resourceId) {
AbstractLocationResourceTemplate resourceTemplate = locationResourceService.getOrFail(resourceId);
List<GroupDTO> groups = GroupDTO.convert(resourcePermissionService.getAuthorizedGroups(resourceTemplate));
return RestResponseBuilder.<List<GroupDTO>>builder().data(groups).build();
}
Aggregations