use of org.apache.nifi.registry.exception.ResourceNotFoundException in project nifi-registry by apache.
the class TenantResource method removeUser.
/**
* Removes the specified user.
*
* @param httpServletRequest request
* @param identifier The id of the user to remove.
* @return A entity containing the client id and an updated revision.
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("users/{id}")
@ApiOperation(value = "Deletes a user", notes = NON_GUARANTEED_ENDPOINT, response = User.class, extensions = { @Extension(name = "access-policy", properties = { @ExtensionProperty(name = "action", value = "delete"), @ExtensionProperty(name = "resource", value = "/tenants") }) })
@ApiResponses({ @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400), @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response removeUser(@Context final HttpServletRequest httpServletRequest, @ApiParam(value = "The user id.", required = true) @PathParam("id") final String identifier) {
verifyAuthorizerSupportsConfigurableUserGroups();
authorizeAccess(RequestAction.DELETE);
final User user = authorizationService.deleteUser(identifier);
if (user == null) {
logger.warn("The specified user id [{}] does not exist.", identifier);
throw new ResourceNotFoundException("The specified user ID does not exist in this registry.");
}
return generateOkResponse(user).build();
}
use of org.apache.nifi.registry.exception.ResourceNotFoundException in project nifi-registry by apache.
the class TenantResource method getUserGroup.
/**
* Retrieves the specified user group.
*
* @param identifier The id of the user group to retrieve
* @return An userGroupEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("user-groups/{id}")
@ApiOperation(value = "Gets a user group", notes = NON_GUARANTEED_ENDPOINT, response = UserGroup.class, extensions = { @Extension(name = "access-policy", properties = { @ExtensionProperty(name = "action", value = "read"), @ExtensionProperty(name = "resource", value = "/tenants") }) })
@ApiResponses({ @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400), @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getUserGroup(@ApiParam(value = "The user group id.", required = true) @PathParam("id") final String identifier) {
verifyAuthorizerIsManaged();
authorizeAccess(RequestAction.READ);
final UserGroup userGroup = authorizationService.getUserGroup(identifier);
if (userGroup == null) {
logger.warn("The specified user group id [{}] does not exist.", identifier);
throw new ResourceNotFoundException("The specified user group ID does not exist in this registry.");
}
return generateOkResponse(userGroup).build();
}
use of org.apache.nifi.registry.exception.ResourceNotFoundException in project nifi-registry by apache.
the class TenantResource method getUser.
/**
* Retrieves the specified user.
*
* @param identifier The id of the user to retrieve
* @return An userEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("users/{id}")
@ApiOperation(value = "Gets a user", notes = NON_GUARANTEED_ENDPOINT, response = User.class, extensions = { @Extension(name = "access-policy", properties = { @ExtensionProperty(name = "action", value = "read"), @ExtensionProperty(name = "resource", value = "/tenants") }) })
@ApiResponses({ @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400), @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401), @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403), @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404), @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getUser(@ApiParam(value = "The user id.", required = true) @PathParam("id") final String identifier) {
verifyAuthorizerIsManaged();
authorizeAccess(RequestAction.READ);
final User user = authorizationService.getUser(identifier);
if (user == null) {
logger.warn("The specified user id [{}] does not exist.", identifier);
throw new ResourceNotFoundException("The specified user ID does not exist in this registry.");
}
return generateOkResponse(user).build();
}
Aggregations