How to Enable and Disable Managed pages feature in WebSpshere Portal Server 8.0?

By default, managed pages is enabled in WebSphere Portal Server 8.0. In order to disable the managed pages, one can use the following config engine task.

ConfigEngine.bat disable-managed-pages -DPortalAdminPwd=wpsadmin -DWasPassword=wasadmin

Note: Do not attempt to enable managed pages on a server where managed pages are already enabled. If you previously disabled managed pages and want to re-enable the feature, you must ensure that the "Portal Site" library is empty first. If you fail to remove page artifacts from the previous configuration, the resulting portal might not work properly.

Disabling managed pages has the following effects:

By default, each virtual portal has its own specific workspace where content is stored. When you disable managed pages, only a single workspace for the default virtual portal is available. The workspaces of other virtual portals are still there, but you can no longer access them. Any system associations between pages in those virtual portals and their respective Portal Site libraries also no longer work.

Note:  To preserve content in the other virtual portals, you must import or syndicate the libraries into the default virtual portal before disabling managed pages.

You can still access the Portal Site library for the default virtual portal, but the library is no longer automatically synchronized with the page structure.

Pages are no longer managed in IBM Web Content Manager, with the following implications:
  • No page drafts can be created.
  • No new versions of pages can be created.
  • Pages are no longer syndicated.
  • Access control changes that you perform in the portal interface are no longer applied to the portal page site area.
  • If you delete a page from the portal interface, the corresponding portal page site area is not deleted.
Try to delete the content in "Portal Site" library and then ran the following commands
ConfigEngine.bat enable-managed-pages -DPortalAdminPwd=wpsadmin -DWasPassword=wpsadmin

ConfigEngine.bat create-page-nodes -DPortalAdminPwd=wpsadmin -DWasPassword=wpsadmin
It will create lost-found and Content Root folders under Portal Site library as shown below.

WCM Library


Synchronizing Portal Pages with Portal Site library in WCM 8.0

If you disable the manged pages feature, Portal Site library in WCM is no longer automatically synchronized with the portal page structure.

After enabling manged pages feature, you can resynchronize the Portal Site library based on the current portal page structure that is stored in the portal database. If you run this synchronization, the portal database acts a master repository. Any portal page site areas in the Portal Site library that do not correspond with existing portal pages are removed from the Portal Site library. Any content site areas or content items within the affected portal page site areas are also removed.

To perform this resynchronization, run the create-page-nodes configuration task.

ConfigEngine.bat create-page-nodes -DPortalAdminPwd=userId -DWasPassword=password

Some important utility methods provided by PortletUtils class

PortletUtils (under package com.ibm.wps.pb.utils.portlet) is a utility class which is provided by WebSphere portal server. With help of JSR286 API, it provides some very useful methods.


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


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


getHttpServletRequest(javax.portlet.PortletRequest portletrequest)
Assuming that the current URL is something like
http://localhost:10039/wps/myportal/IVTc2U0QyMEEz/?paramName=paramValue
HttpServletRequest request=PortletUtils.getHttpServletRequest(request);
System.out.println("ParameterValue"+request.getParameter("paramName"));
// paramValue is printed.


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


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


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

Setting Complex objects in Action phase in Webshere Portal

It is sometimes required to pass some of the complex objects from ProcessAction() method to Render() method. The same can be easily achieved by passing the object using the below method:

actionRequest.SetRenderParameter(Object)

We have add this in our Portlet.xml file

<container-runtime-option>
         <name>javax.portlet.actionScopedRequestAttributes</name>
         <value>true</value>
        <name>numberOfCachedScopes</name>
        <value>10</value>
</container-runtime-option>

Changes in Portlet Class

public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
           if( request.getAttribute("EMPLOYEE_DETAILS") != null ) {
                    System.out.println("Not Null ");
          } else {
                  System.out.println("Null");
          }
}

public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException {
             Employee employee =new Employee();
             request.setAttribute("EMPLOYEE_DETAILS", employee );
}

How to enable and disable versioning of diferrent artifacts in WCM?

Here is a quick tip to enable / disable the versioning of different artifacts used in WCM.

Search WCMConfigService.properties for "versioningStrategy". You can set the below properties to always (enable) or never (disable)

# enable version control for the following types.
# options are always | never
versioningStrategy.AuthoringTemplate = always
versioningStrategy.Component = always
versioningStrategy.Content = always
versioningStrategy.PresentationTemplate = always
versioningStrategy.Site = always
versioningStrategy.Taxonomy = always
versioningStrategy.Workflow = always

Different methods to deploy a portlet using RAD IDE and WebSphere Portal Server

If you are using RAD IDE for portlet development and WebSphere Portal as the deployment server then as a developer you need to know different methods to deploy a portlet on to the server. This will serve multiple purposes.
  • First, if one deployment options fails for some reason then you can try the other one.
  • Second, it will also help you when you move from DEV environment to upper environments.
Below are some of the popular methods to deploy a portlet.

1. Using Portal Admin Console

This is the option that most of the newbies prefer over other deployment options.
  • Export your portlet application as .war file using RAD.
  • Open the Portal admin console using the URL http://localhost:10039/wps/portal. The port number (10039) may vary from machine to machine.
Now, navigate to following section
Administration -> Portlet management -> Web Modules
Click on "Install" and select the .war file from your local drive and click next. This will install the portlet application and makes it available to portal. Now you need to add the portlet to the required portal page. Although this option is very straight forward and simple but after looking at other options you may feel that this is not the best one.

2. Using the Traditional way (using WAS admin console)

The most easiest way of deploying any application (either portlet or simple web application) is through WAS admin console.

Log on to WAS administration console using the URL https://localhost:9080/ibm/console.

Now, navigate to following section
Application -> New Application -> New Enterprise Application
  • Select an EAR or WAR file from your file system.
  • Choose the "Fast path" option and click next.
  • Leave everything as is in "Select installation options" and click next.
  • Select the deploy server for portal, the one which is ending with websphere_portal.
  • Select the module you want to deploy and click apply.
  • Enter the context root (/) for the selected application and click next.
  • Verify the generated summary information and click finish.
It will display the "Deploy Successful" message. Click "save" to save the configuration.

At this point of time, the portlet application is still not available to the server. Next step is to make the portlets available to the portal server. For that , modify the DeployPortlet.xml located at

\IBM\WebSphere\PortalServer\doc\xml-samples 

to the portlet you need and then run it through "Portal Admin UI".

Administration -> Portal Settings -> import xml

This will install the portlet successfully and make available to portal page. You can use the same way for installing theme as .WAR file and then run the DeployTheme.xml.

3. Using RAD, Deploy Portlet Option

The most easy and simplest way of deploying a portlet is by using "Deploy Portlet" option in  RAD.  When you right click on the portlet application, you will see an option "Deploy Portlet". By selecting this option, RAD will automatically generate a xml script for portlet and deploys it on the server configured in the RAD. This way you can avoid the overhead of creating a .WAR file every time you make a change in your portlet application.

4. Using RAD, Run As Option

The last option, not the cleanest way to do deployment is through "Run As" option in RAD.

By right clicking the project select Run As -> Run on server will install the portlet on the portal home under "Rational Components" page. This way it will create multiple sub pages under this page for each portlet you deploy.

Frequently used WebSphere Portal Config Engine Tasks

Below are some of the most commonly used WebSphere Portal ConfigEngine tasks that you must know either you are playing a role of WPS developer or administrator.

start-portal-server

This task is used to Start the portal server. Before executing this task make sure that the portal admin user id and password should be set in wkplc.properties.

./ConfigEngine.sh start-portal-server

stop-portal-server

This task is used to Stop the portal server. Before executing this task make sure that the portal admin user id and password should be set in wkplc.properties.

./ConfigEngine.sh stop-portal-server

activate-portlets

In a clustered environment when the new portlet is deployed, WebSphere Portal cannot guarantee that the portlet has been successfully synchronized to each node in the cluster and thus cannot automatically activate the portlet during deployment.

In order to fix this issue, you have to run this task to activate the deployed portlets and to synchronize the changes across all cluster members.

ConfigEngine.bat activate-portlets -DWasPassword=password task from the wp_profile_rootConfigEngine directory

configure-wcm-authoring

This task installs the WCM Authoring Portlet, Local Rendering Portlet and Web Content Manager Portal pages on top of base portal installation.

ConfigEngine.bat configure-wcm-authoring -DPortalAdminPwd=xxx -DWasPassword=xxx

Note that if the WCM Authoring portlet is invisible after running this task, try going into Portal Admin > Web Modules and make sure the modules for WCM are started.

create-virtual-portal

Use this task to create a new virtual portal.

ConfigEngine.sh create-virtual-portal

Additional custom parameters can be passed to the task depending upon your requirement, so please refer to the Virtual portals reference for more details.

delete-virtual-portal

This task is used to delete a virtual portal by using its object ID. To determine the correct object ID of the virtual portal, use the task list-all-virtual-portals.

modify-virtual-portalUse this task to modify a virtual portal by using its object ID. To determine the correct object ID of the virtual portal, use the task list-all-virtual-portals.

list-all-virtual-portals

This tasks lists all your virtual portals, together with the information like title / description / realm and object ID of virtual portal:

./ConfigEngine.sh list-all-virtual-portals

export-library-copy

This task exports a copy of a web content library. Refer this article Exporting and importing a web content library copy for more details.

export-wcm-data

This task exports a web content library. Several things need to be in place for this task to be executed properly, so please refer this article Exporting and importing web content libraries for more details.

import-library-copy

This task imports a copy of a web content library. Refer this article Exporting and importing a web content library copy for more details.

import-wcm-data

This task imports a web content library. Several things need to be in place for this task to be executed properly, so please refer this article Exporting and importing web content libraries for more details.

list-server-ports

This task list and the available server ports.

ConfigEngine.bat list-server-ports -DWasPassword=password

list-server-ports-by-name

This task list all the server ports by their name.
ConfigEngine.bat list-server-ports-by-name -DServerName=server1 -DWasPassword=password

ConfigEngine.bat list-server-ports-by-name -DServerName=WebSphere_Portal -DWasPassword=password

modify-servlet-path

Changes the default portal Uniform Resource Identifier (URI) after installation.

./ConfigEngine.sh modify-servlet-path -DPortalAdminPwd=password -DWasPassword=password

remove-wcm-authoring

This task uninstalls the Wcm Authoring Portlet, Local Rendering Portlet and Web Content Manager Portal pages.

How to Setup authentication alias in WAS

If your application is deployed on WebSphere application server and is using its JDBC resources for making a database connection then you need to specify the security credentials. If the proper security credentials are not set or specified then you may end up getting the below error.

Authentication Alias Websphere JNDI Data source Exception Connection Failed

There are 2 ways of achieving this.
  1. The easiest way is to hard code the userID / Password in your application which is not at all recommended for enterprise applications.
  2. Second option is to create a component managed authentication alias in WAS which involves creating a mapping of a alias name with the specified userID/password. This alias can be later used while creating a connection factory or a data source.
 Below are the simple steps for creating an alias using WAS console,

1. Open WAS admin console using this URL https://localhost:9080/ibm/console.
Authentication Alias
Authentication Alias
2. Navigate to Security -> Secure administration, applications, and infrastructure -> JAAS -> J2C authentication data.
3. Click New to create a new alias and enter the alias name.
5. Enter the userID/Password for connecting to the database.
6. Click OK to finish.

Now while creating data source for you application to connect to database, you should use this alias name. This was you can avoid hard coding userID / Password in your application code for creating database connection.

Error : The Web Content Management applet failed to load or is unavailable

Issue Faced : WCM throws an error message while creating a new Authoring Template something like

The Web Content Management applet failed to load or is unavailable. Please contact your administrator immediately.

Solution : The solution is to check the installed JRE version on your machine :

The Web Content Management Authoring Portlet requires one of the following JRE's to be installed otherwise it will throw the above exception:

JRE Version -> 1.4.1_07 / 1.4.2_03 / 1.4.2_0 / 1.4.2_05

Step by Step creating a Portlet Filter

Portlet Filter are filters that can be applied to any life cycle method(s) of a portlet. Below are the filters that were introduced as part of JSR 286 specification.

javax.portlet.filter.RenderFilter (for render method)
javax.portlet.filter.ActionFilter (for processAction method)
javax.portlet.filter.EventFilter (for processEvent method)
javax.portlet.filter.ResourceFilter (for serveResource method)

To create a custom portlet filter, you are required to do couple of things here :

1) Code your own filter class - A custom filter class should implement one or more of the above 4 defined interfaces with a no argument public constructor. It is also mandatory for filter class to override init() and destroy() methods of PortletFilter interface.

2) Entry of filter class in portlet.xml - The seconds step is to configure the above filter class in portlet.xml

<filter>
<filter-name>HelloFilter</filter-name>
<filter-class>com.test.filter.HelloFilter</filter-class>
    <lifecycle>RENDER_PHASE</lifecycle>
    <lifecycle>ACTION_PHASE</lifecycle>
<init-param>
    <name>message</name>
    <value>My first filter</value>
</init-param>
</filter>

<filter-mapping>
     <filter-name>HelloFilter</filter-name>
     <portlet-name>HelloPortlet</portlet-name>
</filter-mapping>

The first xml fragment defines a filter by providing a logical name to it. It tells the portlet container about the newly created custom filter class and the lifecycle phases supported by the filter. In addition to this, you can also specify initialization parameters here.

The Second xml fragment specifies the portlet name for which this filter will be applicable. Here you can specify either a single portlet or mapping to a group of portlets using the wildcard character ‘\*’.

Step by Step creating a Portal Filter

Following are the simple steps for creating a Portal Filter.
  1. Using your preferred IDE, create a simple java project named portalFilterProject.
  2. In this project, create a simple java class which will act as a filter class with below line of code. System.out.println("My First Portal Filter");
  3. Export the new created filter project as .jar file.
  4. Copy the exported portal .jar file to following location  \IBM\WebSphere\PortalServer\shared\app
  5. Now, navigate to following directory \IBM\WebSphere\wp_profile\config\cells\DefaultNode\applications\wps.ear\deployments\wps\wps.war\WEB-INF
  6. Add the following entries to the web.xml at the end of all filter entries in the file. Filters take precedence as the order they are added. It is advisable to keep the backup of web.xml before making these changes.
<filter>
<filter-name>Portal Filter</filter-name>
<filter-class>com.test.portal.filter</filter-class>
</filter>

<filter-mapping>
<filter-name>Portal Filter</filter-name>
<url-pattern>/myportal/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>Portal Filter</filter-name>
<url-pattern>/portal/*</url-pattern>
</filter-mapping>

Now restart the portal server, you will see the message "My First Portal Filter" you placed in the portal filter class for the each request in logs. If the message is coming that means you have successfully implemented the Portal Filter.

Useful links:

What is the diiference between Portlet and Portal filters ? How to create them ?

One of the key features of JSR 286 API is Portlet Filter. As the name suggests, filters are used to intercept the request and modify the response of a portlet before or after the execution of any life cycle method of a portlet. The concept of Portlet Filters are inherited from Servlet Filters. The only difference is that in servlets there is only one type of filter that can be applied because there is only one request handling method i.e. service() method but in case of portlets we have 4 different type of filters that can be applied on each and every life cycle method of a portlet.

javax.portlet.filter.RenderFilter (for render method)
javax.portlet.filter.ActionFilter (for processAction method)
javax.portlet.filter.EventFilter (for processEvent method)
javax.portlet.filter.ResourceFilter (for serveResource method)

Portal Filter is used to apply some common filter logic at portal level rather than at individual portlet lifecycle methods level. The following are some of the scenarios where we can apply this filter.
  • Apply some logic or cache some objects in Dynacache before the theme is invoked.
  • Set parameters in HttpSession and later retrieved and used in portlet.
  • Apply some common logic to all the portals  (Base and Virtual portals) on single installation.
  • Alternate place to implement the common logic avoiding authorization filters.
  • Allows you to set application objects in HttpSession without implementing SelfInitializingApplicationObject Interface to write custom PZN rules. 

Recent Posts

Reader Comments

Popular Posts

© 2011-2013 Web Portal Club