@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("producers") public Producer saveProducer(Producer producer) throws BusinessException { if (producer.getId() == null) { return wineServiceFacade.saveProducer(producer); } throw new RuntimeException(); }
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("producers/{id}") public Producer saveProducer(@PathParam("id") int id, Producer producer) throws BusinessException { if ((id == producer.getId()) && (wineServiceFacade.getProducerById(id) != null)) { return wineServiceFacade.saveProducer(producer); } throw new RuntimeException(); }