Friday, September 25, 2009

Prepare url dynamically in Javascript

<% String sWebAppPath=UIUtil.getWebappPath(request); %>string url = window.location.protocol + "://" + window.location.hostname + "/" + <%=sWebAppPath%> + "/" + ViewName

Wednesday, September 23, 2009

Creating Cookie in a Session

The ViewCommandContext offers the getResponse() method which can be used to gain access to the HttpServletResponse, from where you can add the cookies.

http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=/com.ibm.commerce.api.doc/com/ibm/commerce/command/ViewCommandContext.html

For example:

if ( commandContext instanceof com.ibm.commerce.command.ViewCommandContext ) {
 com.ibm.commerce.command.ViewCommandContext v = (com.ibm.commerce.command.ViewCommandContext)commandContext;
 javax.servlet.http.HttpServletResponse response = (javax.servlet.http.HttpServletResponse)v.getResponse();
 javax.servlet.http.Cookie myCookie = new javax.servlet.http.Cookie("name","value");
 response.addCookie(myCookie);
} 

Tuesday, September 22, 2009

Home Page - Getting Admin Console in Store Front

https://localhost:8004/webapp/wcs/orgadmin/servlet/BuyAdminConsoleView?
XMLFile=buyerconsole.BuySiteAdminConsole&
customFrameset=common.MerchantCenterFramesetRHS&
webPathToUse=/webapp/wcs/stores/servlet&
sidebarViewName=SidebarDisplayView&
headerViewName=HeaderDisplayView&
footerViewName=FooterDisplayView&
actionName=organization&langId=-1&
storeIdToUse=10051&
buyer=true

Monday, September 21, 2009

Create DB Schema (When Instance exists)

Command For Create Schema (When Instace exists):
/opt/IBM/WebSphere/CommerceServer60/bin/createdb.oracle.sh /opt/IBM/WebSphere/CommerceServer60/instances/instance-name/properties/createInstance.properties

Check the log for Errors:
/opt/IBM/WebSphere/CommerceServer60/logs/populateDB_oracle.log

Monday, September 14, 2009

TNS NAME BLOCKED - SOLUTION

When lsnrctl status result as follows:
Instance "music", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully

Solution:
Connect as sysdba

SELECT STATUS FROM V$INSTANCE;
ALTER DATABASE MOUNT;
ALTER DATABASE OPEN;


Friday, September 11, 2009

Start and Stop Servers

Start Commerce Server:
/opt/IBM/WebSphere/AppServer/profiles/instance-name/bin/startServer.sh server1

Stop Commerce Server:
/opt/IBM/WebSphere/AppServer/profiles/instance-name/bin/stopServer.sh server1

Start WebServer:
/opt/IBMIHS/bin/apachectl -f /opt/IBM/WebSphere/CommerceServer60/instances/instance-name/httpconf/httpd.conf -k start

Stop WebServer:
/opt/IBMIHS/bin/apachectl -f /opt/IBM/WebSphere/CommerceServer60/instances/instance-name/httpconf/httpd.conf -k stop

HTTP Conf Syntax Check:
/opt/IBMIHS/bin/apachectl -f /opt/IBM/WebSphere/CommerceServer60/instances/instance-name/httpconf/httpd.conf -t

TNS-Names Settings

/opt/ora10g/product/10.2.0/client_1/network/admin/tnsnames.ora

suresh1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = IP-Address)(PORT = 1524))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = suresh1.sureshdomain.com)
)
)

Create user for WCS

drop user suresh1usr cascade;

drop tablespace suresh1db including contents and datafiles;

CREATE TABLESPACE suresh1db DATAFILE '/oracle/u01/app/oracle/oradata/suresh1/suresh1db.dbf' SIZE 4M AUTOEXTEND ON NEXT 2M MAXSIZE UNLIMITED;

CREATE USER suresh1usr IDENTIFIED BY suresh1usrs00 DEFAULT TABLESPACE suresh1db QUOTA UNLIMITED ON suresh1db;

grant all privileges to suresh1usr;

ALTER USER suresh1usr TEMPORARY TABLESPACE TEMP;

CONNECT suresh1usr/suresh1usrs00;

CREATE SCHEMA AUTHORIZATION suresh1usr;

Commerce Product Updates Installation Check

/opt/IBM/WebSphere/CommerceServer60/properties/version/update/backup/NIFStack.xml

/opt/IBM/WebSphere/CommerceServer60/instances/instance-name/properties/version/update/backup/NIFStack.xml

SAR Publish Guide

Place your Store file under the following path:
/opt/IBM/WebSphere/CommerceServer60/starterstores

Folder structure should be:
SureshStore/samplecatalogs/SureshStoreCatalogData.sar
SureshStore/SureshStore.sar

/opt/IBM/WebSphere/AppServer/profiles/instance-name/installedApps/WC_instance-name_cell/WC_instance-name.ear/xml/tools/devtools/SARRegistry.xml

Connect to Commerce Admin Console as site level
Store Archives -> Publish
Select the appropriate Store and click on Publish.

HostName only then redirect to URL

Senario:
When people are hitting to hostname only like "suresh.world.com", that request should be redirect to URL, that requirement can be achived by following snippet.

Code snippet:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^suresh\.world\.com [NC]
RewriteRule ^/?$ http://suresh.world.com/webapp/wcs/stores/servlet/TopCategoriesDisplay?storeId=10001&catalogId=10050&homePage=Y [R=permanent,L]

WAS Deployment Scripts

cd /opt/IBM/WebSphere/AppServer/bin
./wsadmin.sh

$AdminApp update WC_instance-name partialapp {-contents /home/wcuser/temp/Packaging.zip}

$AdminConfig save

$AdminApp update WC_instancename modulefile {-operation addupdate -contents /home/wcuser/temp/WebSphereCommerceServerExtensionsData.jar -contenturi WebSphereCommerceServerExtensionsData.jar -nodeployejb -usedefaultbindings -defaultbinding.datasource.jndi "jdbc/WebSphere Commerce Oracle Datasource demo" -defaultbinding.cf.jndi "jdbc/WebSphere Commerce Oracle Datasource demo" -defaultbinding.cf.resauth Per_Connection_Factory}

$AdminConfig save

import and export

exp userid=usr/usrpass@tnsname consistent=Y statistics=NONE file=/home/ora10g/backup/db_backup_11Sep2009.dmp log=/home/ora10g/backup/db_backup_11Sep2009.log full=Y

imp userid=usr/usrpass@tnsname fromuser=usr touser=usr1 file=/home/ora10g/backup/db_backup_11Sep2009.dmp log=/home/ora10g/backup/db_backup_imp_XXSep2009.log full=N