With new feature pack FEP8, data can be directly fetched from SOLR index via REST calls without hitting commerce server. In order to do the customization, we first need to understand the REST framework in Websphere commerce.
- Every REST call has a unique pattern like /productview/byCatentryId/{catentryId}
- To handle such REST request, the entry points are Rest Handlers.
- In this case, it's ProductViewHandler.
- These REST handlers are of AbstractSearchResourceHandler type and are annotated with different Path annotations.
- These annotation could be at two level, class level and method level.
- In general, /productview/ represents a class level path and the next token represents different methods.
@Path ("store/{storeId}/productview")
public class ProductViewHandler extends AbstractSearchResourceHandler {
@Path ("byCatentryId/{catentryId}")
public Response getProductByUniqueID(@QueryParam String responseFormat...) {
}
@Path ("byPartNumber/{partnumber}")
public Response getProductByPartNumber(@QueryParam String responseFormat...) {
}
}
- The method name and class name has no significance but just conventions associated with them. The actual mapping is determined by the Path annotation.
- Now, how would Search server know that there exists a Handler with ability to handle specific patterns?
- Every REST handler is supposed to be registered with Search server. OOTB handlers are defined in /Search-Rest/WebContent/WEB-INF/config/resources-search.properties
- If you want to create your custom REST handlers, an entry needs to be defined in /Search-Rest/WebContent/WEB-INF/config/resources-search-ext.properties.
- At server startup time, the entries in resource file are loaded and different Path annotations are registered with search server.
Comments
Post a Comment