Showing posts with label Foundational. Show all posts
Showing posts with label Foundational. Show all posts

Retrieving external URL parameters in WebSphere portal environment (using com.ibm.wps.pb.utils.portlet. PortletUtils)


PortletUtils is a utility class which is provided by websphere portal server. With help of JSR286, it provides some method which really useful. 



PortletUtils.getHttpServletRequest(javax.portlet.PortletRequest portletrequest)

http://localhost:10039/wps/myportal/MYPAGE?test=sample

HttpServletRequest req=PortletUtils.getHttpServletRequest(request);
System.out.println("req.getParameter('test'):"+req.getParameter("test"));  // sample is printed

PortletUtils.getPortletDefinitionId(PortletConfig portletconfig)
String portletUniqueName = "";
ObjectID objID = PortletUtils.getPortletDefinitionId(getPortletConfig());
if(null != objID) {
portletUniqueName = objID.getUniqueName();
}

PortletUtils.getPortletDefinitionId(javax.portlet.PortletRequest portletrequest)
String portletUniqueName = "";
ObjectID objID = PortletUtils.getPortletDefinitionId(request)
if(null != objID) {
portletUniqueName = objID.getUniqueName();
}

PortletUtils.getHttpServletResponse(javax.portlet.PortletResponse portletresponse)
HttpServletResponse req=PortletUtils.getHttpServletRequest(response);

PortletUtils.getUser(javax.portlet.PortletRequest portletrequest)
     User user= PortletUtils. getUser (request);

PortletUtils.getPageId(HttpServletRequest httpservletrequest)
String pageuniquename = "";
ObjectID objID = PortletUtils.getPageId(req);
if(null != objID) {
pageuniquename = objID.getUniqueName();
}.

How to enable automatic JSP reloading of Portal pages?

To view changes to your theme and skins JSP's without restarting the portal server, you can force the application server to automatically check for new versions of JSP's. While this is ideal for development and testing purposes, automatic JSP reloading should be disabled in a production environment because of performance issues. 

Follow these steps to enable automatic JSP reloading: 

Portal 6.x and below

1. Open the file was_profile_root/config/cells/cell_name/applications/wps.ear/deployments/wps/wps.war/WEB-INF/ibm-web-ext.xmi 

Find the following entry in this file: 3. <webappext:WebAppExtension xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:webappext="webappext.xmi" xmlns:webapplication="webapplication.xmi" xmlns:commonext="commonext.xmi" xmlns:common="common.xmi" xmi:id="IBM_WPS_Ext" reloadInterval="3"reloadingEnabled="false"  fileServingEnabled="true" directoryBrowsingEnabled="false" serveServletsByClassnameEnabled="false" preCompileJSPs="false"> 

2. Change the value for reloadingEnabled to true. 
3. Save the file. 
4. Restart the portal server. 

After completing these steps, JSPs are automatically reloaded when they are changed. However, to view changes to a JSP that is included by another (parent) JSP, you must also change the parent JSP to indicate that it must be reloaded by the server.

Portal 7 & 8 

To enable reload of the static resources, make the change to the Default.jsp(CustomTheme8Dynamic/WebContent/themes/html/Default.jsp – Line 25 following):

--%><r:dataSource uri='<%="spa:" + pageContext.getAttribute("currentNavNodeID", PageContext.REQUEST_SCOPE)%>' escape="none"><%-- 
--%><r:param name="themeURI" value="${themeTemplateURI}"/><%-- 
--%><r:param name="mime-type" value="text/html"/><%-- 
--%><r:param name="max-age" value="2"/><%-- 
--%></r:dataSource><%--

Also, make sure that

CustomTheme8Dynamic/WebContent/WEB-INF/ibm-web-ext.xmi 
CustomTheme8Static/WebContent/WEB-INF/ibm-web-ext.xmi

are set to the following : reloadingEnabled="true". Following are the steps

Make sure that you have valid ibm-web-ext.xmi file at following theme location

\wp_profile\config\cells\your_cell\applications\your_ear\deployments\your_app\your_war\WEB-INF

Once the file is located, change the following parameter in the same file.

reloadEnabled = true

<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.ejs.models.base.extensions.webappext:WebAppExtension xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:com.ibm.ejs.models.base.extensions.webappext="webappext.xmi" xmi:id="WebAppExtension_1354713252538">
<webApp href="WEB-INF/web.xml#WebApp_ID"/>
<jspAttributes xmi:id="JSPAttribute_1354713252538" name="reloadEnabled" value="true"/>
<jspAttributes xmi:id="JSPAttribute_1354713252546" name="reloadInterval" value="10"/>
</com.ibm.ejs.models.base.extensions.webappext:WebAppExtension>

Save the file and restart the portal server. Once this is done, you also need to restart the application for the jsp changes to take into effect. JSP reloading should be disabled in a production environment because of performance issues.

How to modify the text which is displayed in the banner of your Portal page?

The text that is displayed in the banner of the portal page is defined in the file calledengine.properties. This file is is located in the JAR file named wp.ui.jar in the directory,  

/PortalServer_root/ui/wp.ui/shared/app

For multilingual sites, the file can have a language suffix corresponding to the locale, for example,engine_es.properties for Spanish etc. If Portal cannot determine the client locale, the banner text is defined in engine.properties. Follow the below steps to change the banner text for each language that is supported by your portal site. 

1. Extract the file engine.properties to the /PortalServer_root/ui/wp.ui/shared/app/nls directory. 

2. Edit the file engine.properties and change the title parameter to the name that you want to be displayed in the portal banner. 

3. Save and close engine.properties. 

4. Restart the server to view the changes.

How to add/create support for new language in WebSphere Portal?

As you all know WebSphere Portal has already been translated into a number of languages but if you would like to add another new language into it (for example: Vietnamese Language) you can easily do that by following the below simple steps.

  • Open the CreateLanguage.xml file available under following folder \IBM \ WebSphere \ PortalServer \ doc \ xml-samples \. You can create a copy of this xml file as per your requirement or use an existing one.
<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" type="update"
                xsi:noNamespaceSchemaLocation="PortalConfig_8.0.0.xsd">
<portal action="locate">
        <language action="update" bidi="false" domain="rel" locale="vi">
              <localedata locale="en">
                  <title>Vietnamese</title>
              </localedata>
       </language>
</portal>
</request>
  • Use the xmlaccess utility to run the following command.
xmlaccess.bat -url localhost:10040/wps/config -in CreateLanguage.xml -out result.xml
xmlaccess.sh -url localhost:10040/wps/config -in CreateLanguage.xml -out result.xml 
where CreateLanguage.xml is the input xml file and result.xml is the output xml file.

Note: You should have admin rights to import the new language.

Database Scripts for creating Portal database on DB2

For migrating WebSphere Portal database from Derby (default portal database) to other database like DB2 you need to first create the databases in DB2. Portal uses following 6 databases to store different kind of 
information so the first step is to create the following databases in DB2.
1. Release 
2. Community 
3. Customization 
4. JCR 
5. Feedback 
6. Likeminds 


Following scripts create all the databases required by the Portal on DB2. For executing these scripts open DB2 Command window and copy and paste each of the commands mentioned in the script one by one or you can also copy and paste them as a single script.If everything goes well, you will saw a successful message at the end.

Release database

db2 "CREATE DB release using codeset UTF-8 territory us PAGESIZE 8192" 
db2 "UPDATE DB CFG FOR release USING applheapsz 4096" 
db2 "UPDATE DB CFG FOR release USING app_ctl_heap_sz 1024" 
db2 "UPDATE DB CFG FOR release USING stmtheap 32768" 
db2 "UPDATE DB CFG FOR release USING dbheap 2400" 
db2 "UPDATE DB CFG FOR release USING locklist 1000" 
db2 "UPDATE DB CFG FOR release USING logfilsiz 4000" 
db2 "UPDATE DB CFG FOR release USING logprimary 12" 
db2 "UPDATE DB CFG FOR release USING logsecond 20" 
db2 "UPDATE DB CFG FOR release USING logbufsz 32" 
db2 "UPDATE DB CFG FOR release USING avg_appls 5" 
db2 "UPDATE DB CFG FOR release USING locktimeout 30" 
db2 "UPDATE DB CFG FOR release using AUTO_MAINT off"

Community database

db2 "CREATE DB commun using codeset UTF-8 territory us PAGESIZE 8192" 
db2 "UPDATE DB CFG FOR commun USING applheapsz 4096" 
db2 "UPDATE DB CFG FOR commun USING app_ctl_heap_sz 1024" 
db2 "UPDATE DB CFG FOR commun USING stmtheap 32768" 
db2 "UPDATE DB CFG FOR commun USING dbheap 2400" 
db2 "UPDATE DB CFG FOR commun USING locklist 1000" 
db2 "UPDATE DB CFG FOR commun USING logfilsiz 4000" 
db2 "UPDATE DB CFG FOR commun USING logprimary 12" 
db2 "UPDATE DB CFG FOR commun USING logsecond 20" 
db2 "UPDATE DB CFG FOR commun USING logbufsz 32" 
db2 "UPDATE DB CFG FOR commun USING avg_appls 5" 
db2 "UPDATE DB CFG FOR commun USING locktimeout 30" 
db2 "UPDATE DB CFG FOR commun using AUTO_MAINT off"

Customization database

db2 "CREATE DB custom using codeset UTF-8 territory us PAGESIZE 8192" 
db2 "UPDATE DB CFG FOR custom USING applheapsz 4096" 
db2 "UPDATE DB CFG FOR custom USING app_ctl_heap_sz 1024" 
db2 "UPDATE DB CFG FOR custom USING stmtheap 32768" 
db2 "UPDATE DB CFG FOR custom USING dbheap 2400" 
db2 "UPDATE DB CFG FOR custom USING locklist 1000" 
db2 "UPDATE DB CFG FOR custom USING logfilsiz 4000" 
db2 "UPDATE DB CFG FOR custom USING logprimary 12" 
db2 "UPDATE DB CFG FOR custom USING logsecond 20" 
db2 "UPDATE DB CFG FOR custom USING logbufsz 32" 
db2 "UPDATE DB CFG FOR custom USING avg_appls 5" 
db2 "UPDATE DB CFG FOR custom USING locktimeout 30" 
db2 "UPDATE DB CFG FOR custom using AUTO_MAINT off"

JCR database

db2 "CREATE DB jcrdb using codeset UTF-8 territory us PAGESIZE 8192" 
db2 "UPDATE DB CFG FOR jcrdb USING applheapsz 4096" 
db2 "UPDATE DB CFG FOR jcrdb USING app_ctl_heap_sz 1024" 
db2 "UPDATE DB CFG FOR jcrdb USING stmtheap 32768" 
db2 "UPDATE DB CFG FOR jcrdb USING dbheap 2400" 
db2 "UPDATE DB CFG FOR jcrdb USING locklist 1000" 
db2 "UPDATE DB CFG FOR jcrdb USING logfilsiz 4000" 
db2 "UPDATE DB CFG FOR jcrdb USING logprimary 12" 
db2 "UPDATE DB CFG FOR jcrdb USING logsecond 20" 
db2 "UPDATE DB CFG FOR jcrdb USING logbufsz 32" 
db2 "UPDATE DB CFG FOR jcrdb USING avg_appls 5" 
db2 "UPDATE DB CFG FOR jcrdb USING locktimeout 30" 
db2 "UPDATE DB CFG FOR jcrdb using AUTO_MAINT off"

Feedback database

db2 "CREATE DB fdbkdb using codeset UTF-8 territory us PAGESIZE 8192" 
db2 "UPDATE DB CFG FOR fdbkdb USING applheapsz 4096" 
db2 "UPDATE DB CFG FOR fdbkdb USING app_ctl_heap_sz 1024" 
db2 "UPDATE DB CFG FOR fdbkdb USING stmtheap 32768" 
db2 "UPDATE DB CFG FOR fdbkdb USING dbheap 2400" 
db2 "UPDATE DB CFG FOR fdbkdb USING locklist 1000" 
db2 "UPDATE DB CFG FOR fdbkdb USING logfilsiz 4000" 
db2 "UPDATE DB CFG FOR fdbkdb USING logprimary 12" 
db2 "UPDATE DB CFG FOR fdbkdb USING logsecond 20" 
db2 "UPDATE DB CFG FOR fdbkdb USING logbufsz 32" 
db2 "UPDATE DB CFG FOR fdbkdb USING avg_appls 5" 
db2 "UPDATE DB CFG FOR fdbkdb USING locktimeout 30" 
db2 "UPDATE DB CFG FOR fdbkdb using AUTO_MAINT off"

Likeminds database

db2 "CREATE DB lmdb using codeset UTF-8 territory us PAGESIZE 8192" 
db2 "UPDATE DB CFG FOR lmdb USING applheapsz 4096" 
db2 "UPDATE DB CFG FOR lmdb USING app_ctl_heap_sz 1024" 
db2 "UPDATE DB CFG FOR lmdb USING stmtheap 32768" 
db2 "UPDATE DB CFG FOR lmdb USING dbheap 2400" 
db2 "UPDATE DB CFG FOR lmdb USING locklist 1000" 
db2 "UPDATE DB CFG FOR lmdb USING logfilsiz 4000" 
db2 "UPDATE DB CFG FOR lmdb USING logprimary 12" 
db2 "UPDATE DB CFG FOR lmdb USING logsecond 20" 
db2 "UPDATE DB CFG FOR lmdb USING logbufsz 32" 
db2 "UPDATE DB CFG FOR lmdb USING avg_appls 5" 
db2 "UPDATE DB CFG FOR lmdb USING locktimeout 30" 
db2 "UPDATE DB CFG FOR lmdb using AUTO_MAINT off"

JCR database update script

You need to perform following additional steps on the JCR DB to match it with the Portal's requirements. replace & with the one you used to create the database. 

db2 "CONNECT TO jcrdb USER userid USING pasword" 
db2 "CREATE BUFFERPOOL ICMLSFREQBP4 SIZE 1000 PAGESIZE 4 K" 
db2 "CREATE BUFFERPOOL ICMLSVOLATILEBP4 SIZE 8000 PAGESIZE 4 K" 
db2 "CREATE BUFFERPOOL ICMLSMAINBP32 SIZE 8000 PAGESIZE 32 K" 
db2 "CREATE BUFFERPOOL CMBMAIN4 SIZE 1000 PAGESIZE 4 K" 
db2 "CREATE REGULAR TABLESPACE ICMLFQ32 PAGESIZE 32 K MANAGED BY SYSTEM USING ('ICMLFQ32') BUFFERPOOL ICMLSMAINBP32" 
db2 "CREATE REGULAR TABLESPACE ICMLNF32 PAGESIZE 32 K MANAGED BY SYSTEM USING ('ICMLNF32') BUFFERPOOL ICMLSMAINBP32" 
db2 "CREATE REGULAR TABLESPACE ICMVFQ04 PAGESIZE 4 K MANAGED BY SYSTEM USING ('ICMVFQ04') BUFFERPOOL ICMLSVOLATILEBP4" 
db2 "CREATE REGULAR TABLESPACE ICMSFQ04 PAGESIZE 4 K MANAGED BY SYSTEM USING ('ICMSFQ04') BUFFERPOOL ICMLSFREQBP4" 
db2 "CREATE REGULAR TABLESPACE CMBINV04 PAGESIZE 4 K MANAGED BY SYSTEM USING ('CMBINV04') BUFFERPOOL CMBMAIN4" 
db2 "CREATE SYSTEM TEMPORARY TABLESPACE ICMLSSYSTSPACE32 PAGESIZE 32 K MANAGED BY SYSTEM USING ('icmlssystspace32') BUFFERPOOL ICMLSMAINBP32" 
db2 "CREATE SYSTEM TEMPORARY TABLESPACE ICMLSSYSTSPACE4 PAGESIZE 4 K MANAGED BY SYSTEM USING ('icmlssystspace4') BUFFERPOOL ICMLSVOLATILEBP4" 

db2 "DISCONNECT jcrdb" 
db2 "TERMINATE"

Note : Depending on the environment you are setting up you may need to tweak the above scripts a little like increasing the pagesize etc. to achieve the desired level of performance. You can migrate all the Portal DB's into one DB as well but its recommended to have each of them separately for better performance.

Step by Step transferring Portal 6 database from Derby to DB2

By default, WebSphere Portal is installed with Derby database to store all Portal information. Portal uses following six databases in total to store different kind of information. Following are the database names. 

Portal DB

Portal provides following 3 options for creating and transferring the databases: 

1. Create one database and transfer all the databases to this single database. 
2. Create separate databases on the same server and transfer the portal data to them. 
3. Create separate databases on different server (distributed environment) and transfer the portal data to them. 

This article will demonstrate how to transfer the portal databases to other databases on the same server, but you can use the same steps to transfer the database to one database or databases created on separate servers. 

After configuring your database server(s) by installing DB2 (or Oracle/MS SQL Server) and creating databases using the DB2 creation script you need to run the following to transfer the databases: 

<wp_profile_root>\PortalServer\wizard\configwizard.bat

Running the above batch command will open the following screen: 


Portal DB Migration


Click on “Next” to go to next screen. 


Portal DB Migration


Select “Transfer data to other databases” and click next to go to next step. 


Portal DB Migration


Provide WebSphere Application Server username and password to start WebSphere_Portal server. Click “Next” to go to next screen. 


Portal DB Migration


Wizard will check if server is started or not. If server is not started then it will start the server before moving to next screen. 


Portal DB Migration


Select “IBM Derby” from the options to select the source database. Click “Next” to go to next screen. 


Portal DB Migration


Select “IBM DB2 Universal Database” to select the target database. Click “Next” to go to next screen. 


Portal DB Migration


Specify database server name or provide IP address in “DbHostName” and “DbPort”. Also specify complete path for “DbLibrary” files. You need to specify the location for the jar files “db2jcc.jar” and “db2jcc_license_cu.jar”. Click “Next” to go to next screen. 



Portal DB Migration

Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “community” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen. 


Portal DB Migration


Wizard will validate the information provided by you before moving to next screen. You just have to wait for it to finish verification to go to next screen. 


Portal DB Migration


Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “customization” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen. 


Portal DB Migration


Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “Feedback” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen. 


Portal DB Migration


Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “jcr” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen. 


Portal DB Migration


Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “likeminds” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen. 

Portal DB Migration



Specify “DbName”, “DbUser” (having admin access) and “DbPassword” for “release” database. You can specify other custom information as well according to your need. Click “Next” to go to next screen. 


Portal DB Migration


Check all the information in that you specified in this screen. If everything is correct then click “Next” to start the transfer of the databases. You will get successful message if everything goes well without any error. 

You can now start and stop the servers to propagate the changes. If servers start without any errors and you are able to login successfully using GUI then you have successfully transferred the databases.