Transforming URL requests into Process BODs

When you create, remove, or change the state of a Management Center object, you use a Process service.

Overview

When you are transforming a URL request into a Process service request, the Management Center Web application creates the BOD by populating both the Noun and the Process verb. To comply with the best practices for building the Process service request message, the action expression in a Process verb must apply to the entire Noun. If the process needs to act upon specific parts of the Noun, the Noun must be populated based on the information that controls the process operation. Based on this guideline, every action code that is specified must apply to a particular Noun that is constructed based on the URL request parameters.

The URL requests are represented by Struts actions that map the URL to Noun and Verb combinations to transform a URL into a BOD Process message. Upon completion of the Process service, the Struts action forward builds a JSP file containing XML-formatted data for the Management Center.

Step 1: Creating the Noun

When an action is performed in the Management Center, the properties of the Management Center object are passed as URL parameters that represent a Noun element. The name of each URL parameter corresponds to the name and value of the associated Management Center object. By using Management Center object definition files, the Management Center Web application populates the Noun portion of the BOD, based on the specified URL to BOD definition name. The application then iterates through request parameters. For each parameter, the application determines whether the Noun contains an element that is defined in the configuration file. For every parameter that has the corresponding definition or association, the Noun element is populated with the URL parameter value. For example, if the configuration defines catalogEntryId to be /CatalogEntry/CatalogEntryIdentifier/UniqueID and the URL request is catentryId=1234, then the Noun that is produced has a UniqueID populated with the value 1234.

UserData within a noun

If you require more data in a noun and Management Center object, you can use UserData. UserData is used as a data extension point for adding data for objects without changing your WebSphere Commerce logical model. UserData must use parameters with the format prefix_name, where the prefix must begin with the letter x and identifies the field as UserData. The name is the name of the UserData field. Since a noun can have UserData at multiple levels, you must append an identifier to the x prefix to distinguish between UserData that has the same field name at different levels of a noun. For instance, xattr_, xdesc_, and xattrdesc_.

If you use UserData, your configuration must include definitions for how to handle the mapping of your UserData. UserData can be identified through different prefixes that are based on where the UserData is in the noun. For example, in the configuration for catalog objects, xasso_ indicates the UserData comes from merchandising associations, or xattr_ for attributes. As an example, UserData for a catalog object can begin with the prefix x_, which has its mapping, which is defined in the catalog component configuration file, wc-catalog-clientobjects.xml. In this file, the mapping of UserData with the prefix x_ is defined with the following code snippet:

<_config:URLParameter name="x_" nounElement="/UserData/UserDataField" type="UserData"/>
Where the type="UserData" code identifies that URL parameters that begin with the prefix x_ are mapped to the element in the catalog entry noun that is defined by the XPath: /UserData/UserDataField.

When a URL request is generated, the URL parameters are compared with the configuration file definitions to get the instructions for mapping the parameters to the associated noun elements. If the URL request requires an updated Management Center object to be returned, the noun is then transformed into the object model XML that is required by Management Center.

For more information about User Data, see Adding data to an existing Management Center object.

Step 2: Creating the Process verb

To create the Process verb, a special URL parameter that is called actionCode is used to define the action code that is part of the action expression. The actionCode URL parameter represents the value of the action code for each action expression that is built in the Process verb. Since URL parameters can have multiple values for the same parameter, each value represents a separate action expression for the same Noun. For example, if the value of actionCode is Add and Delete, then the Process verb has two action expressions: one with action code for Add and another with action code for Delete, each pointing to the same Noun.

Example

The following URL:
https://localhost/webapp/wcs/cmc/servlet/ProcessCatalogEntry.do?catentryId=10259&actionCode=Delete&...
corresponds to the following part of a BOD:
[...]
<_cat: DataArea>
	<oa:Process>
		<oa:ActionCriteria>
			<oa:ActionExpression actionCode="Delete">/CatalogEntry[1]</oa:ActionExpression>
	  </oa:ActionCriteria>
	</oa:Process>
	<_cat:CatalogEntry>
		<_cat:CatalogEntryIdentifier>
			<_wcf:UniqueID>10259</_wcf:UniqueID>
[...]