Wednesday, 29 April 2015

StoreConfigurationRegistry to access values stored in STORECONF table

StoreConfigurationRegistry to access store configuration values in the STORECONF database table from either Java code or JSP files.
The STORECONF data is not propagated from staging to production. Therefore, you can have configurations and test systems set up in your staging environment that are different from your production environment.

Java code example
From Java code, you can access the StoreConfigurationRegistry directly. 

String value = StoreConfigurationRegistry.getSingleton().getValue(storeId, "STORECONF_Name");

public String getValue(Integer storeId, String name)

JSP file example
You can use the <wcst:storeconf> tag in a JSP file to access data from the STORECONF table. The <wcst:storeconf> tag reads from the StoreConfigurationRegistry cache to provide access to the configuration parameters. This tag is provided with the WebSphere Commerce Stores tag library (stores.tld). 
In the default JSTLEnvironmentSetup.jspf file for the Aurora starter store, the library is included, as shown here:

<%@ taglib uri="http://commerce.ibm.com/foundation-fep/stores" prefix="wcst" %>

The following example shows how to use the tag in a store page to get the parameter named wc.bazaarvoice.runtime_url from the STORECONF table:

<wcst:storeconf var="bvUrl" name="wc.bazaarvoice.runtime_url" scope="request" />

scope-
page
request
session
application
If the scope parameter is not set, then the default value is page.

Inserting Data into STORECONF OR Using Dataload

insert into storeconf (storeent_id, name, value, optcounter)values (storeent_id, 'name', 'value', 0); 

Monday, 20 April 2015


LHN - Facet Management - Queries and Tables Used

List of the tables used in Facet Filtering

Existing tables (till FEP4)
ATTR
SRCHATTR
SRCHATTRPROP

New tables (FEP5+)
FACET (SELECTION – for Multifaceted selection)
FACETDESC


FACETCATGRP  (.. SEQUENCE column to handle FACET sequence in LHN)

Use case of Facet Selection
  • Facet remains in available filters list
  • First value selected decreases counts for other facets
  • Additional selected values increase counts for other facets
  • Counts for multi-value facet remain the same


Management Centre ( to handle the facet attributes)


To View the facets associated with a particular category.

Query params-
_wcf.search.facet='$facet$';
_wcf.search.exclude.facet='$filter Facet$';

To pass the selected facet values to getData
<c:forEach var="facetValue" items="${paramValues.facet}">
                <wcf:param name="facet" value="${facetValue}" />

How to Start and Stop Solr server

cd /opt/IBM/WebSphere/AppServer/profiles/<instance_name>/bin

./stopServer.sh solrServer


./startServer.sh solrServer


Once the server is up and running - this can be verified using the below URL.. 


http://localhost:<port>/solr/Default/select?q=*%3A*
CWXFD3134E: Execution of get request failed. 

Here is the exception -
[26/03/15 12:00:57:663 GMT] 00000035 bod           I   CWXFD3134E: Execution of get request failed. com.ibm.commerce.foundation.server.services.dataaccess.exception.ConfigurationException: CWXFS1003E: Cannot determine core name based on the search profile IBM_findNavigationSuggestions. Ensure this search profile is associated with a search index.

[26/03/15 12:00:57:664 GMT] 00000035 config        I com.ibm.commerce.foundation.internal.client.taglib.config.GetDataConfig$DataTypeConfig invokeClientFacadeMethod(Object clientFacade, GetType getVerb) <Null Message>
com.ibm.commerce.catalog.facade.client.CatalogNavigationViewException
at com.ibm.commerce.catalog.facade.client.AbstractCatalogFacadeClient.checkShowCatalogNavigationView(AbstractCatalogFacadeClient.java:1796)
at com.ibm.commerce.catalog.facade.client.AbstractCatalogFacadeClient.getCatalogNavigationView(AbstractCatalogFacadeClient.java:1827)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:611)


Root Cause -
This issue is due to missing values within the wc-search.xml for cores and server details

Fix 
Add the below stuff in wc-search.xml

1) Add the server details within <_config:server></_config:server>  


<_config:server name="AdvancedConfiguration_1">
        <_config:common-http URL="http://localhost/solr/"
            allowCompression="true" connectionTimeout="15000"
            defaultMaxConnectionsPerHost="600" followRedirects="false"
            maxRetries="1" maxTotalConnections="600"
            retryTimeInterval="1000" soTimeout="15000"/>
</_config:server>
<_config:server name="AdvancedConfiguration_2">
        <_config:common-http URL="http://localhost:9060/solr/"
            allowCompression="true" connectionTimeout="15000"
            defaultMaxConnectionsPerHost="600" followRedirects="false"
            maxRetries="1" maxTotalConnections="600"
            retryTimeInterval="1000" soTimeout="15000"/>
</_config:server>
<_config:server name="BasicConfiguration">
        <_config:embedded/>
</_config:server>


2) Add the cores details <_config:cores></_config:cores>


<_config:cores>
        <_config:core catalog="10001" indexName="CatalogEntry"
            language="en_US" name="MC_10001_CatalogEntry_en_US"
            path="/MC_10001/en_US/CatalogEntry" serverName="AdvancedConfiguration_2"/>
        <_config:core catalog="10001" indexName="UnstructuredContent"
            language="en_US"
            name="MC_10001_CatalogEntry_Unstructured_en_US"
            path="/MC_10001/en_US/CatalogEntry/unstructured" serverName="AdvancedConfiguration_2"/>
        <_config:core catalog="10001" indexName="CatalogGroup"
            language="en_US" name="MC_10001_CatalogGroup_en_US"
            path="/MC_10001/en_US/CatalogGroup" serverName="AdvancedConfiguration_2"/>
</_config:cores>




Friday, 19 December 2014

To generate the Java code from WSDL using axis 1.4 version and axis2

Using Axis 1.4
Download and Install
JDK -
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
-- Use  default path for the installation

axis-bin-1_4.zip or axis-src-1_4.zip
http://archive.apache.org/dist/ws/axis/1_4/

-- Unzip and place axis-1_4 in C:\

SET Environment Variables
Select Start -> Control Panel -> System -> Advanced -> Environment Variables -> System Variables

set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_25"
set PATH=%JAVA_HOME%\bin;%PATH%
set AXIS_HOME="C:\axis-1_4"
CLASSPATH = C:\axis-1_4\lib

Create Input and Output Folders
Create c:\wsdl folder and place the wsdl file provided
Create c:\output folder for Java code generation

Command to execute
C:\axis-1_4\lib>java -classpath activation.jar;mailapi.jar;axis.jar;jaxrpc.jar;saaj.jar;commons-logging-1.0.4.jar;commons-discovery-0.2.jar;wsdl4j-1.5.1.jar;log4j-1.2.8.jar; org.apache.axis.wsdl.WSDL2Java -s C:\wsdl\<WDSL_NAME>.wsdl -o C:\output -p <PACKAGE_NAME> -t
- Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
C:\axis-1_4\lib>

                Note – ignore the above error which is underlined.

More info on the command params for reference -
  -s Generate sync style code only (Default: off). Takes precedence over -a.
  -o Specify a directory path for the generated code.
  -p Specify a custom package name for the generated code.
  -t Generate a test case for the generated code.

------------------------------------------------------------
Implementation –
------------------------------------------------------------
Once we have the Java code generated from the WSDL.  We will have to create a command implementation that will invoke the webservice by passing the request parameters.  The request params for the Headers and Body will be purely based on the WDSL provided.

------------------------------------------------------------
Testing -
By passing –t as parameter to the above command Junit test case will be generated which can be used for Unit Test.


------------------------------------------------------------

Using Axis2


set ANT_HOME=C:\apache-ant-1.8.2

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_25

set PATH=C:\apache-ant-1.8.2\bin;C:\Program Files\Java\jdk1.8.0_25\bin

set ANT_OPTS=-Xms256M -Xmx512M

URL -
http://localhost:8080/axis2/services/

Command to generate Code
C:\axis2-1.6.2\bin\wsdl2java.bat -uri <WSDL_PATH> -d adb -s -ss -sd -ssi -o <OUT_PUT_FOLDER_PATH>\service


C:\axis2-1.6.2\bin\wsdl2java.bat -uri <WSDL_PATH> -d adb -o <OUT_PUT_FOLDER_PATH>\client

- Once the files are generated - Create a Client file - to invoke the webservice by setting the request params for the SOAP request.

- Use the file with name < ..Skeleton.java> to write the Business logic for the response SOAP request.


Thursday, 4 December 2014

To set the variable in JSP for partialCredentialsUsed

<c:set var="partial" value="${CommandContext.deviceFormatAdapter.sessionContext.partialCredentialsUsed}"/>    
Commands to setup Solr in Websphere Commerce 

For Catalog Solr Data Setup and Index
                C:\WCDE_ENT70\components\foundation\subcomponents\search\bin>setupSearchIndex.bat -masterCatalogId 10001

C:\WCDE_ENT70\bin>di-preprocess.bat C:\WCDE_ENT70\search\pre-processConfig\MC_10001\DB2\ -fullbuild true -force true

Bring the server up and test it using -      http://localhost/solr/Default/select?q=*%3A* 

C:\WCDE_ENT70\bin>di-buildindex.bat -masterCatalogId 10001

http://localhost/solr/MC_10001_CatalogEntry_en_US/select?q=catentry_id:10251

For Inventory Solr Data Setup and Index
                C:\WCDE_ENT70\components\foundation\subcomponents\search\bin\setupSearchIndex.bat -masterCatalogId 10001 -indexSubType Inventory

C:\WCDE_ENT70\bin>di-preprocess.bat C:\WCDE_ENT70\search\pre-processConfig\MC_10001\DB2\SubTypes\Inventory -force true

Bring the server up and test it using -      http://localhost/solr/Default/select?q=*%3A* 

C:\WCDE_ENT70\bin>di-buildindex.bat -masterCatalogId 10001 -indexSubType Inventory -force true

http://localhost/solr/MC_10001_CatalogEntry_Inventory_generic/select?q=*&fq=catentry_id:( 13331 13332 )