You are on page 1of 5

ATG REST MVC Definition Framework

In Oralce Commerce Release 11, Oracle has provided the integration support to
the RESTful webservices, which allows the http requests to work with any ATG
applications. The following information gives a high level overview of the REST
MVC Definition framework provided by oracle in its Release 11. The below
information is referred from the ATGWSFrameGuide.
ATG REST MVC Webservices allows us to use HTTP requests to work with any ATG
application. These services provides the ways using which we can do things such
as protect user logins, send data to forms using mobile applications, or retrieve
data from search results. Multiple controllers generate a Model Map that can be
filtered, and the output from these controllers is used to generate JSON or XML
response.
REST MVC Service Flow Example
To understand how the REST MVC processes work, imagine that a customer
would like to add a single item from
a catalog to their shopping cart. When the customer, or client REST service,
initiates the REST call, the following
occurs
1. The REST Service uses a URL that begins with /rest/model and has been
registered with the
ActorChainRestResgistry service. In this example, the URL is:
/rest/model/atg/commerce/order/purchase/CartModifierActor/addItemToOrder
This URL contains not only the CartModifierActor Nucleus component, but the
addItemToOrder actorchain.
The REST Service also verifies the users access using the
AccessControllerService.
2. The REST Service initializes the actor context from the REST control
parameters and the URL. The actorcontext
is then passed to the ActorChainService. Because the addItemToOrder actorchain calls the
/atg/commerce/order/purchase/CartModifierFormHandler, a formActor is invoked.
The /atg/commerce/order/ShoppingCart component requires that a
componentActor is also invoked.
3. Once all of the actors have provided the data, the ModelMap is filtered with
BeanFilters initiated by the
BeanFilteringService. This process modifies the data in the ModelMap.
4. After the filters have been applied to the ModelMap, the ResponseGenerator
transforms the ModelMap into
the response, which is configured to be a JSON or XML response. The response
then sent back to the client.

The following diagram shows the flow of the REST service call:

Request URLs
ATG REST MVC requests use a /rest/model URL to process request against the
actor framework. The general format for a REST MVC URL is
http://host:port/rest/model/actor_component/tail
The format variables are
host The REST server
port the port from which user access the REST services
actor_component The nucleus path for a nucleus component that implements
the Actor interface
tail Any attribute that can be processed by a URI processor. For chained-actors,
the tail is the chain-id.
A typical request might look like as follows
http://rest.company.com:8280/rest/model/atg/commerce/order/purchase/
CartModifierActor/addItemtoOrder

External REST MVC Services for Category and Product provided OOTB in
ATG REST API
Get Catalog By Sub-Categories Example
Request URL to be sent:
curl -L -v -b customer_cookies.txt -H "Content-Type: application/json" -d "{
\"categoryId\" : \"cat50056\" }" "http://localhost:8280/rest/model/atg/
commerce/catalog/ProductCatalogActor/getCategory"

Response from Server might be:


{
"childCategories": [
{
"id": "cat50056",
"description": null,
"defaultParentCategory": null,
"displayName": "Gift Shop",
"type": null
},
{
"id": "cat50001",
"description": "",
"defaultParentCategory": null,
"displayName": "Women",
"type": null
},
{
"id": "catMen",
"description": "",
"defaultParentCategory": null,
"displayName": "Men",
"type": null
},
{

"id": "cat50097",
"description": "",
"defaultParentCategory": null,
"displayName": "Shoes",
"type": null
},
{
"id": "cat10016",
"description": null,
"defaultParentCategory": null,
"displayName": "Home Accents",
"type": null
}
],
"category": {
"id": "rootCategory",
"description": null,
"defaultParentCategory": null,
"displayName": "Commerce Root",
"type": null
}
}

Get Product by Product ID Example


Request sent to server:
curl -v -b customer_cookies.txt -H "Content-Type: application/json" -d "{
\"productId\" : \"xprod2085\"}" "http://localhost:8280/rest/model/atg/commerce/
catalog/ProductCatalogActor/getProduct"
Response from server might be:
{
"product": {
"currencyCode": "USD",
"highestSalePrice": 19,

"lowestSalePrice": 19,
"lowestListPrice": 19,
"fullImageUrl": "/crsdocroot/content/images/products/full/
HOME_TumblerGlass_full.jpg",
"childSKUs": [{
"listPrice": 19,
"displayName": "Tumbler Glass",
"type": "sku",
"repositoryId": "xsku2085"
}],
"repositoryId": "xprod2085",
"highestListPrice": 19,
"description": "Tumbler glass great for mixed drinks and other beverages",
"largeImageUrl": "/crsdocroot/content/images/products/large/
HOME_TumblerGlass_large.jpg",
"longDescription": "Our heavy glass tumblers are a versatile addition to your
barware
collection. Holds 12 ounces. Dishwasher safe. Made in Poland.",
"isNavigableProduct": true,
"mediumImageUrl": "/crsdocroot/content/images/products/medium/
HOME_TumblerGlass_medium.jpg",
"displayName": "Tumbler Glass",
"thumbnailImageUrl": "/crsdocroot/content/images/products/thumb/
HOME_TumblerGlass_thumb.jpg"
}}

You might also like