@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("regions") public Region saveRegion(Region region) throws BusinessException { if (region.getId() == null) { return wineServiceFacade.saveRegion(region); } throw new RuntimeException(); }
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("regions/{id}") public Region saveRegion(@PathParam("id") int id, Region region) throws BusinessException { if ((id == region.getId()) && (wineServiceFacade.getRegionById(id) != null)) { return wineServiceFacade.saveRegion(region); } throw new RuntimeException(); }