leveraging pz n features

19
Leveraging PZN features of Web Sphere Portal in real time Ashish Srivastava, Jitendra Raganathan, Elangovan Ramalingam

Upload: balaganesh-buduguru

Post on 21-Apr-2015

39 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Leveraging Pz n Features

Leveraging PZN features of Web Sphere

Portal in real time

Ashish Srivastava, Jitendra Raganathan, Elangovan Ramalingam

Page 2: Leveraging Pz n Features

Leveraging PZN features in real time

Page 2 of 19

TABLE OF CONTENTS

1. INTRODUCTION .............................................................. 3

1.1 PURPOSE AND SCOPE OF THE DOCUMENT .................................................................................................. 3

1.2 OVERVIEW .................................................................................................................................................... 3

2. MODULES OVERVIEW ....................................................... 3

2.1 RESOURCE COLLECTION .............................................................................................................................. 3

2.2 CONTENT SPOT ............................................................................................................................................ 5

2.3 ADDING COLLECTION & CONTENT SPOT TO PORTAL SERVER................................................................... 6

2.4 CREATING A PORTLET TO MAKE USE OF CONTENT SPOT ........................................................................... 10

2.5 RULES ......................................................................................................................................................... 11

2.6 VISIBILITY RULES BASED ON THE SELECTION OF PREFERENCES ................................................................. 13

2.7 STORAGE AND RETRIEVAL OF PREFERENCES ............................................................................................. 14

2.8 MAKING USE OF WEB-CLIPPING PORTLET WITH AUTHENTICATION ...................................................... 15

Page 3: Leveraging Pz n Features

Leveraging PZN features in real time

Page 3 of 19

1. INTRODUCTION

1.1 Purpose and Scope of the Document

The purpose of this document is to demonstrate the ways in which the personalization feature of Web Sphere Portal 6.1 can be leveraged in real time. It presents the development aspects of various modules required for implementing personalization.

1.2 Overview

WebSphere Portal implements rule-based content delivery through a feature called personalization. By using personalization, one can customize the content that a Web site shows automatically for each user. Personalization can recognize a specific user based on a profile. It can also determine the characteristics of a user based on previous records and then select content that is appropriate for that profile. This feature of personalization can be leveraged by making various components interact with each other.

2. MODULES OVERVIEW

2.1 Resource Collection

A resource collection is a Java class that represents and allows access to a collection of resource instances. It is similar to a database table with a fixed schema and a number of rows. Resource collection classes must implement the com.ibm.websphere.personalization.resources.ResourceDomain3 interface. Implementation:

Create Project for Resource Collection using RAD:

1. Navigate to FileNewProjectJava Project and click next.

2. Enter Project Name and click next.

Page 4: Leveraging Pz n Features

Leveraging PZN features in real time

Page 4 of 19

3. In the Java Settings select the tab Libraries and click Add External Jars button.

4. Select Personalization libraries pznauthor.jar, pzncommon.jar, pznquery.jar, pznresources.jar, pznruntime.jar from

...WebSphere\PortalServer\pzn\prereq.pzn\lib folder.

Create Resource class:

1. Create a class and implement the interfaces com.ibm.websphere.personalization.resources.Resource and Serializable.

2. Create private instance variables for each attribute represented by the content object. i.e. String preferences , etc

3. Create getter and setter methods for each instance variable.

4. Implement the method public Object get (String name), which will invoke corresponding getter methods based on the

attribute name passed as parameter.

5. Implement the method public String getId (), which will return the primary key attribute for the content object.

Create implementation of ResourceDomain3 & ResourceManager3 interfaces:

1. Create a class and implement the interfaces com.ibm.websphere.personalization.resources.ResourceManager3,

com.ibm.websphere.personalization.resources.ResourceDomain3 and Serializable.

Page 5: Leveraging Pz n Features

Leveraging PZN features in real time

Page 5 of 19

2. Implement the method public Enumeration findResourcesByQuery(Query query, RequestContext context). This is the entry

point method from Personalization Rules Engine. The rules defined in Rules Editor will be passed to this method in

the parameter query. This method is responsible for retrieving the collection of resources based on the rules and

returning the collection. The following steps needs to be followed in this method.

Write logic to connect to external data source and fetch the relevant content for the particular user. The user details can be obtained through context.getAuthenticatedUsername();

PFB the sample attached.

2.2 Content Spot

1. Navigate to File New OtherPortalPersonalizationContent Spot.

2. Click Next.

3. Enter the values for package name, Display name, Class name and Return type as fully qualified class name of

Resource class.

Page 6: Leveraging Pz n Features

Leveraging PZN features in real time

Page 6 of 19

4. Click Finish.

2.3 Adding Collection & Content Spot to Portal Server

1. Export the Resource, ResourceDomain3, ResourceManager3 classes created in the steps above as Jar file

2. Copy the jar file to folder ...\WebSphere\PortalServer\pzn\prereq.pzn\collections

3. Restart WebSphere Portal Server (WPS).

Create Resource Collections in Personalization Navigator

1. Navigate to WPS ConsolePersonalizationBusiness RulesNewFolder.

2. Create new folder ResourceCollection.

Page 7: Leveraging Pz n Features

Leveraging PZN features in real time

Page 7 of 19

3. Click NewResource Collection from Personalization Navigator.

4. Enter the name for the Resource Collection.

5. Select the Collection Type as Standard Resource Collection and specify the values for Resource class, ResourceDomain3

class and ResourceManager3 class.

6. Select “Locate the current resource”: as Content Resource.

7. Click Save button.

Preview of the same:

Create Personalization Rule in Personalization Navigator

1. Navigate to WPS ConsolePersonalizationBusiness RulesNewFolder.

2. Create new folder „Rules‟.

3. Click NewRule from Personalization Navigator.

4. Enter the name for the rule.

Page 8: Leveraging Pz n Features

Leveraging PZN features in real time

Page 8 of 19

5. Select “Select Action” from the Rule Type drop-down list.

6. Click content next to Select.

7. Select the resource collection name that we created before from the list.

8. Click attribute and select the attribute to be included in the condition from the drop-down list.

Page 9: Leveraging Pz n Features

Leveraging PZN features in real time

Page 9 of 19

9. Click value, enter the value and submit.

10. Multiple conditions can be added by clicking „add Condition‟ link.

11. Click Save.

Create Content Spot in Personalization Navigator

1. Navigate to WPS ConsolePersonalizationBusiness RulesNewContent Spot.

2. Enter the name of the content spot.

3. Select Output type as the name of the Resource class that we created.

4. Click the button in the Default Mapping section.

5. Select the rule that we created before and click Ok button.

6. Click Save.

Page 10: Leveraging Pz n Features

Leveraging PZN features in real time

Page 10 of 19

7. Test the content spot by clicking the Preview tab in the Personalization Editor. It will fetch the data depending upon

the rule that is bound.

2.4 Creating a portlet to make use of content spot

1. Navigate to File New OtherPortlet Project.

2. Click Next.

3. Enter the values for Project name, package name.

4. Click Finish.

5. Add the following code to call the content spot created earlier

<%@page import="com.intel.personalization.POC.ContentResource"%>

<jsp:useBean class="com.intel.personalization.POC.ContentSpot"

id="contentSpot"></jsp:useBean>

<%

contentSpot.setRequest(request);

%>

6. Call the Content Spot which in turn triggers the rule, as follows

ContentResource testContentResource= new ContentResource(); ContentResource[] testContentResourceList = null;

testContentResourceList = contentSpot.getRuleContent();

Page 11: Leveraging Pz n Features

Leveraging PZN features in real time

Page 11 of 19

7. Deploy the portlet in the portal server and add this portlet to a page.

2.5 Rules

Following are the rules that were created for the POC.

Action Rule

Profiler Rule

Binding Rule

Page 12: Leveraging Pz n Features

Leveraging PZN features in real time

Page 12 of 19

Visibility Rules

Hiding Portlets for Valid user

Hide page or portlet when

current Portal Users.cn is wps_technical_user or

current Portal Users.cn is wps_business_user

Otherwise show

For showing portlets only for business User

Show page or portlet when

Current Portal Users.cn is wps_business_user Otherwise hide

For showing portlets only for Technical User

Show page or portlet when Current Portal Users.cn is wps_technical_user Otherwise hide

All the visibility rules can be applied to portlets through the page edit section.

Page 13: Leveraging Pz n Features

Leveraging PZN features in real time

Page 13 of 19

2.6 Visibility rules based on the selection of preferences

Creation of application object

1. Navigate to FileNewProjectJava Project and create a new project

2. Create a class and implement the interfaces SelfInitializingApplicationObject and Serializable.

3. Create private instance variables for each attribute represented by the application object.

4. Implement the method public void init(RequestContext arg0) of the SelfInitializingApplicationObject interface.For ex: to

retrieve a user group name.

Set the class in the session:

Ex:

arg0.setSessionAttribute("applicationobjectfortopics", this);

5. Export the project as a jar file into ...\WebSphere\PortalServer\pzn\prereq.pzn\collections. 6. Restart the Portal server.

Create Application object in Personalization engine:

1. Navigate to the Business Rules in personalization 2. Select “Application object” from the drop-down “New” 3. Enter the Application object name, for ex: “TopicsApplicationObject”. 4. Enter the session key same as the session attribute name, for ex: “applicationobjectfortopics”. 5. Enter the complete Class name, for ex: “com.intel.topicsapplicationobjects.TopicsApplicationObject”. 6. Click on Save.

Ref:

Visibility Rules based on the application Object:

Page 14: Leveraging Pz n Features

Leveraging PZN features in real time

Page 14 of 19

For Displaying Desktop – Computing Preferences based portlet:

Show page or portlet when

current TopicsApplicationObject.desktopComputing is Yes

Otherwise hide

2.7 Storage and Retrieval of preferences

Storage:

As soon as the form is submit, the process action of the portlet is called where preferences are stored in the database for the user, whose details are obtained through puma API. Sample code is as follows :

Retrieval:

The preferences are retrieved through content spot, which triggers the rule and fetches the data through the Resource collection bound to it. The preferences can be fetched both from portlet JSP and through Portlet

Java code.

Through Portlet JSP:

Through Java Code:

Page 15: Leveraging Pz n Features

Leveraging PZN features in real time

Page 15 of 19

2.8 Making Use of Web-Clipping Portlet with Authentication

Login to the portal server as Admin

Creation of Credential Vault

1) Go to Administration Tab 2) Click on “Credential Vault” under Access Category as follows :

3) Click on “Add a vault slot” 4) Enter details as follows :

5) Click “OK” option. Note: Vault Slot should not be shared.

Creation of Web-Clipping Portlet

1) Click on “New Portlet” Option after clicking Web-Clipping Tab as follows :

Page 16: Leveraging Pz n Features

Leveraging PZN features in real time

Page 16 of 19

2) Enter the details as follows :

Name : Give any relevant name URL Clip : URL from which message needs clipped Description : Optional Read timeout : time you want it to wait for the read operation

3) Go to “Advanced Options”. Following screen will appear

Page 17: Leveraging Pz n Features

Leveraging PZN features in real time

Page 17 of 19

4) Select “Modify clipping type” Option and enter the details as follows :

Select “Text Clipping” Start clipping after text: Refers to the text after which you want the clipping to begin in the target. End clipping before text: Refers to the text at which you want the clipping to end. “Include start and end text with clipped content”: lets you include start and end text

5) Click “OK”. You will be redirected to “Web Clipper Options”.

6) Now select “Modify authentication options”. Following screen will appear :

Page 18: Leveraging Pz n Features

Leveraging PZN features in real time

Page 18 of 19

7) Click on “Set credentials” button after selecting “Authentication required” Option. Form will be displayed as follows :

8) Select the vault slot created earlier from the dropdown. 9) Specify the admin credentials, click “OK”. 10) Now select “Form Based Authentication” and specify the details as mentioned above.

Log-in URL: Refers to Portal Log – in URL Username Parameter Name and Password Parameter Name as mentioned above.

11) Click On “OK”. 12) You will be redirected to following form:

Page 19: Leveraging Pz n Features

Leveraging PZN features in real time

Page 19 of 19

13) Click on “next” and then “finish”. You may get an error while clicking “finish”, but that can be ignored. 14) Add the above created web-clipping portlet to any page for testing.