Tuesday, July 12, 2011

Multiple fulfillment center | Remove the default override

When designing certain eCommerce applications, some businesses have multiple fulfillment centers to choose from and this choice is some times provided to the customers.

Commerce by default overrides the FFMCENTER_ID (fulfillment center) information with the default STORE.FFMCENTER_ID, during order item add functionality.

If you want this value to be not overridden and manually given into the order tunnel commands.
In the ORDERITEMS.PREPAREFLAGS. 3rd bit needs to set.

By default, the prepared flags value is 2048 (100000000000) Binary. Setting the 3rd bit to 1 becomes
(100000000100) =2048+4=2052

int currentPrepFlag =orderItems[i].getPrepareFlagsInEJBType().intValue();
currentPrepFlag |=OrderConstants.PREPAREFLAGS_FULFILLMENT_CENTER_OVERRIDE;
orderItems[i].setPrice(String.valueOf(finalprice));
orderItems[i].setPrepareFlags(new Integer(currentPrepFlag ));
orderItems[i].commitCopyHelper();


Tuesday, July 5, 2011

Components Services | BOD versus SOI confusion !

Component Services are a set of services that follow the
Service Component Architecture (SCA) paradigm, which is a set of specifications which describe a model for building applications and systems using a Service-Oriented Architecture. SCA extends and complements prior approaches to implementing services, and SCA builds on open standards such as Web services.


Earlier versions of component services were based on SOI and the newer versions of the services are based on BOD framework from IBM.

The BOD is definitely IBM's future direction so if your building a new service you should consider BOD but if you want to use existing IBM services and do some customization, the decision to choose BOD vs SOI, lies on How commerce implemented these services.

Main difference between BOD and SOI, BOD uses pattern matching and DSL to the enter the database VS SOI uses controller commands\data beans \access beans.

E.g.

If your developing something in V7, the decision is purely based on what services are available for the requirements that one has.

BOD: SyncInventoryAvailability uses INVAVL tables and Distribute order management as inventory model.

SOI: SyncProductAvailability uses Inventory table with non-ATP inventory model.

If your store model is using non-ATP, go with SOI and if it's using DOM, the BOD service would be the way to go.

References:
http://www.ibm.com/developerworks/library/specification/ws-sca/

Tuesday, June 14, 2011

Adding an external JAR file to WCS.

JAR files are used to distribute Java applications or libraries.
There is always an interesting API that is required and need to import an external JAR file.

Steps.
1. Add the jar file to the enterprise project WC/lib.
2. Make an entry for JAR file in the Stores.war\META-INF\MANIFEST.MF (the file has specific formatting with a space before and after each line and also blank line at the end.
3. Add the jar file to the WebSphereCommerceServerExtensionsData classpath. Mak sure the exported flag is true.
<classpathentry exported="true" kind="lib" path="/WC/lib/custom/recaptcha4j.jar"/>
4. Build
5. Restart

JAR basic commands:

Unzip: Jar -xvf .jar

Zip: java -jar .jar

Troubleshoot:
When you start the server, make sure the jar file is added in the system out logs:
[6/14/11 15:39:10:087 PDT] 00000019 WebApp A SRVE0180I: [InitializationServlet] [/InitializationServlet] [Servlet.LOG]: InitServlet: ServletContext attributes:
C:\WCToolkitEE60_Raj\workspace\WC\lib\custom\recaptcha4j.jar

Thursday, May 26, 2011

Impersonation ! Hiccup with WCSV7

Impersonation: In E-Comm site, this is a important flow where essentially a telesales rep or admin places an order for a regular user, the admin is essentially impersonating the user and WebSphere commerce provides out of box flows to use this behavior.

If your using SalesCenter or have your own Telesales tool customization to work with websphere commerce, you need to add a flag in wc-server.xml after V7 migration.

Until V7 by default impersonation feature was available and would work but essentially there is a flag introduce that needs to be added in wc-server.xml in the instance section during V7 migration if you are using impersonation.

<OrderLockFeature enabled="false"/>

API Background on Impersonation in WCS
getCallerId() --> returns the admin user Id when doing impersonation.
getUserid() --> Returns the userId of the user in the current session.

Important commands for Impersonation for setting user and admin for various commerce operations.
RunAsUserSetInSessionCmd and RestoreOriginalUserSetInSessionCmd

Tuesday, May 24, 2011

Magic of Servlet Filter for Mobile\ROR\Blocking requests for Performance

Java Servlet Filters are very powerful and have been around for a while and they are used for intercepting the requests and responses dynamically and can transform\modify response for different devices. The WCS framework allows programmers to extend this feature and use if solve various interesting problems.
I have to warn that servlet filter should only be used very carefully as every request/response goes through it and if not done right could impact the performance of the site.


There are 3 parts to writing a filter in commerce.
1. Defining the Filter in web.xml (Web Deployment descriptor)

<filter>
<display-name>XXBlockServletFilter</display-name>
<filter-name>XXBlockServletFilter</filter-name>
<filter-class>com.company.webcontroller.XXBlockServletFilter</filter-class>
<init-param>
<param-name>listOfParams</param-name>
<param-value>Param1,Param2,Param3</param-value>
</init-param>
</filter>

2. Where to add filter mapping in web.xml The order of filter mapping specified in the web deployment descriptor is used for filter chaining. I have worked on a couple and have them before DynaCache filter and the rational behind that is, we wanted to intercept the request before it goes into the DynaCache filter.
All requests in commerce are processed through multiple filters. It is important to understand where you want to place the filter.

3. Writing the java code for XXBlockServletFilter by overriding the doFilter method: All the processing happens here so if you are using it for Mobile or XML for any ruby on rails front end or blocking certain kinds of commands.


For More information on Commerce flow of request:
http://publib.boulder.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.developer.doc/concepts/csdrequestsummary.htm

Sunday, May 1, 2011

Configuration | Must know for Development


Changing the DB configuration on development instance:

setdbtype oracle C:\oracle\product\10.2.0\db_1 orcl10g system oracle devjan07 devjan07 localhost 1521

Where devjan07 is the name of the schema and the password.

When you run the command above a log is created in \logs\setdbtype.log and wc-server.xml is updated with the new database details.

Disabling Access control on development instance:

AccessControlUnitTest="true"

This property is not there by default in wc-server.xml in V6 and beyond. Add this property under <Instance xml element.

Accelerator XML configuration for instantly reflecting in Development environment: This is very useful when doing Acceleraor development.

    If you want the changes made in XML file to automatically be reflected in development environment

<ToolsGeneralConfig DTDPath="tools/common;tools/devtools;tools/bi;tools/catalog;schema/xml;sar" XMLCacheSize="1000" XMLPath="tools;tools/devtools;WEB-INF/xml/tools;WEB-INF" developmentMode="true"

    Make this change in wc-server.xml

Saturday, April 30, 2011

Punchout with Commerce systems

Punchout is a common paradigm called for sharing catalog and transfer cart at run time between different systems procurement and e-commerce systems.

Different 3rd party systems popular for PunchOut
e.g. Ariba Supplier Network, Oracle Fulfillment, SMAPS

There are 2 ways to communicate, I have used point to point and using Ariba supplier network.

cXML is used for communication. (Commerce eXtensible Markup Language) is a protocol intended for communication of business documents between e-commerce and procurement applications. It is really easy to understand and use.

Punch out on Ariba: You need to configure in the admin tool
administration->configuration->electronic order routing
catalogs->create punchout Only

Integrating WCS with various Punchout system is very interesting. Will do a another blog on the details.