use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class IdmIdentityController method getProfilePermissions.
/**
* Returns profile permissions
*
* @return
* @since 9.0.0
*/
@ResponseBody
@RequestMapping(value = "/{backendId}/profile/permissions", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.PROFILE_READ + "')" + " or hasAuthority('" + CoreGroupPermission.PROFILE_AUTOCOMPLETE + "')")
@ApiOperation(value = "What logged identity can do with identity profile", nickname = "getPermissionsOnIdentityProfile", tags = { IdmIdentityController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_READ, description = ""), @AuthorizationScope(scope = CoreGroupPermission.PROFILE_AUTOCOMPLETE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_READ, description = ""), @AuthorizationScope(scope = CoreGroupPermission.PROFILE_AUTOCOMPLETE, description = "") }) })
public Set<String> getProfilePermissions(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable @NotNull String backendId) {
IdmProfileDto profile = profileService.findOneByIdentity(backendId);
if (profile == null) {
IdmIdentityDto identity = (IdmIdentityDto) getLookupService().lookupDto(IdmIdentityDto.class, backendId);
if (identity == null) {
throw new EntityNotFoundException(IdmIdentity.class, backendId);
}
profile = new IdmProfileDto();
profile.setIdentity(identity.getId());
}
// profile can be null (create)
return profileController.getService().getPermissions(profile);
}
use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class IdmRoleRequestController method delete.
@Override
@ResponseBody
@RequestMapping(value = "/{backendId}", method = RequestMethod.DELETE)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLE_REQUEST_DELETE + "')")
@ApiOperation(value = "Delete role request", nickname = "deleteRoleRequest", tags = { IdmRoleRequestController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_DELETE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_DELETE, description = "") }) })
public ResponseEntity<?> delete(@ApiParam(value = "Role request's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
IdmRoleRequestDto dto = getDto(backendId);
if (dto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
checkAccess(dto, IdmBasePermission.DELETE);
IdmBulkActionDto deleteAction = getAvailableBulkActions().stream().filter(action -> {
return RoleRequestDeleteBulkAction.NAME.equals(action.getName());
}).findFirst().get();
deleteAction.setIdentifiers(Set.of(dto.getId()));
bulkAction(deleteAction);
return new ResponseEntity<Object>(HttpStatus.NO_CONTENT);
}
use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class DefaultLongRunningTaskManager method processCreated.
@Override
@Transactional
public LongRunningFutureTask<?> processCreated(UUID longRunningTaskId) {
LOG.debug("Processing created task [{}] from long running task queue", longRunningTaskId);
//
IdmLongRunningTaskDto task = service.get(longRunningTaskId);
if (task == null) {
throw new EntityNotFoundException(IdmLongRunningTask.class, longRunningTaskId);
}
// task cannot be started twice
if (task.isRunning() || OperationState.RUNNING == task.getResultState()) {
throw new ResultCodeException(CoreResultCode.LONG_RUNNING_TASK_IS_RUNNING, ImmutableMap.of("taskId", task.getId()));
}
if (OperationState.CREATED != task.getResultState()) {
throw new ResultCodeException(CoreResultCode.LONG_RUNNING_TASK_IS_PROCESSED, ImmutableMap.of("taskId", task.getId()));
}
//
LongRunningTaskExecutor<?> taskExecutor = createTaskExecutor(task);
if (taskExecutor == null) {
return null;
}
return execute(taskExecutor);
}
use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class IdmIdentityProjectionController method get.
@ResponseBody
@RequestMapping(value = "/{backendId}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.IDENTITY_READ + "')")
@ApiOperation(value = "Identity projection detail", nickname = "getIdentityProjection", response = IdmIdentityProjectionDto.class, tags = { IdmIdentityProjectionController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITY_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITY_READ, description = "") }) })
public ResponseEntity<?> get(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable @NotNull String backendId) {
IdmIdentityProjectionDto dto = getDto(backendId);
if (dto == null) {
throw new EntityNotFoundException(identityService.getEntityClass(), backendId);
}
ResourceSupport resource = toResource(dto);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
//
return new ResponseEntity<>(resource, HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException in project CzechIdMng by bcvsolutions.
the class IdmLongRunningTaskController method downloadResult.
@ResponseBody
@RequestMapping(value = "/{backendId}/download/{attachmentId}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.SCHEDULER_READ + "')")
@ApiOperation(value = "Download result from LRT", nickname = "downloadReslut", response = IdmLongRunningTaskDto.class, tags = { IdmLongRunningTaskController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.SCHEDULER_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.SCHEDULER_READ, description = "") }) })
public ResponseEntity<?> downloadResult(@ApiParam(value = "LRT's uuid identifier.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Attachment's id.", required = true) @PathVariable @NotNull String attachmentId) {
// check if user has permission for read the long running task
IdmLongRunningTaskDto longRunningTaskDto = getDto(backendId);
if (longRunningTaskDto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
//
IdmAttachmentDto attachment = longRunningTaskManager.getAttachment(longRunningTaskDto.getId(), DtoUtils.toUuid(attachmentId), IdmBasePermission.READ);
InputStream is = attachmentManager.getAttachmentData(attachment.getId(), IdmBasePermission.READ);
String attachmentName = attachment.getName();
//
return ResponseEntity.ok().contentLength(attachment.getFilesize()).contentType(MediaType.parseMediaType(attachment.getMimetype())).header(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=\"%s\"", attachmentName)).body(new InputStreamResource(is));
}
Aggregations