@GET @Path("/{id}/delete") public Response deleteShirt(@PathParam("id") String id, @Context SecurityContext securityContext) throws Exception { final Shirt toDelete = shirtDatastore.get(id); return Response.ok(new DeletePage(toDelete, securityContext, userService).build()).build(); }
@GET @Path("/{id}/edit") public Response editShirt(@PathParam("id") String id, @Context SecurityContext securityContext) throws Exception { final Shirt shirt = shirtDatastore.get(id); if (shirt == null) { throw new NotFoundException("No shirt found for ID: " + id); } return Response.ok(new EditPage(shirt, securityContext, userService).build()).build(); }
@GET public Response index(@Context SecurityContext securityContext) throws Exception { return Response.ok( new IndexPage( new ShirtIndexPageEntityDescriptor(shirtDatastore.getAll()), securityContext, userService) .build()) .build(); }
@POST @Path("/{id}/edit") public Response editShirt(@PathParam("id") String id, @BeanParam ShirtFormData shirtData) throws Exception { final Shirt toUpdate = new Shirt(shirtData.getName()); toUpdate.setId(id); toUpdate.setCount(shirtData.getCount()); toUpdate.setCut(shirtData.getCut()); toUpdate.setSize(shirtData.getSize()); shirtDatastore.update(toUpdate); return Response.status(Response.Status.FOUND).location(INDEX_URI).build(); }
@POST @Path("/add") public Response addShirt( @BeanParam ShirtFormData shirtFormData, @Context SecurityContext securityContext) throws Exception { final Shirt shirt = new Shirt(shirtFormData.getName()); shirt.setCount(shirtFormData.getCount()); shirt.setCut(shirtFormData.getCut()); shirt.setSize(shirtFormData.getSize()); shirtDatastore.add(shirt); return Response.status(Response.Status.FOUND).location(INDEX_URI).build(); }
@POST @Path("/{id}/delete") public Response deleteShirt(@PathParam("id") String id) throws Exception { shirtDatastore.delete(id); return Response.status(Response.Status.FOUND).location(INDEX_URI).build(); }