Monday, April 15, 2013

Anonymous Search Collection for custom Search Portlet



Introduction

The objective of the task is to create a Portal Search collection, which
could index contents inside specific site area of the WCM. As the client
has specific UI needs, Instead of out of box Search Portlet, the developer
is expected to access the Search services from the custom portal. All
contents thus searched from the custom Portlet should be searchable in
anonymous mode.


Steps to Create Collection


· Go to Administration > Manage Search >Search Collections > Default
Search Collection
· Click "New Collection"



· Click "ok"


Steps to Create Index


· Click "NCCollection"
· Click "New Content Source"
· Under "Content Source type" select "WCM site"
· Under "General Parameters"
o Content Source Name : DataIndex
o Collect documents linked from this URL :
http://hostname:10039/wps/seedlist/myserver?SeedlistId=NC_Contents/Data&Source=com.ibm.workplace.wcm.plugins.seedlist.retriever.WCMRetrieverFactory&Action=GetDocuments
o Stop fetching a document after (sec): 1800

· Under "Schedulers"
o From: Today's Date
o At: Current time
o Update every: 1 days
o Click Create
· Under "Security"
o User Name: wpsadmin
o Password: wpsadmin
o Host Name: hostname
o Click Create

· Click "Save"
· Click Play icon


· After some time click "Refresh" to see no of Documents indexed





Giving Anonymous Access to the Collection Resources



· Go to Administration > Access > Resource Permissions > PSE Sources
· Click on "Assign Access"





· Click on "Edit Role" against User



· Click Add
· Select "Anonymous Portal User"
· Click "ok"


Accessing the Collection Service using contenthandler servlet

It is possible to launch the search over the index thus created using
contenthandler servlet. Following is the example url which caries a query
text as "keyword".

http://hostname:10039/wps/contenthandler/searchfeed/search?queryLang=en&locale=en&resultLang=en&query=keyword&start=0&results=10&index=Default
+Search
+Service%3A%3AC%3A%5CIBM%5CWebSphere%5Cwp_profile%5CPortalServer%5Ccollections%5CDataIndex

For linux/unix based portal environments, the url would be of bellow format

http://hostname:10039/wps/contenthandler/searchfeed/search?queryLang=en&locale=en&resultLang=en&query=keyword&start=0&results=10&index=Default
+Search
+Service%3A%3A%2Fopt%2FIBM%2FWebSphere%2Fwp_profile%2FPortalServer%2Fcollections%2FDataIndex

The above URL could be launched from the custom Portlet and the response
would be in the form of ATOM feed. The developer could parse the ATOM Feed
and build the custom Portlet as per the UI needs given by customer.

Sample Portlet using Web Experience Factory 8

To download Web experience Factory 8, go to
http://www.ibm.com/developerworks/downloads/ws/wpf/. Installation is fairly
simple. Now let's quickly start creating a sample Portlet.

· Create a project by clicking File>New>Web Experience Factory Project.
· In Project Name page, Enter Project Name: SampleProj
· Click Next
· In Feature Set Page, Uncheck all
· Click Finish
· Select No if prompted for "Would you like to publish project now?"
· Right Click "SampleProj"> New> Web Experience Factory Model
· Select "SampleProj"
· Click Next
· In Select Model page, Select "Main and Page"
· Click Next
· In Page Settings page, Select "Simple Page"
· Click Next
· In Save New model page, Select "models" folder and enter Model name
as "SamplePortlet"
· Click Finish
· You will have following Screen

· Now double click "SampleProject.model"
· Select "Application Tree" tab
· Select "page1"
· Click on "Add Builder Call to the Current Model"
· Select "Portlet Adapter"
· Click ok
· In the Portlet Adapter page
· Enter Name: SamplePortlet
· Portlet Title: SamplePortlet
· Portlet Description: SamplePortlet
· Click OK
· Now Right click "SampleProj">Export>Web Experience Factory Portlet
WAR
· Click Finish
· Now you could deploy the war thus obtained through Portal Web
Console.