Saturday, 29 March 2014

WCS Component Service strusts configuration and invocation Details

1. Component Plugin Configuration in  struts-config-order-services.xml


<plug-in className="com.ibm.commerce.struts.ComponentPlugIn">
 <set-property property="componentId" value="order"/>
  <set-property property="clientFacadeClassName"        value="com.ibm.commerce.order.facade.client.OrderFacadeClient"/>
</plug-in>

2. Struts Action Mapping Configuration:

<action parameter="order.addOrderItem" path="/OrderChangeServiceItemAdd" type="com.ibm.commerce.struts.ComponentServiceAction">
<set-property property="authenticate" value="0:0"/>
<set-property property="https" value="0:1"/>
</action>

3. ComponetServiceAction.java class invokeService(ActionMapping mapping,HttpServletRequest request) method has following code which calls the appropriate method on component client facade

{
RequestHandle handle = (RequestHandle)request.getAttribute("EC_requestHandle");
Map responseMap = ComponentPlugIn.invokeComponentService(handle, inMap, mapping.getParameter());
}

Wednesday, 6 November 2013

Virtual Host Changes for WebServicesRouter Project: Default Port is 8000 which is secure port



HTTPServer plugin-cfg.xml path on app server or httpserver based on environments:
C:\IBM\WAS\profiles\wc_instancename\config\cells\cell_name\nodes\WC_instancename_node\servers\webserver1

Change
1. First open the commerce deployment manager admin console and update the virtual host mapping for WebServicesRouter project from VH_instancename_Tools to VH_instancename.
2. Click on enterprise application link and then click on save configuration link on this page. Don’t check synchronize with node check box and click OK.
3. Now click on nodes under system administration link and then select the appropriate node and click synchronize
4. Check logs , this project should bound to new virtual host group VH_wc_instancename not VH_wc_instancename_Tools

<UriGroup Name="VH_wc_instancename_wc_instancename_Cluster_URIs">
      <Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/webapp/wcs/stores/*"/>
      <Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/InitializationServlet/*"/>
<!-- added below uri so that webservicerouter project urls like /webapp/wcs/services/   can also be handled by virtual host group VH_wc_instancename-->
<Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/webapp/wcs/*"/>
</UriGroup>
<Route ServerCluster="wc_instancename_Cluster" UriGroup="VH_wc_instancename_wc_instancename_Cluster_URIs" VirtualHostGroup="VH_wc_instancename"/>







It can also be achieved through following way:

httpd.conf file path on sefags840:   C:\IBM\WCS\instances\wc_instancename\httpconf

<VirtualHost sefags840.secotools.net:8000>
SSLEnable
SSLClientAuth 0
ServerName sefags840.secotools.net
Alias /wcsstore "C:\IBM\WAS\profiles\wc_instancename\installedApps\WC_wc_instancename_cell\WC_wc_instancename.ear/Stores.war"
Alias /accelerator "C:\IBM\WAS\profiles\wc_instancename\installedApps\WC_wc_instancename_cell\WC_wc_instancename.ear/CommerceAccelerator.war/tools/common/accelerator.html"
Alias /wcs "C:\IBM\WAS\profiles\wc_instancename\installedApps\WC_wc_instancename_cell\WC_wc_instancename.ear/CommerceAccelerator.war"
Alias /wcwkspcadmin "C:\IBM\WAS\profiles\wc_instancename\installedApps\WC_wc_instancename_cell\WC_wc_instancename.ear/WorkspaceAdministration.war"
Alias /workspaceadmin "C:\IBM\WAS\profiles\wc_instancename\installedApps\WC_wc_instancename_cell\WC_wc_instancename.ear/WorkspaceAdministration.war/tools/workspaceadmin/wkspcadmin.html"
</VirtualHost>

Change
Comment out SSLEnable & SSLClientAuth 0 lines in above configuration like this 
#SSLEnable
#SSLClientAuth 0

Thursday, 31 October 2013

WCS Code to find storeId from user LogonId (Expecting that user has registereigd customer role from one store only)

MemberRoleAccessBean m = new MemberRoleAccessBean();
Enumeration mEnum = m.findByMemberIdRoleId(cmdContext.getUserId(),Integer.valueOf("-29"));
Enumeration sEnum = null;
if(mEnum.hasMoreElements()){
   m =(MemberRoleAccessBean)mEnum.nextElement();
   StoreEntityAccessBean stAb = new StoreEntityAccessBean();
   sEnum = stAb.findByMember(Long.valueOf(m.getOrgEntityId()));
   if (sEnum.hasMoreElements()){
   stAb =(StoreEntityAccessBean)sEnum.nextElement();
   storeId = stAb.getStoreEntityId();
}
}

Wednesday, 30 October 2013

WCS developer toolkit , WC.ear deployment files location

Error: SRVE0017W: A WebGroup/Virtual Host to handle localhost:443 has not been defined.

It could be the reason that WC application is not deployed to Websphere Test Server; we can see that in app server admin console enterprise application section if it is installed or not. This sometimes happens when we do add/remove wc project in toolkit.

In WCS developer toolkit , C:\IBM\WCToolkitEE60\wasprofile\config\cells\localhost\applications folder contains the WC.ear file which contains deployment files like deployment.xml, resources.cml and variables.xml

if in above file location applications folder is missing then copy it from backup toolkit.

C:\IBM\WCToolkitEE60\wasprofile\config\cells\localhost\nodes\localhost\serverindex.xml contains wc.ear deployment configuration for app server

serverindex.xml should look like this



<?xml version="1.0" encoding="UTF-8"?>

<serverindex:ServerIndex xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:serverindex="http://www.ibm.com/websphere/appserver/schemas/5.0/serverindex.xmi" xmi:id="ServerIndex_1" hostName="localhost">

<serverEntries xmi:id="ServerEntry_1224144829726" serverName="server1" serverType="APPLICATION_SERVER">

<deployedApplications>WC.ear/deployments/WC</deployedApplications>

<specialEndpoints xmi:id="NamedEndPoint_1224144829726" endPointName="BOOTSTRAP_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829726" host="localhost" port="2809"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829727" endPointName="SOAP_CONNECTOR_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829727" host="localhost" port="8880"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829728" endPointName="SAS_SSL_SERVERAUTH_LISTENER_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829728" host="localhost" port="9401"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829729" endPointName="CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829729" host="localhost" port="9403"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829730" endPointName="CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829730" host="localhost" port="9402"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829731" endPointName="WC_adminhost">

<endPoint xmi:id="EndPoint_1224144829731" host="*" port="9060"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829732" endPointName="WC_defaulthost">

<endPoint xmi:id="EndPoint_1224144829732" host="*" port="80"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829733" endPointName="DCS_UNICAST_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829733" host="*" port="9353"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829734" endPointName="WC_adminhost_secure">

<endPoint xmi:id="EndPoint_1224144829734" host="*" port="9043"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829735" endPointName="WC_defaulthost_secure">

<endPoint xmi:id="EndPoint_1224144829735" host="*" port="443"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829736" endPointName="SIB_ENDPOINT_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829736" host="*" port="7276"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829737" endPointName="SIB_ENDPOINT_SECURE_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829737" host="*" port="7286"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829738" endPointName="SIB_MQ_ENDPOINT_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829738" host="*" port="5558"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144829739" endPointName="SIB_MQ_ENDPOINT_SECURE_ADDRESS">

<endPoint xmi:id="EndPoint_1224144829739" host="*" port="5578"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144830117" endPointName="ORB_LISTENER_ADDRESS">

<endPoint xmi:id="EndPoint_1224144830117" host="localhost" port="9100"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144901755" endPointName="WC_PORT_1">

<endPoint xmi:id="EndPoint_1224144901755" host="*" port="8000"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144901817" endPointName="WC_PORT_2">

<endPoint xmi:id="EndPoint_1224144901817" host="*" port="8002"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144901880" endPointName="WC_PORT_3">

<endPoint xmi:id="EndPoint_1224144901880" host="*" port="8004"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144901927" endPointName="WC_PORT_4">

<endPoint xmi:id="EndPoint_1224144901927" host="*" port="8006"/>

</specialEndpoints>

<specialEndpoints xmi:id="NamedEndPoint_1224144901958" endPointName="WC_PORT_5">

<endPoint xmi:id="EndPoint_1224144901974" host="*" port="8007"/>

</specialEndpoints>

</serverEntries>

</serverindex:ServerIndex>

Thursday, 29 August 2013

How to get CatalogAssetStore storeId in WCS

com.ibm.commerce.common.helpers.StoreUtil.getStorePath(storeId, com.ibm.commerce.server.ECConstants.EC_STRELTYP_CATALOG)
This method returns all the catalog related store IDs in the store path given the current store ID.

Above Util class uses RelationshipJDBCHelperAccessBean().findRelatedStores(storeId, storeRelationshipTypeName) .

This will fetch data from STOREREL database table


Friday, 6 July 2012

WCS Extended Site Model Concepts

Extended Site architecture diagram & solution outline



In WCS Extended site model Multiple stores can exist in a single Stores Web module. If so, the store assets are separated using the following methods:

Storefront Assets

Storefront assets for each store in the Stores Web module are stored in a separate store directory (storedir). For example, all storefront assets for Mystore1.com (for QC 57) are in the Mystore1 directory & all shared storefront assets are in SharedStorefrontAssetStore directory.
Storefront asset includes jsp, html, css, javascript, images & properties files.

Business logic

The store ID is used to select the command implementation for each store, as specified in the command registry.



Struts Mapping
The configurations for actions and forwards for the Extended-Sites model work the same general way as the ConsumerDirect (B2C) or AdvancedB2BDirect (B2B) models, with one important difference.
For the B2C and B2B direct models, actions and forwards will be looked up for the STORE_ID matching the parameter of the Web request. If no entry exists, it defaults to the default "STORE_ID = 0" and performs another lookup.
In the case of Extended-Sites, you also need to consider the StorePath, which is defined by the relationships between the extended site customer facing stores and the asset stores. These are defined in STOREREL. The relevant relationships for Struts are:
 NAME                                     STRELTYP_ID        
com.ibm.commerce.URL            -10         
com.ibm.commerce.view           -11        
The lookups for actions and forwards first check the Extended-site STORE_ID (as passed in from the Web request). If no entry exists it then looks up based on the related STORE_ID's from STOREREL (for example, asset stores), and then reverts to the default STORE_ID = 0, performing another lookup.
Examples of mapping: Same view name but different storeId
Struts forward mapping to display Mystore1.com specific view (e.g. storIed: 10002)
<forward className="com.ibm.commerce.struts.ECActionForward" name="MyStore1CategoryOnlyResultsDisplayView/10002" path="/Snippets/Catalog/CategoryDisplay/MyStore1CategoryOnlyResultsDisplay.jsp"/>
Struts forward mapping to display shared view ,right now it is shared between mystore1.com & mystore2.com (e.g. shared storIed: 10101, STORETYPE is BMP – Hosted B2B storefront asset store)
<forward className="com.ibm.commerce.struts.ECActionForward" name="MyStore1CategoryOnlyResultsDisplayView/10101" path="/Snippets/Catalog/CategoryDisplay/MyStore1CategoryOnlyResultsDisplay.jsp"/>
Commerce Database tables

Commerce Database tables database tables that are used to define the store path & relationship type are:

STRELTYP
The store relationship type defines all the assets that can be shared.

STOREREL
Defines a relationship between an asset store and an Extended Site store in extended site model

STORE
Stores the directory path for hosted as well as storefront asset store

Commonly used JSTL variables in Elite starter store pages

Infocenter Ref:      http://publib.boulder.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.elite-starterstore.doc/refs/rsmelitejstlvars.htm

Store directory variables

jspStoreDir
Web Asset directory of the shared file directory. This directory can contain common Web file formats such as JSP files, HTML, and images.
storeDir
Web Asset directory of the hosted store. This directory can contain common Web file formats such as JSP files, HTML, and images.


Utility Class

There is a simple utility class we can use to pull all the related store identifiers for a given store relationship type and store identifier, use com.ibm.commerce.common.helpers.StoreUtil.getStorePath(storeId,storePathType ). An array of store identifier values is returned. The index of the array is congruent with the sequence value from the STOREREL table. The way we use that data is up to us, either use all values to find corresponding assets by the foreign key store identifier, or use a specific index from the array based on some conditional rule.

Customized Extended site model where we don’t need separate struts view mapping for each store separated by /storied

Business Requirement:

As a developer we don’t want to create separate entry in struts-config file for each store in case we have different view implementation for different stores. We can still have the same view name & same storeId which is related store storeId(e.g. 10101 )  in the struts config file for all hosted sites in an extended site model of WCS.

Solution:

To implement this functionality we need to extend the OOB BaseAction class & override the execute() method & below is the solution outline & request processing flow of commerce:

 




(1) Extended MyBaseAction class execute() method will first call the OOB BaseAction class execute method which will do all the processing & will return a ActionForward. At this point all the processing has been done by the OOB BaseAction.

(2) Check for the LOOK_UP_AT_HOSTED_STORE property value from store specific WHRConfig.properties file inside the MyBaseAction execute() method. If it is true then execute the logic written in step # 3 otherwise ignore it & return the ActionForward from step #1 to RequestProcessor.

(3) Inside MyBaseAction execute() method we have ActionForward object from step #1 i.e. super class & from this object we will get the relative path of the resource (jsp) which will be returned to the struts RequestProcessor & in turn it will be returned to the browser for display.
In this step we will use the store path concept of the extended site model & will retrieve all the store paths i.e. related stores directory stored in the STOREREL database table.

Now we will check for requested resource in the related stores directory in the sequence maintained in the STOREREL database table in a for loop.Once it finds the requested resource in a store directory then set this path in the ActionForward object which we got from BaseAction & it break the for loop & return the updated ActionForward to the RequestProcessor & remaining things will be taken care by the OOB Request Processor & ECActionServlet classes as usual.

(4) Use this extended MyBaseAction in place of OOB BaseAction in the struts-config file action mapping section for the views shared between more than hosted sites.

In short, if we have same jsp in the store specific directory then it will be displayed to the user & if it is not there in the store specific directory then it will be displayed from the shared/related store directory.


We will get following advantage if we will go with this approach:

1. We can have views name same for all the stores so small size of struts config file, easy to maintain.
2. Since views name are same so need to create separate access control policies
3. No need to change the existing jspf paths in the already existing jsp(s) since those will work as usual unless those are not overridden in the specific store directory.
4. No changes required in the SEO URL since views name are still same.
5. In future it will help us to make changes/add new features in different sites without impacting other existing sites very easily.

Sunday, 6 November 2011

ERROR Message: CMN2007E: There is insufficient inventory to purchase 1 units of the product for catalog entry


CMN2007E
Explanation: This message is issued by the default implementations of inventory related task commands (such as CheckInventoryCmdImpl, UpdateInventoryCmdImpl, and CheckInventoryAvailabilityCmdImpl) when there is insufficient inventory for the quantity of a product required to fulfill an Order.\n\nWhen STORE.ALLOCATIONGOODFOR is zero, the CheckInventoryCmdImpl and UpdateInventoryCmdImpl default task command implementations check the INVENTORY table. Otherwise, the CheckInventoryAvailabilityCmdImpl default task command implementation checks the RECEIPT and ITEMFFMCTR tables.

How to customize java.util.logging.Logger class to write logs in separate file than System.out.log in Websphere commerce/ HCL commerce)

/** * This method updated the passed in java.util.logging.Logger object with * custom file handler to write logs data form that class ...