@DELETE @Path("/{id:[0-9][0-9]*}") public Response deleteById(@PathParam("id") int id) { LCD entity = dao.find(id); if (entity == null) { return Response.status(Status.NOT_FOUND).build(); } dao.remove(entity); return Response.noContent().build(); }
@GET @Path("/{id:[0-9][0-9]*}") @Produces("application/json") public Response findById(@PathParam("id") int id) { LCD entity; try { entity = dao.find(id); } catch (NoResultException nre) { entity = null; } if (entity == null) { return Response.status(Status.NOT_FOUND).build(); } return Response.ok(entity).build(); }
@PUT @Path("/{id:[0-9][0-9]*}") @Consumes("application/json") public Response update(@PathParam("id") int id, LCD entity) { if (entity == null) { return Response.status(Status.BAD_REQUEST).build(); } if (id != entity.getBarkod()) { return Response.status(Status.CONFLICT).entity(entity).build(); } if (dao.find(id) == null) { return Response.status(Status.NOT_FOUND).build(); } try { entity = dao.merge(entity); } catch (OptimisticLockException e) { return Response.status(Response.Status.CONFLICT).entity(e.getEntity()).build(); } return Response.noContent().build(); }