Managing Portlets and Portal Content via XMLAccess

In this scenario we look at installing Portlets and portal Content, some clever features to dynamically create new xml files to remove Portlets and content. We will also look at using the clone portal task which is built around the ReleaseBuilder tool that comes with WebSphere Portal.

The steps that are completed are:

  • Installation of portlets
  • Configuration of Portal Content
  • Deleting portlets and Content dynamically via xsl
  • Cloning Portal Content
  • Setting up multiple projects with same content package

To create a new project, go to the project page and select the Project Creation Wizard and on the product tab select the WebSphere Portal 8 plugin from the available products. Next on the Environment tab select the WebSphere Portal 8 Application Template, complete all the required parameters.

Tasks related to this template:

  • WebSpherePortalDeployPortletsTask
  • WebSpherePortalXMLAccessTask

It is advised that you read up on each task that is associated with each task in the templates before running or modifying them, this will save you time and help you to complete the required fields correctly.

TODO - Incert link to taskmetadata.xml

Review and create the project.

Next you need to add your Portlets and xml Access xml file to the new project, make sure and add the urlSearchKey to your new xmlaccess like below:

<web-app action="update" active="true" domain="rel" objectid="Z1_GQGG1KG0KG0620AKB43R5630K4" uid="com.ibm.wps.portlets.webPage.WebPagePortlet"> <url>@@PORTLETPATH@@/webpage.war</url>

Make sure this matches whats in the orchestration file:

The template also adds the WebSpherePortalXMLAccessTask as in general most people like to separate their Portlets for Content deployments, but these can be in one large xml file.

The extra WebSpherePortalXMLAccessTask can also be used to Activate the newly installed Portlets without the need for the user to write any xml files. All they need to do is create a xsl stylesheet and add the path to the task like below:

Below is a sample xsl stylesheet for creating an activate Portlets xml file. When an sxl path has been added to the WebSpherePortalXMLAccessTask it will no longer run the inFile as this will only be used to generate a new file based on the requirement in the xsl stylesheet.

GenerateActivatePortlets.xsl

 <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xalan="http://xml.apache.org/xslt">

 <xsl:template match="/">
   <xsl:apply-templates select="request"/>
 </xsl:template>

 <xsl:template match="/request">
   <xsl:copy>
      <xsl:attribute name="xsi:noNamespaceSchemaLocation">PortalConfig_1.3.xsd</xsl:attribute>
      <xsl:attribute name="type">update</xsl:attribute>
      <xsl:apply-templates select="/request/portal"/>
        </xsl:copy>
  </xsl:template>

Next we will look at creating rollback package without actually creating a new package. What we mean here is we can make use of the existing package and the xsl functionality.

First step is to copy select the copy project icon and on the Create Project page, Change the project name and Orchestration file name and make sure to leave the SCM Repositpory path the same as the Deploy project path.

Make sure to uncheck the Create project specific directories and file checkbox, and click create. This will create a new project with the same files as the deploy package only with a new orchestration file.

All we need to do now is generate an xsl stylesheet and modify the orchestration task list:

Below are examples for creating xsl to delete pages and portlets:

GenerateDeletePages.xsl

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE stylesheet [
 <!ENTITY cr "<xsl:text>
 </xsl:text>">
 <!ENTITY tab "<xsl:text>    </xsl:text>">
 ]>
        
 <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xalan="http://xml.apache.org/xslt">
        
 <xsl:template match="/">
        <xsl:apply-templates select="request"/>
 </xsl:template>
        
 <xsl:template match="/request">
        <xsl:copy>
                <xsl:attribute name="xsi:noNamespaceSchemaLocation">PortalConfig_1.3.xsd</xsl:attribute>
                <xsl:attribute name="type">update</xsl:attribute>
                <xsl:apply-templates select="/request/portal"/>
        </xsl:copy>
 </xsl:template>