class UserRest {

    @DELETE
    @Path("{username}")
    @RolesAllowed("user")
    @ApiOperation("Remove a Mobi user's account")
    public Response deleteUser(@Context ContainerRequestContext context,
                        @PathParam("username") String username) {
        if (StringUtils.isEmpty(username)) {
            throw ErrorUtils.sendError("Username must be provided", Response.Status.BAD_REQUEST);
        }
        isAuthorizedUser(context, username);
        try {
            Optional<User> user = engineManager.retrieveUser(username);
            if (!user.isPresent()) {
                throw ErrorUtils.sendError("User " + username + " not found", Response.Status.BAD_REQUEST);
            }
            String userIRI = user.get().getResource().stringValue();
            if (userIRI.equals(ADMIN_USER_IRI)) {
                throw ErrorUtils.sendError("The admin user cannot be deleted.", Response.Status.METHOD_NOT_ALLOWED);
            }
            engineManager.deleteUser(rdfEngine.getEngineName(), username);
            logger.info("Deleted user " + username);
            return Response.ok().build();
        } catch (IllegalArgumentException ex) {
            throw ErrorUtils.sendError(ex.getMessage(), Response.Status.BAD_REQUEST);
        }
    }

}