class RestRules {

    @DELETE
    @Path("/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response remove(@PathParam("id") String id) {
        RestListener listener = RestManager.getListener();
        Response response;

        // Check if the listener accepted the operation
        try {
            log.info("Remove request with id: {}", id);
            listener.remove(id);
            response = Response.ok().build();
        } catch (RestNotFoundException e) {
            log.info("Remove request invalid: {}", e.getMessage());
            e.printStackTrace();
            response = Response.status(Response.Status.NOT_FOUND)
                    .entity(toMap(e, Response.Status.NOT_FOUND))
                    .build();
        } catch (Exception e) {
            e.printStackTrace();
            response = Response.serverError()
                    .entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
                    .build();
        }

        return response;
    }

}