@DELETE @Path("/{id}") public Response removeUsuario(@PathParam("id") Long usuarioId) { try { usuarioService.removeUsuario(usuarioId); } catch (Exception e) { return Response.status(Status.CONFLICT).build(); } return Response.noContent().build(); }
@POST @Consumes(MediaType.APPLICATION_JSON) public Response addUsuario(Usuario usuario) { try { usuarioService.addUsuario(usuario); } catch (Exception e) { return Response.status(Status.CONFLICT).build(); } return Response.ok(usuario).build(); }
@PUT @Path("/{id}") @Consumes(MediaType.APPLICATION_JSON) public Response updateUsuario(@PathParam("id") Long usuarioId, Usuario usuario) { try { usuarioService.updateUsuario(usuarioId, usuario); } catch (Exception e) { return Response.status(Status.CONFLICT).build(); } return Response.status(Status.OK).entity(usuario).build(); }
@GET @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) public Response getUsuario(@PathParam("id") Long idUsuario) { return Response.ok(usuarioService.getUsuario(idUsuario)).build(); }
@GET @Produces(MediaType.APPLICATION_JSON) public Response getUsuarios() { return Response.ok(usuarioService.getUsuarios()).build(); }