Page 1 of 1

REST Endpoints

Posted: Wed Feb 25, 2015 1:02 am
by rajfnu
Are there REST endpoints available for Login, Registration, Account, Wishlist? If yes, are they on any specific branch (devel...)?

Re: REST Endpoints

Posted: Wed Feb 25, 2015 6:18 pm
by phillipuniverse
Currently no. They should be relatively straightforward to add using the docs at http://www.broadleafcommerce.com/docs/c ... -tutorials

Re: REST Endpoints

Posted: Thu Feb 26, 2015 12:43 pm
by rajfnu
Thanks for your reply. Had they been built using @RestController rather than jersey/jax-rs, life could have relatively easy. I faced several challenges so far -
0.)Spring Boot - I saw couple of posts in various forums where impression was made as if Broadleaf works well with Spring Boot (and spring 4) but didn't find any piece of code. I checked "devel" branch at Github, it seems to be using spring4 but it is more like "old wine in new bottles". I rolled my sleeves up and took clone from devel branch. Started moving it on SpringBoot but after spending a month; I was back to square one. Had many challenges. Do you have any branch where it works as SpringBoot project?

1.) Cloud - I saw couple of articles on how Broadleaf can be deployed on clouds. They were mainly for Heroku and amazon. But none of them shows how to deploy both backoffice/Admin and Store/site together. I successfully deployed it on OpenShift (though having some document for Broadleaf on openshift as well could have saved a lot of time) but still not able to make Admin and site working together. I was more comfortable in deploying Spring boot application on any cloud provider.

2.) API Doc - I rolled out Swagger for the existing endpoints. But the wrappers as parameters in Request/Response, do not auto converted in json for showing them under Model Schema. I found this was due to the fact that wrappers don't have getters.

3.) Custom wrappers - I wrote some custom wrappers by extending existing wrappers but they don't seem to override existing. I declared them inside core/src/main/resources/applicationContext-entity.xml as <bean id="org.broadleafcommerce.core.web.api.wrapper.ProductWrapper" class="com.lp.api.wrapper.CustomProductWrapper" scope="prototype"/>
In order to find a wrokaround, I declared them as separate bean inside site/src/main/webapp/WEB-INF/applicationContext.xml as <bean id="com.lp.api.wrapper.CustomProductWrapper" class="com.lp.api.wrapper.CustomProductWrapper" scope="prototype"/>

but this had cascading effect which resulted into many changes in endpoint.java files.. Do you know what stupid mistake I might be making?

4.) Endpoints are not logical - for an example, this is not an easy to figure out that /cart/{productId} would need COLOR.black and SIZE.s parameters until I debugged and found some logic inside getOptions which takes uriInfo and has logic key.startsWith("productOption."). Why all these complexity? Rather Cart endpoint should have been like /cart/customer/{customerId} and in the post it should let submit a JSON object which can take skuID, categoryId, qty. Why it has things unclear like customerId and stuff in queryString?
Moreover, skuId is unique and if one is providing this why does it still look for ProductOptions? My clients' mobile app team only sends me skuId and I had to write a logic to fetch productOptions for the given sku so that I can make "orderService.addItem" happy otherwise it always look for prductOptions even if orderItemRequestDTO.setSkuId() is used before calling addItem()?

5.) Registered User Checkout - Using rest api, if an existing user (but not logged in) adds items into cart as guest user (which means post to /cart would create a cart with a new customerId (lets say customerId=100). After adding items into cart, he goes and login. How can we link that cart with his customerId?

6.) Any example of using WebServiceTemplate for webservice integration with Broadleaf? I was writing Tax module for Vertex and not able to get soap response integrated inside calculateTaxForOrder() implementation of TaxProvider

I have to cut it short. I have a big list of questions. Thanks for your time and help!

Re: REST Endpoints

Posted: Thu Feb 26, 2015 5:21 pm
by phillipuniverse
Rafnu,

Thanks a lot for your feedback. A lot of what I am talking about below is addressed in Broadleaf 4.0, which is yet unreleased. The plan is for this to be in RC1 by early next week. To address your points:

Had they been built using @RestController rather than jersey/jax-rs


This is the new default for Broadleaf 4.0 and has been completed: https://github.com/BroadleafCommerce/Br ... /pull/1221.

Broadleaf works well with Spring Boot (and spring 4)


Broadleaf 4.0 targets Spring 4.1. You are right that it is somewhat "old wine in new bottles"; we have a way to go with a lot of our design patterns to take advantage of the newer ways of doing things in Spring 4. One of the next major items for refactoring is to reduce/eliminate our need for a customized XML merging process. However, even though in Broadleaf we might not use all the latest and greatest, by the nature of targeting Spring 4 the idea is that people that are using Broadleaf can take advantage of those new features.

For Spring Boot specifically, this is again another refactoring process that we simply have not had time for. I would love to drill into the trouble that you had and see how we can address those individually and make that process easier. I can also see a tutorial for how to start with Spring Boot and add Broadleaf, or even refactor our public DemoSite to be a Spring Boot based project. Unfortunately, we have limited resources (still a small company) and limited time to solve all of these refactoring problems. We would love to support community efforts here.

Cloud


We can definitely improve in this area. This year we are going to be focusing on documentation, various strategies for production deploys is one of the areas. Getting the site and admin to deploy on the same instance specifically is lower on the priority list.

API Doc - I rolled out Swagger for the existing endpoints.


I would love to see what you have done here; writing some sort of blog or tutorial on how to use Swagger with the Broadleaf endpoints has been on my backlog for a while.

I found this was due to the fact that wrappers don't have getters.


I didn't realize this could manifest itself in this way. We have an issue open at https://github.com/BroadleafCommerce/Br ... issues/651, it would be great to have a pull request that solves that.

Custom wrappers - I wrote some custom wrappers by extending existing wrappers


applicationContext-entity.xml is a specialized applicationContext; you need to put wrapper overrides in a different applicationContext. This is not well documented at this point.

but this had cascading effect which resulted into many changes in endpoint.java file


Not sure what you mean by this, can you elaborate?

4.) Endpoints are not logical


I agree with you, can you open an issue at https://github.com/BroadleafCommerce/Br ... rce/issues?

Registered User Checkout - Using rest api, if an existing user (but not logged in)


This is a great point, not sure how to solve it. It would be awesome if you could open an issue at https://github.com/BroadleafCommerce/Br ... rce/issues with a potential solution, or even just present that problem.

I was writing Tax module for Vertex and not able to get soap response integrated inside calculateTaxForOrder() implementation of TaxProvider


Not sure what you mean by this, need more information.

Re: REST Endpoints

Posted: Tue Apr 07, 2015 1:29 am
by Collin
1.) Cloud - I saw couple of articles on how Broadleaf can be deployed on clouds. They were mainly for Heroku and amazon. But none of them shows how to deploy both backoffice/Admin and Store/site together. I successfully deployed it on OpenShift (though having some document for Broadleaf on openshift as well could have saved a lot of time) but still not able to make Admin and site working together. I was more comfortable in deploying Spring boot application on any cloud provider.