Wednesday, 12 August 2009

Creating Virtual Portals via templates using the New Site Wizard portlet

Working with some of my yellow brethren to build a real live portal demonstration, using WebSphere Portal, Lotus Connections, Lotus Sametime, Lotus Quickr etc. and I have a requirement to allow a business user to create a new "microsite" from within the portal, without needing to know or care about the bits, bytes or widgets under the covers. I decided to implement this using WebSphere Portal's Virtual Portal feature, where as VP equates to a "microsite".

Therefore, I wanted to get deep into the New Site Wizard portlet which, I was aware, can be customised, via a templated aproached.

In this scenario, I wanted to create a template from an existing portal site - one of my Portal 6.1.0.2 demo VMs has masses of Virtual Portals, including one called Tasting Department - this, with it's coffee-based theme, appealed to me.

In essence, I needed to generate three artifacts from the existing Virtual Portal: -

  • Site structure, including page layout, portlets etc.
  • Site look and feel, based upon a theme policy, created using the Theme Customiser portlet
  • A thumbnail of the site

as follows: -

Generate Site Structure - Export VP Configuration

Use XMLAccess to export the Virtual Portal configuration, using this XML script: -

<?xml version="1.0" encoding="UTF-8"?>

<request
xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd"
type="export">

<!-- sample for exporting a page -->
<portal action="locate">
<content-node action="export" objectid="*"/>

</portal>
</request>

and this command: -

c:\IBM\WebSphere\PortalServer\bin\xmlaccess.bat -in c:\work\ExportPages.xml -out c:\work\TastingDepartmentPages.xml -url http://portal.ibm.com:10040/wps/config/TastingDepartment -user
wpadmin -password passw0rd

which generates an XML file ( TastingDepartmentPages.xml ) containing the portal configuration for the Tasting Department VP ( note the URL )

Generate Site Look and Feel - Export VP Theme/Style

Use XMLAccess to export a Theme Customiser Style from portal, using this XML script: -

<?xml version="1.0" encoding="UTF-8"?>
<request xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd" create-oids="true" type="export" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<portal action="locate">
<policy-node action="export" label="WebPage" type="theme" path="Tasting Department">
</policy-node>
</portal>
</request>

( where the style name is Tasting Department - replace with your style name )

and this command: -

c:\IBM\WebSphere\PortalServer\bin\xmlaccess.bat -in c:\work\ExportStyle.xml -url http://portal.ibm.com:10040/wps/config -user wpadmin -password passw0rd

which generates an XML file ( TastingDepartmentStyle.xml ) containing the style, in terms of navigation, font selection, images etc.

Generate Thumbnail - A picture showing the look and feel of the site

I used a tool called Irfanview to take a screenshot of the Tasting Department Virtual Portal, as I happened to be running the Portal VM on Windows - other screenshot tools exist , including Shutter on Ubuntu and Grab on OSX.

Having gathered these three things, I then created my own customised version of the New Site Wizard portlet, adding Tasting Department as a template: -

Prepare the New Site Wizard portlet


b) Expand the resulting ZIP file - 1WP1001N7.zip - to c:\temp - I chose to do this using the Java JAR command as follows: -

\IBM\WebSphere\AppServer\java\bin\jar.exe -xvf "\Documents and Settings\Administrator\Desktop\1WP1001N7.zip"

c) This extracts the contents of the ZIP, including the New Site Wizard portlet itself - NewSiteWizard.war

d) Expand the contents of NewSiteWizard.war to a temporary folder - I chose to create a subdirectory called NewSiteWizard into which I extracted the contents: -

mkdir c:\temp\NewSiteWizard
cd c:\temp\NewSiteWizard
\IBM\WebSphere\AppServer\java\bin\jar.exe -xvf c:\temp\NewSiteWizard.war

e) Place the previously exported portal configuration ( TastingDepartmentPages.xml ) in the virtualportals subdirectory of the expanded WAR file: -

copy c:\work\TastingDepartmentPages.xml C:\Temp\NewSiteWizard\virtualportals

f) Place the previously exported theme policy/style ( TastingDepartmentStyle.xml ) in the styles subdirectory of the expanded WAR file: -

copy c:\work\TastingDepartmentStyle.xml c:\temp\NewSiteWizard\styles

g) Place a screenshot of the site ( TastingDepartmentNail.jpg ) in the images subdirectory of the expanded WAR file: -

copy c:\work\TastingDepartmentThumbnail.jpg c:\temp\NewSiteWizard\images

h) Amend the New Site Wizard configuration file ( C:\Temp\NewSiteWizard\WEB-INF\NewSiteWizardConfig.xml ) to include details of the new VP template: -

write C:\Temp\NewSiteWizard\WEB-INF\NewSiteWizardConfig.xml

adding the following lines: -

<site id="4">
<title lang="en">Tasting Department</title>
<description lang="en">Sample departmental intranet Web site primarily made up of coffee ( using Java beans )</description>
<layout-xml>TastingDepartmentPages.xml</layout-xml>
<content-library>Tasting Department</content-library>
<work-thread-class>com.ibm.wps.portlets.signup.tasks.CreateSiteTask</work-thread-class>
<style id="1">
<title lang="en">Tasting Department</title>
<description lang="en">Site with a smidgen of coffee-related content</description>
<style-xml>TastingDepartmentStyle.xml</style-xml>
<style-image>TastingDepartmentThumbnail.jpg</style-image>
</style>
</site>

i) Re-package the New Site Wizard portlet as a new WAR file: -

cd C:\Temp\NewSiteWizard>
c:\IBM\WebSphere\AppServer\java\bin\jar cvf NewSiteWizardUpdated.war *

j) As the Portal Administrator, deploy the new WAR file - NewSiteWizardUpdated.war ( as the original portlet was originally installed on my server, I used the Update Web Module control under Portlet Management -> Web Modules )

k) Deploy the New Site Wizard portlet to a page

l) Navigate to the page, and use the Wizard to create a new portal ...

m) C'est voila, here's the updated Wizard with the Tasting Department template ...


3 comments:

Unknown said...

Thanks you Dave for writing such a good article on Virtual Portals.

I am using a download configuration portlet which is bundeld with New Site Wizard to export an existing VP from portal.

This Download Configuration portlet is only working with VP's which are built by New Site Wizard . It is not able to package VP'S which are created by Portal Admin Console.

my requirement is like i want to export already existing VP's from a production box to a staging server using Download Configuration Portlet for testing purpose

Please guide me how to handle this task.

Thanks,
GNP

Unknown said...

i need your help about how to extend the implementaion of createsitetask class. Actaully, we need the resulting site as a group of pages (not as a new virtual portal)within the same portal.

Dave Hay said...

@GMR - not sure that the New Site Wizard is the thing that you need, given that you're not using Virtual Portals.

Have you considered Composite Application templates instead ?

Reminder - installing podman and skopeo on Ubuntu 22.04

This follows on from: - Lest I forget - how to install pip on Ubuntu I had reason to install podman  and skopeo  on an Ubuntu box: - lsb_rel...