Page 1 of 1

How to implement the CustomerEndpoint in version 4

Posted: Fri Aug 14, 2015 3:40 am
by diptangshu
The Rest endpoints for the demosite are working.
I have implemented the CustomerEndpoint like this.

Code: Select all

@RestController
@RequestMapping(value ="/customer/",
      produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE},
      consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
public class CustomerEndpoint extends
      org.broadleafcommerce.core.web.api.endpoint.customer.CustomerEndpoint {

   @RequestMapping(value = "search", method = RequestMethod.GET)
   public CustomerWrapper findCustomerByEmail(HttpServletRequest request, @RequestParam("email") String emailAddress) {
      Customer customer = customerService.readCustomerByEmail(emailAddress);
      if (customer != null) {
         CustomerWrapper wrapper;
         wrapper = (CustomerWrapper) context.getBean(CustomerWrapper.class.getName());
         wrapper.wrapDetails(customer, request);
         return wrapper;
      }
      throw BroadleafWebServicesException.build(HttpStatus.NOT_FOUND.value())
           .addMessage(BroadleafWebServicesException.CUSTOMER_NOT_FOUND, emailAddress);
   }
}


However, I get nothing when I hit /api/v1/customer/search

Is there anything I am missing? Please help.

Re: How to implement the CustomerEndpoint in version 4

Posted: Fri Aug 14, 2015 5:12 pm
by phillipuniverse
Try trace logging on DispatcherServlet or debugging it.

Also verify that your endpoint is in a place that gets component scanned by applicationContext-rest-api.xml

Re: How to implement the CustomerEndpoint in version 4

Posted: Sat Aug 15, 2015 11:24 am
by diptangshu
Fixed it after enabling tracing.
Had to change the request mapping value from "/customer/" to "/customer"