Monday, July 30, 2012

Websphere commerce--ERP data flow !!

For a lot of front end developers not working on integration, the ERP system is like a Black hole. This blog presents high level flow and integration touch points. As a part of most B2B and B2C implementation, it is generally important to communicate with a back end ERP system. 
The core of order management system in ERP has at least 3 main documents, Sales Order Doc, Delivery Doc, Invoice Doc. Sales Doc is used to create orders, delivery doc involves with shipping, Invoice with PO and settlement.
There could several other feeds and integration's depending on the operations in the end ERP system but most e-commerce system are fed Product\Pricing\Inventory data from back-end.  All this data being transported between the systems, could be implemented as Feeds\Web services\JMS-MQ .
Enterprise middle-ware systems such as Web Methods\WebSphere ESB\Open Source ESB could be for data transformations and communication with multiple systems.


Products\Price\Inventory--core of any commerce site and if it is driven from your ERP system, here's how the flow would be:


If the orders are dropped into the ERP system for order fulfillment at the high level, order tunnel flow from commerce to the backend system.





Tuesday, June 26, 2012

Logon failure Issue | URLRedirect filter enabled


If your user logon flow is working fine in development environment and is failing once you get to staging or live. Essentially there is a configuration that needs to be defined in wc-server.xml for allowedDomain if the URLRedirectFilter is enabled.

The URL redirectfilter is enabled to prevent phishing attacks where a link from the current site would prevent the user from being redirected to a different site. It does need correct allowedDomain or else some of the functionality including logon starts failing.

Make sure in wc-server.xml in store definition has correct value  to domain or sub-domain value in the URLredirectfilter definition for store element.

alloweddomain name="example.com" 

Logs from Error for this scenario with login failure:

[6/22/12 12:34::024 EDT] 00000123 EJBMDOrchestr A   CNTR0117I: Container-managed ejbStore() call will be bypassed on bean: "WC_ejgrp#Member-MemberManagementData.jar#UserPasswordHistory" if it has not been modified in the current transaction.
[6/22/12 12:34:58:313 EDT] 0000023b CommerceSrvr  A ECActionForwardInstance isRedirectAllowed(String) CMN0207E The value of the parameter "URL" is not correct.
[6/22/12 12:59:59:254 EDT] 00000113 CommerceSrvr  E WCAuthenticationCookie getUserId CMN1039E: An invalid cookie was received for the user, your logonId may be in use by another user.
[6/22/12 12:34:28:727 EDT] 00000122 CommerceSrvr  A ECActionForwardInstance isRedirectAllowed(String) CMN0207E The value of the parameter "URL" is not correct.
[6/22/12 12:34:30:239 EDT] 0000045b CommerceSrvr  E WCAuthenticationCookie getUserId CMN1039E: An invalid cookie was received for the user, your logonId may be in use by another user.
[6/22/12 12:34:13:330 EDT] 00000245 CommerceSrvr  A ECActionForwardInstance isRedirectAllowed(String) CMN0207E The value of the parameter "URL" is not correct.
[6/22/12 12:34:15:141 EDT] 00000245 CommerceSrvr  E WCAuthenticationCookie getUserId CMN1039E: An invalid cookie was received for the user, your logonId may be in use by another user.

Tuesday, June 19, 2012

IBM Management Center | Preview not working

When you click on the preview functionality from the management center and it fails with the following error

[5/8/12 15:43:15:374 CDT] 00000026 SystemOut O ErrorDataBean:
Originating command:
Message Type: 0
Message Key: _ERR_REDIRECT_VIEW_ERROR
Message: CMN3101E The system is unavailable due to "URL".
[5/8/12 15:47:28:845 CDT] 0000002c CommerceSrvr E WCAuthenticationCookie getUserId CMN1039E: An invalid cookie was received
for the user, your logonId may be in use by another user.
[5/8/12 15:47:28:856 CDT] 0000002c SystemOut O ErrorDataBean:
Originating command:
Message Type: 1
Message Key: _ERR_INVALID_COOKIE
Message: CMN3101E The system is unavailable due to "{0}".
[5/8/12 15:49:06:561 CDT] 00000027 SystemOut O ErrorDataBean:
Originating command:
Message Type: 0
Message Key: _ERR_REDIRECT_VIEW_ERROR
Message: CMN3101E The system is unavailable due to "URL".

In wc-server.xml under respective WebModule all webserver hostname and domainname are added as AllowedHost

Monday, May 14, 2012

Cookie path creation always at the web server root !!

If you use the default settings on cookie, it creates the cookies at the web server context. In WebSphere commerce that would create the cookies at /webapp/wcs/stores/servlet with default settings. This is usually not a problem for most scenarios but if you have a scenario when there is a canonical URL e.g for SEO,  that does not start with /webapp/wcs/stores/servlet. The HTTP response stops carrying the cookies to the browser and you will start seeing issues in the site where you have code that depends on the cookie.


Sample code to create a custom cookie at the root:
String value="custom_cookie_value";
Cookie customCookie = new Cookie("CustomCookie",value);
customCookie.setPath("/");
Even though this is a simple thing to fix, it could be hard to debug. As a best practice, always create custom cookies at the root and out of the box cookies are always created at the root.


Primer on cookies:
A cookie is a application specific data stored as a separate file for each domain in the browser. There are 2 types, session cookies and persistent cookies. Session cookies are used to log information that are eventually erased after the life cycle of a session, e.g Based on a users Login, if you want to show certain attributes or mini-carts and are deleted on LogOff.
Persistent cookies are store for much longer period and are useful for things like RememberMe functionality.


Validation rules to pass the cookies back to web-server:
A cookie is sent back from browser to web-server based on certain events when it matches the Domain, Path and port of the server in cookie.
Cookie can have a secure attribute set if it is on HTTPS.
Each cookie has a Max-Age and the browser would not send back expired cookies.

Tuesday, May 8, 2012

Bazaar Voice Integration | Reviews and Ratings

BazaarVoice provides a really good platform for product feedback and social media integration's. It is really easy for business users and programmers to integrate with back end systems.

Essentially BazaarVoice Integration has the following main components:

1. Display reviews to guest and registered customers.
2. Writing new reviews and as a platform providing business users access to their workbench tooling to approve reviews.
3. This is optional and provides SEO benefits as the JS based integration makes it harder for search engines to crawl the content and hence BazaarVoice provides SEO basic and SEO advanced integration's, this is a server side include of product files.
4. Sending outbound XML product feed to BazaarVoice nightly or weekly feed of categories and products, depending on your product cycle.
5. Feeding reviews and ratings file from BazaarVoice back to your Search engine (Endeca or SOLR).  This is to improve the search on the site by allowing keywords from reviews to be searchable.
Find below sample code for a simple integration piece to show reviews.




Resources: Great place with examples.
https://github.com/bazaarvoice/HostedUIResources

Sunday, April 29, 2012

Adding cache-control on static assets | Improve data integrity and performance


Static files (example: JS\CSS\HTML.) are cached by client browsers and if they don't carry cache-control directive in the HTTP-header, it is up to the browsers to determine, how often to check to check for updated value from server. Some times browsers could cache stale content for days.
This could cause the static file to be obsolete and pick from local browser cache and out of sync and could potentially result in broken pages and corrupt files.
The solution is to add cache-control directive to the web server configuration and this will force the browser to check for the updated version from the server when the time specified expires.
The functionality would essentially result in HTTP_STATUS code 200 when a file is modified and other wise would return HTTP_STATUS code 304

Testing the HTTP-Header changes:
You can using tamper data as Firefox plugin or fiddler for IE to look at the HTTP-header

Make changes to httpd.conf
1. Add the following at the end of LoadModule section in web server configuration file (httpd.conf).
        LoadModule headers_module modules/mod_headers.so
2. Add the following at the end of web server configuration file (httpd.conf).


Scenario1: [Browser cache not expired and file changed - File should be fetched with 200 response]
Scenario2: [Browser cache expired and file changed - should be fetched from server with 200 response]
Scenario3: [File not changed but browser cache expired - should get 304 response]
Scenario4:[File not changed and browser cache not expired - should be serverd from browser cache]

Friday, April 27, 2012

Sorting !!! an important function for a lot of display pages

This blog is for sorting using Java code. Sorting is an essential part, which is a required function in most code bases.I am going to start with a couple and then will add few more. If you any of you guys reading this have better ideas, please add in the comments.

//Sort a string with a delimiter and arrange with the same delimiter into a string Arrays.sortOf() uses merge sort and has a worst case performance O(nlogn)
//Sort and maintain the same ordering. LinkedHashMap is very useful to preserve the ordering. It Maintains a doubly-linked list running through all of it's entries