@Path("{username}")
@RequiresPermissions(USERS_EDIT)
@ApiOperation("Removes a user account.")
@ApiResponses({@ApiResponse(code = 400, message = "When attempting to remove a read only user (e.g. built-in or LDAP user).")})
public Response deleteUser(@ApiParam(name = "username", value = "The name of the user to delete.", required = true) @PathParam("username") String username) {
final User user = userService.load(username);
if (user == null) {
return status(NOT_FOUND).build();
}
if (user.isReadOnly()) {
throw new BadRequestException("Cannot delete readonly user " + username);
}
userService.destroy(user);
return Response.noContent().build();