From c2d84ae1d2125168b7f34473d97409d3cdb92ce6 Mon Sep 17 00:00:00 2001 From: Roshan Thomas Date: Fri, 15 Apr 2016 00:13:17 -0400 Subject: [PATCH] allOrders URL implementation --- .../org/baeldung/web/controller/CustomerController.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java index e103edcc19..3a14094440 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java @@ -34,7 +34,12 @@ public class CustomerController { @RequestMapping(value = "/customer/{customerId}/orders", method = RequestMethod.GET) public List getOrdersForCustomer(@PathVariable final String customerId) { - return orderService.getAllOrdersForCustomer(customerId); + final List orders = orderService.getAllOrdersForCustomer(customerId); + for (final Order order : orders) { + final Link selfLink = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(CustomerController.class).getOrderById(customerId, order.getOrderId())).withSelfRel(); + order.add(selfLink); + } + return orders; } @RequestMapping(value = "/customers", method = RequestMethod.GET)