class RestRules {

    @POST
    @Path("/synchronize")
    @Consumes (MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response synchronize(String json) {
        RestListener listener = RestManager.getListener();
        Response response;

        try {
            log.info("Synchronize request with json: {}", json);
            listener.synchronize(parseList(json));
            response = Response.ok().build();
        } catch (RestInvalidException e) {
            log.info("Synchronize request was invalid: {}", e.getMessage());
            e.printStackTrace();
            response = Response.status(Response.Status.BAD_REQUEST)
                    .entity(toMap(e, Response.Status.BAD_REQUEST))
                    .build();
        } catch (Exception e) {
            e.printStackTrace();
            response = Response.serverError()
                    .entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
                    .build();
        }

        return response;
    }

}