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)


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:

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:


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