Ejemplo n.º 1
0
 @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();
 }
Ejemplo n.º 2
0
 @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();
 }