Thursday, October 6, 2011

Generated columns UP_* for case insensitive search in V7


You might not find anything while searching about this info center. At least not when I did the search.

In V7 data migration generates some new generated fields and these fields are tablename.UP_*  columns. These fields are used by out of the box case insensitive searches. The grouping functions such as to_lower or to_upper are expensive operations for search when dealing with vast data and that is one of the performance enhancements in V7.

I am pretty sure, if you use out of the box data migration tool for migrating to V7. It should take care of  these generated fields. These fields should not be populated from code, there are triggers in database that would take care of populating these fields.

e.g.
  "UP_MFNAME" VARCHAR(64) GENERATED ALWAYS AS (UPPER(MFNAME)) ,
  "UP_MFPARTNUMBER" VARCHAR(64) GENERATED ALWAYS AS (UPPER(MFPARTNUMBER))
  "UP_PARTNUMBER" VARCHAR(64) GENERATED ALWAYS AS (UPPER(PARTNUMBER)) )

References:
https://www-304.ibm.com/support/docview.wss?uid=swg21498502
http://www.ibm.com/developerworks/data/library/techarticle/0203adamache/0203adamache.html
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.db2.luw.admin.dbobj.doc%2Fdoc%2Fc0020109.html

Order state diagram !!

Orde state Diagram
This is probably one of the interesting info center article regarding the state diagram of order status. It shows pretty good transition between states. If you decide to use custom statuses as a best practice choose lower case letters.




Reference:
http://publib.boulder.ibm.com/infocenter/wchelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.commerce.developer.doc%2Frefs%2Frosordstattran.htm

http://publib.boulder.ibm.com/infocenter/wchelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.commerce.user.doc%2Fconcepts%2Fcossostat.htm



Saturday, September 24, 2011

Troubleshooting User log-in and organization relationship

CommerceSrvr E AccManager isAllowed CMN1501E: User 6002 does not have the authority to perform action "Display" on resource "com.ibm.commerce.user.beans.UserDataBean" for command "Logon".
 CommerceSrvr A DataBeanManager directActivate(DataBean,CommandContext) The user does not have the authority to run this command "com.ibm.commerce.user.beans.UserRegistrationDataBean".
t have the authority to perform action "Display" on resource "com.ibm.commerce.user.beans.OrganizationDataBean"

Troubleshooting: The above error was caused as there was a missing relationship in MBRREL to the parent organization.

DN should be lowercase and no spaces between orgs.

If you have Manually imported orgentity table through data load, The DN relationship is stored between the ancestor and descendant in MBRREL. If the tree has multiple parents, all the parent-child relationship should be defined in MBRREL.

A member_id from MEMBER table can be a ORGENTITY_ID, USERS_ID,MBRGRP_ID

 Some queries to help for debugging:

select * from mbrrel where descendant_id=;


select * from orgentity where orgentity_id in (
select ancestor_id from mbrrel where descendant_id=);



USERS:

 MBRREL; ( USER to all parent organization relationship as per dn is loaded here)

MBRROLE & ROLE; (Role for each user is assigned to an organization, e.g. -29 for registered customer)

SELECT DN FROM USERS (DN SHOULD BE THE CORRECT ORGENTITY)


Wednesday, September 21, 2011

Retrieving WCParam value from scriptlet



Using JSPHelper to retrieve WCParam values:

JSTL:
wcparam value AdddressId:<c:out value="${WCParam.addressId}"/>

 above example using JSP Scriptlet:
<%@ page import="com.ibm.commerce.server.JSPHelper" %>

<%
String addressId=(String)com.ibm.commerce.server.JSPHelper.getParameter(request, "addressId") ;
System.out.println("addressId: "+addressId);
 %>


<%
CommandContext jstlCommandContext = (CommandContext)request.getAttribute(ECConstants.EC_COMMANDCONTEXT );
System.out.println("JSTLEnvironmentSetup languageId: "+jstlCommandContext.getLanguageId());

 %>


Using PageContext to retrieve session values in a JSP page:

<c:set var="rsOrderId" value="${WCParam.orderId}"/>

System.out.println("RS OrderID: "+pageContext.getAttribute("rsOrderId"));


Sunday, September 11, 2011

Override Access authority from Commands

checkResourcePermission The user does not have the authority to run this command. CMN0410E: The system failed to retrieve the message with  key "_ERR_USER_AUTHORITY" from "com.ibm.commerce.ras.properties.ecServerMessages"
I am sure all of us working in commerce have seen the above error  a million times and some times it is because we didn't correctly define the access privileges when creating a new command and running ACPLoad but some times it is important to override the out of the box access policies.

I would not recommend returning plain null but also find below some more restricted overrides of getResources.


public AccessVector getResources() {
  return null;
}
public AccessVector getResources()
{          final String METHOD_NAME = "getResources";            
            java.util.Vector resourcesVector = new java.util.Vector();
            Long parentOrgId= null;
            UserAccessBean userAccessBean = getCommandContext().getUser();
            Long[] userAncestors = userAccessBean.getAncestors();
            if(userAncestors != null)   {      parentOrgId = userAncestors[0];   }   
            else   {   return null;     }            
            OrganizationAccessBean orgAccessBean = new OrganizationAccessBean();
            orgAccessBean.setInitKey_MemberId(parentOrgId.toString());
            orgAccessBean.refreshCopyHelper();
            resourcesVector.addElement(orgAccessBean.getEJBRef());
            return new AccessVector(resourcesVector);
   }  
public AccessVector getResources()
{     
 final String METHOD_NAME = "getResources";
        resources = new AccessVector();
        try {
            if (resources.isEmpty()) {
                orderId = getRequestProperties().getString(ORDER_ID,
                        null);
                OrderAccessBean orderAccessBean= new OrderAccessBean();
                oab.setInitKey_orderId(orderId);  
                oab.refreshCopyHelper();
                resources.addElement(
orderAccessBean);
            }
    return resources;
}



Saturday, September 3, 2011

Order & Login flow commands

This post was requested in the comments section last week and  I tried to cover if not all, most of the commands in these flows.

Order Flow:
.
Flow
Controller Commands
Task Commands
Add/Update Items to Cart
OrderItemAddCmdImpl
OrderItemUpdateCmdImpl

Display Cart:
OrderItemDisplayCmdImpl
CheckInventoryCmdImpl
OrderItemDeleteCmdImpl
DoInventoryActionCmdImpl
Checkout/
Review
OrderPrepareCmdImpl

Submit/Place Order
OrderProcessCmdImpl


Order Calculate Command: OrderCalculateCmdImpl, This command is very heavy and is used for calculations on promotions/taxes/shipping discounts. It could be called from Cart display page and Order checkout page, it depends on the requirements and also on cart merge during login. Make sure this command is called less frequently.

Login/Registration:


Flow
Controller Commands
Registration Add/Update
UserRegistrationAddCmdImpl/
UserRegistrationUpdateCmdImpl

Registration using Admin access
UserRegistrationAdminAddCmdImpl/
UserRegistrationUpdateCmdImpl
Login
LogonCmdImpl
Password Reset
ResetPasswordCmdImpl
Asynchronous event after Password Reset
SendPasswordNotificationCmdImpl
(This one’s a task command)
Log off
LogoffCmdImpl
The Asynchronous event after password reset, there is an event that triggers SendPasswordNotificationCmd.

Friday, August 26, 2011

Programming a Schedule Job !!! Dynamic job

I find dynamic schedule jobs a very useful feature in Websphere commerce. It is very useful for jobs that require to be dynamically generated based on some programming logic in a command. e.g. if there are emails that need to be triggered based on a event or any admin action that requires a schedule job to run to generate reports.

AddJobCmd addJobCmd =
(AddJobCmd) CommandFactory.createCommand(
AddJobCmd.class.getName(),
commandContext.getStoreId());
addJobCmd.setQueryString();
addJobCmd.setForUserId();
addJobCmd.setStartTime();
addJobCmd.setPathInfo("");
addJobCmd.setUrl(); //Even though this is not checked in validate parameters, this is required
addJobCmd.setStoreId(new Integer(SITE_STORE));
addJobCmd.setCommandContext(commandContext);
addJobCmd.setAccCheck(false);
addJobCmd.execute();
addJobCmd.setAccCheck(true);


recurring Jobs needs these extra methods to be configured:

addJobCmd.setAttempts()
addJobCmd.setDelay()
addJobCmd.setInterval()