@DELETE @Path("/{id}") public Response deletarAnimal(@PathParam("id") int id) { Animal animal = AnimalDao.getById(id); try { AdocaoDao.deletePorAnimal(animal); AnuncioDao.deletePorAnimal(animal); AnimalDao.deleteAnimal(animal); } catch (Exception e) { String result = "Error: " + e.getMessage(); return Response.status(500).entity(result).build(); } String result = "Animal Deletado : " + animal.getNomeAdotivo(); return Response.status(200).entity(result).build(); }
@POST @Consumes("application/json") public Response criarAnimal(Animal animal) { try { AnimalDao.saveAnimal(animal); } catch (Exception e) { String result = "Error: " + e.getMessage(); return Response.status(500).entity(result).build(); } String result = "Animal Criado : " + animal.getNomeAdotivo(); return Response.status(200).entity(result).build(); }