@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("wines") public Wine saveWine(Wine wine) throws BusinessException { if (wine.getId() == null) { return wineServiceFacade.saveWine(wine); } throw new RuntimeException(); }
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("wines/{id}") public Wine saveWine(@PathParam("id") int id, Wine wine) throws BusinessException { if ((id == wine.getId()) && (wineServiceFacade.getWineById(id) != null)) { return wineServiceFacade.saveWine(wine); } throw new RuntimeException(); }