Tuesday, April 7, 2015

Frequent JSTL use in IBM WCS

1.     Control statement :
 <if test="${!orderStatus. itemsReturned }">
                  </c:if>
2.      Setting Variables in a JSP:
 <c:set var="status" value="P"/>
 <c:set var="errorZipCounter" value="0" />
 <c:set var="accDisplaycount" value="${accDisplaycount + 1 }" />


3.  If, Else this is the equivalent of If Else as JSTL does not have the usual If Else
    <c:choose>    
 <c:when test="${!empty WCParam.source}">        
       <c:set var="source" value="${WCParam.source}" />        
  </c:when>     
 <c:otherwise>      
  <c:set var="source" value="${source}" />     
 </c:otherwise>    
  </c:choose>


4. For statement: counter is current status variable, you could get index\first\last\current\count status.
 <c:forEach items="${orderList}" var="order" varStatus="counter">
  If the orderList is a list of orderdatabeans or something, you could loop through them
 </c:forEach>
5. If statment example:
 <c:if test="${(!empty WCParam.orderStatus && (WCParam.orderStatus eq 'Y'))}">
  You can use eq,ne,lt,gt,ge,le other relational operators
 </c:if>
6.  Constructing hyperlinks: Prep-ends the name of current servlet context,URl encoding of request params and values, URl re-writing for session management.
 <a href="<c:url value='/content/sitemap.jsp'/>">View sitemap</a>

 <c:url var="productDisplayURL" value="ProductDisplay">
      <c:param name="catalogId" value="${WCParam.catalogId}"/>
      <c:param name="storeId" value="${WCParam.storeId}"/>
      <c:param name="langId" value="${WCParam.langId}"/>
      <c:param name="productId" value="${accessoryItem.itemId}"/>
 </c:url>
7.  Include content of a JSP into another JSP:
<c:import url="../../CurrentOrderSection/OrderItemDetailsDisplay.jsp">
  <c:param name="orderId" value="${WCParam.orderId}"/>
  </c:import>

  <% out.flush(); %>
  <c:import url="${storeDir}include/footer.jsp"/>
  <% out.flush(); %>

  <% out.flush(); %><c:import url="{storeDir}include/header.jsp"/><% out.flush(); %>
8. Removes a variable from scope:
                 <c:remove var="wishListURL" scope="page"/>
9. Print the value: Also helpful to print values in JavaScript. The <c:out> tag evaluates an expression and outputs the result on the page
 status:<c:out value="${WCParam.status}"/>
 firstName:<c:out value="${orderDetailsVB.orderBillingAddress.firstName}"
 <script language="javascript" src="<c:out value="${storeJavascriptDir}/browser_detect.js" />"></script>
10. Using functions: There are several functions that are very helpful
 var paramvalues = "<c:out value="${fn:substring(config.params, 1, -1)}" escapeXml="false"/>";
 <c:set var="dispalyPrice" value="${fn:substringAfter(orderItemTotalPrice,)}"/>
 <c:when test="${fn:indexOf(locale, 'en') >= 0}">
 </c:when>
11. useBean to instantiate and auto populate the bean

 <wcbase:useBean id="productVB" classname="com.abc.catalog.beans.ItemViewBean"  scope="request" >    
   <c:set target="${productVB}" property="itemId" value="${WCParam.catentryId}" />    

</wcbase:useBean>  

Monday, April 6, 2015

WebSphere Commerce Architecture

WebSphere Commerce Architecture

The following software components are associated with WebSphere Commerce:
1.    Web Server
2.    WebSphere Application Server
3.    WebSphere Commerce Developer.


 





WebSphere Commerce Application Layers

WebSphere Commerce Application architecture consists of 7 layers. Each of these layers has the different functionality















Database schema
It is the bottom layer which stores all data from the WebSphere Commerce Server. Examples of the tables that are stored in database can be Order Table,
Member Table, CatEntry Table.
Persistence layer
This layer registers the data and operations made using WebSphere system. The layer represents entities used to encapsulate the data-centric logic that is needed to take information from database. They act like an interface between the business components and the database.

Business logic
It contains the actual actions of the WebSphere Commerce Server. In this layer the business rules are implemented using the command pattern. There are two types of commands: controller commands and task commands. Implementation is made independently of the presentation layer.
Service layer
This Layer includes channel independent mechanism that allows accessing
WebSphereCommerce business logic. It shows the business logic to the outside world. It supports two transport mechanisms: local Java binding and Web services.

Presentation layer
The task of the layer is to display results. There are two types of presentation layer supported by IBM WebSphere Commerce. The first of it is Web presentation layer, the display is rendered using JSP files. The second type is rich client, for this type presentation is rendered using Eclipse views and editors implemented with SWT components.
Business processes
Business processes show the processes available in WebSphere Commerce.
They are divided, according to the business model, into three areas:
Administrative processes, starter stores, solutions.
Business models
Business models describe the situation in which WebSphere Commerce products can be used to reach the goals. There are five business models provided by WebSphere Commerce: B2B (Business to business) direct, Consumer direct, Demand chain, Hosting, Supply chain. The sample starter stores are created based on these business models, and can be developed for users’ own needs.

WebSphere Commerce presentation layer
The view layer of the Model-View-Controller (MVC) design pattern is implemented using the JSP. The view layer uses data beans to retrieve and format data from the database. It also decides if the request should be sent to a browser or streamed out as XML. JSP files separate data content from presentation.
Below figure shows how the presentation layer works when the user uses
WebSphere Commerce store pages.
1. The user is browsing store pages
2. The servlet is getting the store data from servers using Java beans
3. JSP uses the data to display the information on the store pages
4. JSP interacts with store data via Java beans


Thursday, April 2, 2015

Installing the SQL Profiler on the server

Installing the SQL Profiler on IBM RAD

1.      Download RAD-SQL Profiler folder from the sample zip file.
2.      Copy the jdbcProfiler.jar into your D:\IBM\SDP\runtimes\base_v7\lib\ext directory
3.      Start your WebSphere Commerce Toolkit.


4.      In your WebSphere Commerce Toolkit workspace, make sure you are in the J2EE perspective.
6. For BD2 : Go to 'WC/META-INF/ibmconfig/cells/defaultCell/applications/defaultApp/deployments/defaultApp/resource.xml ' and change the implementationclassName of JDBC as below,      

IBM DB2 Type 4 JCC com.ibm.issw.jdbc.wrappers.WrappedDB2JCCDataSource

7. Unzip 'updatesite' and now go to RAD workspace,
go to Help --> Software Updates --> Available Software and click on 'Add Site' and select Local, now point to the updatesite folder which we unzipped. Now install it by selecting all default values. After this RAD will be restarted.

8. Now clean and publish the workspace, and restart the server, verify SQL profiler is working, Open SQL profiler repositories and click on the green play button to connect it, Now we can see all the SQL for the events ( like productDisplay page ) done on the server.

Refrence : SQL Profiler

Friday, March 20, 2015

OrderTrashCan Feature in IBM WCS

Deleting order items and requisition lists
When a user deletes an order item or requisition list item the table rows representing those items are removed from the database. If enabled, these rows are updated to belong to the trashcan. You can clear the trashcan by running the OrderTrashCanClear scheduled job which will delete the rows, or by using the Database Clean up utility. This feature is disabled by default.

It is highly recommended that you clean your database of order items both before you enable the OrderTrashCan feature, and periodically afterwards. Order item deletion is a common operation, and as a result, a large number of deleted order items can build up in the ORDERITEMS table.

1. Open wc-sever.xml configuration file
2. Within the file, the text can be put next to "ExpectedInventorySynchronize" element.


TrashCanRequisitionListSegmentLen="30"
TrashCanOrderItemSegmentLen="50"
TrashCanEnabled="true"/>

This setting deletes order item entries from the ORDERITEMS table. If TrashCanEnabled is set to "true", when a user deletes an order item or requisition list item, the table rows representing those items are not deleted from the database. Instead, the items are updated to belong to the trashcan.

Enabling Order Trashcan feature

In wc-server.xml change the value of TrashcanEnabled="true"

Asset managment in IBM WCS

Asset managment in IBM WCS

Managed assets are files that are uploaded by business users to be used for store marketing or product supplements. They are added to Asset tool or the marketing tool in MC.

1. Managed assets, when uploaded through MC, are first stored in CMFILE, CMSMALLFILE and CMLARGEFILE tables of WCS DB.

2. From there, the scheduled job "ScheduledContentManagedFileEARUpdateCmd" evaluates its set of criteria in the WCS configuration file (wc-server.xml). The criteria and their default values are :-

minNumOfFilesForUpdate - the minimum number of files for an update to occur.
minSecFromLastUpload - The minimum number of seconds since the last update.

3. The files are extracted from DB and placed into the EAR of the staging environment.

4. These assets are then pushed to the production environments with the fileprop utility when when stagingprop called. 

Tuesday, March 17, 2015

Invalidating Cache: Data Cache Invalidation

Since Data Cache invalidation is self managed, We should not need to understand the underlying structure, but you may be curious about how Data Cache manages invalidations, or require additional information about this for your site tuning.


Data Cache invalidation IDs format in CACHEIVL

The Data cache dependency IDs are based upon which table is being cached, and what type of operation is performed to create this data. CACHEIVL entries are created by database triggers, and some Commerce processes, like Marketing or Solr. By default, CACHEIVL rows are created with a DATAID column value in this format:

WCx+TableName+colName1+colName2:%:colVal1:%:colVal2

Where x represents the type of operation that was performed, and the colName/colValue information is the unique index information about the record that was updated, so that the data cache can target the cache invalidation.  An example DATAID column value could be WCT+CATENTRY+CATENTRY_ID:%:10501, which would signify that the CATENTRY table row with CATENTRY_ID 10501 was updated, but we are not sure what operation took place.  The other operation symbols that can be used here are 'D' for deletes, or 'N' for a non-delete operation.

Monday, March 16, 2015

Message Key: _ERR_INVALID_COOKIE

Message Key: _ERR_INVALID_COOKIE


Issue : RequestedSessionIdFromURL,boolean bSingleSignOn) CMN1039E: An invalid cookie was received for the user, your logonId may be in use by another user.
[3/16/15 10:47:41:815 GMT] 000000a3 SystemOut     O ErrorDataBean:
Originating command:
Message Type: 1
Message Key: _ERR_INVALID_COOKIE
Message: CMN3101E The system is unavailable due to "{0}".


Resolution : When using Firefox or Safari browser, and a guest session
expired. Customer will see Generic System Error page 

Open : Stores\WebContent\GenericSystemError.jsp

Search for key : _ERR_INVALID_COOKIE

try {
      ErrorDataBean errorBean = new ErrorDataBean ();
      com.ibm.commerce.beans.DataBeanManager.activate (errorBean, request);
      if (errorBean.getMessageKey().equals("_ERR_INVALID_COOKIE"))
      {
                  Cookie cookies [] = request.getCookies ();
                  Cookie myCookie = null;
                  if (cookies != null){
                  System.out.println ("Cookies Issue");
                        for (int i = 0; i < cookies.length; i++) {
                              if (cookies [i].getName().equals ("WC_USERACTIVITY")) {
                                    myCookie = cookies[i];
                                    break;
                              }
                        }
                  }
                  if (myCookie != null)
                  {
                  System.out.println ("Cookies Issue -Here");
                        myCookie.setMaxAge(0);
                        myCookie.setValue("");
                        response.addCookie(myCookie);
                  }
String fwhostName = "http://" + request.getHeader("host")
 // To resolve append with below syntax (or) Redirect to home page
+"/webapp/wcs/stores/servlet/TopCategoriesDisplay?storeId=12556&catalogId=33057";
            response.sendRedirect(fwhostName);
      }
      System.out.println ("ErrorDataBean:\n" + errorBean.toString()+"\n");
%>