Saturday 24 September 2011

Enabling the attribute dictionary


If you are using an external catalog and loading your data into WebSphere Commerce, you can save time by using the attribute dictionary to load in attributes for your products, instead of creating new attributes for each product in the Management Center. The Catalogs tool only displays shared attributes meaning, you cannot update or add new attributes to the dictionary.

Before you beginDecide if you want to use the attribute dictionary only, or use the attribute dictionary and classic attribute functionality concurrently. Classic attribute functionality includes those attributes not in the attribute dictionary, where each product has it's own attributes.
Procedure
To enable the attribute dictionary and classic attribute functionality concurrently, switch the implementation of ResolveSkuCmd to ResolveSkuAllCmdImpl in CMDREG table:
Open a database command window.
Run the following SQL command: update cmdreg set classname='com.ibm.commerce.catalog.commands.ResolveSkuAllCmdImpl' where interfacename ='com.ibm.commerce.catalog.commands.ResolveSkuCmd';

To enable the attribute dictionary only, switch the implementation of ResolveSkuCmd to ResolveSkuNewCmdImpl in the CMDREG table:
Open a database command window.
Run the following SQL command: update cmdreg set classname='com.ibm.commerce.catalog.commands.ResolveSkuNewCmdImpl' where interfacename ='com.ibm.commerce.catalog.commands.ResolveSkuCmd';

Customize the Catalogs tool to hide the local attribute table to prevent users from using the table to create a new attribute in the legacy table.
Note: To change the ResolveSkuCmd implementation for one store, you create a new row in the CMDREG table with the STOREENT_ID set to the store ID. If you set the STOREENT_ID to "0", the command applies to all the stores. 

Ref: Infocenter : http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/topic/com.ibm.commerce.management-center.doc/tasks/tpnenattrdic.htm

Handling a limited length redirect URL

Handling a limited length redirect URL By default, all input parameters to the controller command are propagated to the redirect view command. If there is a limit on the number of characters in the redirect URL, this may cause a problem. An example of when the length may be limited is if the client is using the Internet Explorer browser. For this browser, the URL cannot exceed 2083 bytes. If the URL does exceed this limit,
the URL gets truncated. As such, you can encounter a problem if there are a large number of input parameters, or if you are using encryption, because an encrypted string is typically two to three times longer than a string that is not encrypted. There arethe URL gets truncated. As such, you can encounter a problem if there are a large number of input parameters, or if you are using encryption, because an encrypted string is typically two to three times longer than a string that is not encrypted. There are two approaches for handling a limited length redirect URL: 
1. Override the getViewInputProperties method in the controller command to return only the sets of parameters that are required to be passed to the redirect view command.
2. Use a specified special character in the URL parameters to indicate which parameters can be removed from the input parameter string.To demonstrate each of the preceding approaches, consider the following set of input parameters to the controller command: URL="MyView";
// All of the following are inputs to the original controller command. 
ip1="ipv1";
ip2="ipv2";
ip3="ipv3";
iq1="iqv1";
iq2="iqv2";
ir1="ipr1";
ir2="ipr2";
is="isv";
If you are overriding the getViewInputProperties method, the new method can be written so that only the following parameters are passed to the view command: ir2="ipr2"; is="isv"; Using the second approach, the view command can be invoked using special parameters to indicate that certain input parameters should be removed. For example, you can achieve the same result by specifying the following as the URL parameter: URL="MyView?ip*=&iq*=&ir1=" This URL parameter instructs the WebSphere Commerce run-time framework of the following: 
 The ip*= specification means that all parameters whose names start with ip should be removed.
The iq*= specification means that all parameters whose names start with iq should be removed. 
The ir1= specification means that the ir1 parameter should be removed.

Creating System Generated primary keys in WCS Entity Beans

Creating primary keys: The ejbCreate method is used to instantiate new instances of an entity bean. This method is automatically generated but the generated method only includes logic to initialize primary keys to a static value. You may need to ensure that the primary key is a new, unique value. In this case, you may have an ejbCreate method similar to the following code snippet:

public void ejbCreate(int argMyOtherValue) throws javax.ejb.CreateException {
//Initialize CMP fields MyKeyValue = com.ibm.commerce.key.ECKeyManager. singleton().getNextKey("table_name"); 
MyOtherValue = argMyOtherValue; 
}
In the preceding code snippet, the getNextKey method generates a unique integer for the primary key. The table_name input parameter for the method must be an exact match to the TABLENAME value that is defined in the KEYS table. Be certain to match the characters and case exactly.

In addition to including the preceding code in your ejbCreate method, you must also create an entry in the KEYS table. The following is an example SQL statement to make the entry in the KEYS table: insert into KEYS (TABLENAME, COUNTER, KEYS_ID) values ("table_name", 0, 1) Note that with the preceding SQL statement default values for the other columns in the KEYS table are accepted. The value for COUNTER indicates the value at which the count should start. The value for KEYS_ID should be any positive value. If your primary key is defined as a long data type (BIGINT for DB2 or NUMBER(38, 0) for Oracle), use the getNextKeyAsLong method.

Tuesday 13 September 2011

How to change contentType of a jsp page response at run time without using scriplet

write the following lines of code in your jsp

<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set property="contentType" target="${pageContext.response}" value="text/html;charset=UTF-8"/>

Wednesday 7 September 2011

Disabling cross-site scripting protection for the Management Center

Disabling cross-site scripting protection for the Management Center

When enabled, cross-site scripting protection rejects any user requests that contain attributes (parameters) or strings that are designated as not allowable. You can also exclude commands from cross-site scripting protection by allowing the values of specified attributes for that particular command to contain prohibited strings. Cross-site scripting protection is enabled by default, but you can disable it to match your security needs.
Procedure
  1. Open the following file:
    • LOBTools.war/WEB-INF/web.xml
    • WebSphere Commerce Developer LOBTools/WEB-INF/web.xml
    See Management Center Web application file locations for more information.
  2. Search for and remove the following snippet:
    <param-name>com.ibm.commerce.security.crosssitescriptingprovider</param-name> 
    <param-value>com.ibm.commerce.foundation.internal.client.security.impl. 
    ClassicCommerceCrossSiteScriptingProviderImpl</param-value>
  3. Save your changes and close the file.
  4. Deploy your changes.

Tuesday 6 September 2011

Unable to browse store pages when using port 80

Unable to browse store pages when using port 80
When attempting to access the home page for one of the WebSphere Commerce starter stores (for example, ConsumerDirect), an error message displays. An example of the error message follows:

A WebGroup/Virtual Host to handle /webapp/wcs/stores/servlet/ConsumerDirect/index.jsp has not been defined.

The virtual host definitions in the WebSphere Application Server might not be functioning properly.

A simple test to verify this situation is to attempt to access the starter store's home page using port 8000 instead of port 80. For example if ConsumerDirect was published, try to access the store using https://localhost:8000/webapp/wcs/stores/servlet/ConsumerDirect/index.jsp. If port 8000 was successful then the virtual host definitions will need to be updated.
To change the virtual host definitions:

    Start the WebSphere Commerce Test Server using either the Rational Application Developer interface or using the startWCServer.bat script.
    Access the WebSphere Application Server's administrative console
    Select Environment > Virtual Hosts
    Select the default_host entry
    From the "additional properties" section select "Host Aliases"
    Delete the references to port 80 and 443
    Save your change to the master configuration.
    Restart the server.

You should now be able to access the starter stores using port 80.
  

Sunday 4 September 2011

how to change the virtual host of a dynamic web project in WC application

Change the virtual host of the Web Service to WC_default_host:
  1. In the Enterprise Explorer view, expand the MyCompanyMemberServices > WebContent > WEB-INF folder.
  2. Open the ibm-web-bnd.xml file.
  3. Change the virtualHostName to " WC_default_host".
  4. Save and close the file
Don't forget to add/remove WC project from Test Server to apply the changes

    Difference between buyable & published flag


    catentdesc.published
    Indicates whether this catalog entry should be displayed for the language indicated by LANGUAGE_ID:
    0     Catalog entry should not be displayed
    1    Catalog entry should be displayed
      If a product is published then catentry.buyable indicates whether this catalog entry can be purchased individually: 1=yes and 0=no.

    Troubleshooting: Error when a catalog entry does not have a price


    If a catalog entry does not have a price there are exceptions in the log file.

    Problem

    The following exception is in the log files.
    6/2/06 13:48:55:750 CEST  3519d5d5 CommerceSrvr  E                    
    com.ibm.commerce.price.commands.SelectContractPricesCmdImpl            
    handlePriceNotFoundException CMN1011E: Unable to retrieve the price for
    catEntry 10058, quantity: 1.0, unit of measure: C62, and currency: USD.
    6/2/06 13:48:55:766 CEST  3519d5d5 CommerceSrvr  A                    
    com.ibm.commerce.catalog.beans.ProductDataBean                         
    processItemCalculatedContractPrices CMN1519I: WebSphere Commerce status
    message: "com.ibm.commerce.exception.ECApplicationException".Current   
    exception:                                                             
    Message:                                                               
       null                                                                
    Stack trace:                                                           
    com.ibm.commerce.exception.ECApplicationException                      
    at                                                                    
    com.ibm.commerce.price.commands.PriceCalculationHelper.handlePriceNotFoundException(PriceCalculationHelper.java:1112)                          
    at                                                                    
    com.ibm.commerce.price.commands.SelectContractPricesCmdImpl.selectOffer(SelectContractPricesCmdImpl.java:542)                                  
    at                                                                     
    com.ibm.commerce.price.commands.SelectContractPricesCmdImpl.performExecute(SelectContractPricesCmdImpl.java:408)                               
    at                                                                    
    com.ibm.commerce.command.ECCommandTarget.executeCommand(ECCommandTarget.java:133)                                                              
    at                                                                    
    com.ibm.ws.cache.command.CommandCache.executeCommand(CommandCache.java:333)                                                                    
    at                                                                    
    com.ibm.websphere.command.CacheableCommandImpl.execute(CacheableCommandImpl.java:163)                                                          
    at                                                                     
    com.ibm.commerce.command.AbstractECTargetableCommand.execute(AbstractECTargetableCommand.java:180)                                             
    at                                                                    
    com.ibm.commerce.price.commands.GetContractUnitPriceCmdImpl.selectPrices(GetContractUnitPriceCmdImpl.java:1651)                                
    at                                                                    
    com.ibm.commerce.price.commands.GetContractUnitPriceCmdImpl.performExecute(GetContractUnitPriceCmdImpl.java:807)                               
    at                                                                     
    com.ibm.commerce.command.ECCommandTarget.executeCommand(ECCommandTarget.java:133)                                                              
    at                                                                    
    com.ibm.ws.cache.command.CommandCache.executeCommand(CommandCache.java:333)                                                                    
    at                                                                    
    com.ibm.websphere.command.CacheableCommandImpl.execute(CacheableCommandImpl.java:163)  

    Solution

    In the com.ibm.commerce.price.commands.GetContractUnitPriceCmdImpl class customize the selectPrices(Integer storeId) method by setting the error mode to false when calling the SelectContractPricesCmd. This customization prevents an exception when a catalog entry does not have a price.

    Some basic information about catalog data model tables

    STORECAT
    This table holds the relationship between StoreEntities and the Catalogs that they offer.
    Column Name    Column Type    Description
    CATALOG_ID     BIGINT NOT NULL     The reference number of the Catalog.
    STOREENT_ID     INTEGER NOT NULL     The reference number of the StoreEntity.
    MASTERCATALOG     CHAR(1)     Specifies a master catalog for the Store. A value of 1 indicates that this Catalog is designated as a master catalog.
    LASTUPDATE     TIMESTAMP     Indicates the last time that this relationship was updated.
    OPTCOUNTER     SMALLINT     Reserved for IBM internal use.


    CATGPENREL

    This table relates catalog groups (or categories) to the catalog entries that are inside them. You can also use this table to dictate the navigational flow from catalog groups to catalog entries. Each relationship is also qualified by a Catalog ID.

    CATGROUP_ID     BIGINT NOT NULL     The source catalog group of this relationship.
    CATALOG_ID     BIGINT NOT NULL     The catalog inside of which this relationship is found.
    CATENTRY_ID     BIGINT NOT NULL     The target catalog entry of this relationship.
    RULE     VARCHAR(254)     Reserved for IBM internal use.
    SEQUENCE     DOUBLE NOT NULL DEFAULT 0     The sequence number that determines the display order of the contents of the catalog group.
    LASTUPDATE     TIMESTAMP     Indicates the last time that this relationship was updated.
    OPTCOUNTER     SMALLINT     Reserved for IBM internal use.

    CATGROUP

    This table hold the information related to a catalog group. A catalog group is similar to a generic category that can contain both other catalog groups and also catalog entries.

    CATGROUP_ID     BIGINT NOT NULL     The internal reference number of the catalog group.
    MEMBER_ID     BIGINT NOT NULL     The internal reference number that identifies the owner of the catalog group. Along with IDENTIFIER, these columns are a unique index.
    IDENTIFIER     VARCHAR(254)     The external name that is used to identify the catalog group. Along with MEMBER_ID, these columns are a unique index.
    MARKFORDELETE     INTEGER NOT NULL     Indicates if this catalog group has been marked for deletion:
    0 = No.
    1 = Yes.
    LASTUPDATE     TIMESTAMP     Indicates the last time that this catalog group was updated.
    FIELD1     VARCHAR(254)     Customizable.
    FIELD2     VARCHAR(254)     Customizable.
    OID     VARCHAR(64)     Reserved for IBM internal use.
    RANK     DOUBLE     Reserved for IBM internal use.
    OPTCOUNTER     SMALLINT     Reserved for IBM internal use.


    CATGRPREL

    This tables relates catalog groups(or categories) to child catalog group (or child categories). You can use this table to dictate the navigational flow from catalog groups to child catalog groups. Each relationship is also qualified by a Catalog ID.

    CATGROUP_ID_PARENT     BIGINT NOT NULL     The source catalog group of this relationship.
    CATGROUP_ID_CHILD     BIGINT NOT NULL     The target catalog group of this relationship.
    CATALOG_ID     BIGINT NOT NULL     The catalog in which this relationship is found.
    RULE     VARCHAR(254)     Reserved for IBM internal use.
    SEQUENCE     DOUBLE NOT NULL DEFAULT 0     The sequence number that determines the display order of the contents of the catalog group.
    LASTUPDATE     TIMESTAMP     Indicates the last time that this relationship was updated.
    CATALOG_ID_LINK     BIGINT     Reserved for IBM internal use.
    OPTCOUNTER     SMALLINT     Reserved for IBM internal use.

    STORECGRP

    This table holds the relationship between StoreEntities and the CatalogGroups that they can display and process.

    Column Name    Column Type    Description
    STOREENT_ID     INTEGER NOT NULL     The reference number of the Store Entity.
    CATGROUP_ID     BIGINT NOT NULL     The reference number of the Catalog Group.
    OPTCOUNTER     SMALLINT     Reserved for IBM internal use.



    CATENTREL

    This table holds containment relationships between catalog entries. Examples of these relationships are Product-Item, Bundle, and Package relationships. This table should not be used for peer-to-peer catalog relationships, such as cross-sells.
    Column Name    Column Type    Description
    CATENTRY_ID_PARENT     BIGINT NOT NULL     The reference number of the source catalog entry in this relationship.
    CATRELTYPE_ID     CHAR(32) NOT NULL     The type of relationship:

        PRODUCT_ITEM
        PACKAGE_COMPONENT
        BUNDLE_COMPONENT
        DYNAMIC_KIT_COMPONENT

    Foreign key to the CATRELTYPE table.
    CATENTRY_ID_CHILD     BIGINT NOT NULL     The reference number of the target catalog entry in this relationship.
    SEQUENCE     DOUBLE NOT NULL DEFAULT 0     The sequence number used to determine the display order.
    QUANTITY     DOUBLE     A quantity that can be associated with the relationship.
    GROUPNAME     VARCHAR(254)     Reserved for IBM internal use.
    FIELD1     VARCHAR(254)     Customizable.
    FIELD2     INTEGER     Customizable.
    FIELD3     DECIMAL (20,5)     Customizable.
    OID     VARCHAR(64)     Reserved for IBM internal use.
    OPTCOUNTER     SMALLINT     Reserved for IBM internal use.
    MANDATORY     CHAR(3)     Reserved for IBM internal use.

    How to customize java.util.logging.Logger class to write logs in separate file than System.out.log in Websphere commerce/ HCL commerce)

    /** * This method updated the passed in java.util.logging.Logger object with * custom file handler to write logs data form that class ...