Create XMLAccess scripts copy individual portal resources development to integration environments

Lets say you want to move a page from your development to integration environment. I am planning to move XMLAccess Test page from my portal on VMWare to Portal on Local machine. I will have to follow these steps for that


  • Create a XMLAccess Test page like this. While doing that assign com.wpcertification.xmlaccess.test as unique name to it. You can use this name to reference the page while exporting it.

  • Add two portlets Welcome WebSphere to WebSphere Portal and About WebSphere Portal to it

  • Create exportpage.xml file like this in /tmp/xmlaccess folder. YOu will have to specify either the objectid which is big number like 6_H24EGKG100G350I0OR9K0000Q4 this or uniqnname of the page. and value of action should be export.

    <?xml version="1.0" encoding="UTF-8"?>
    <request
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd"
    type="export">
    <portal action="locate">
    <content-node action="export" uniquename="com.wpcertification.xmlaccess.test"/>

    </portal>
    </request>


  • Once your exportpage.xml is ready you can execute following command

    ./xmlaccess.sh -in /tmp/xmlaccess/exportpage.xml -out /tmp/xmlaccess/exportpageresult.xml -user wasadmin -password wasadmin -url http://localhost:10040/wps/config


  • If the xmlaccess is successful then it will create exportpageresult.xml document like this on your disk.

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- IBM WebSphere Portal/6.1.0.1 build wp6101_115_01 exported on Thu Mar 19 12:44:21 EDT 2009 from spinfotech.com/127.0.0.1 -->
    <!-- 1 [content-node 6_000000000000000000000000A0] -->
    <!-- 2 [content-node 6_CGAH47L00G72502N5S2MAV00I3] -->
    <!-- 3 [content-node 6_H24EGKG100G350I0OR9K0000Q4 uniquename=com.wpcertification.xmlaccess.test] -->
    <!-- 4 [component 7_H24EGKG100G350I0OR9K0000Q2] -->
    <!-- 5 [component 7_H24EGKG100G350I0OR9K0000Q6] -->
    <!-- 6 [component 7_H24EGKG100G350I0OR9K0000Q7] -->
    <!-- 7 [web-app 1_CGAH47L00G72502N5S2MAV0G24] -->
    <!-- 8 [portlet-app 2_CGAH47L00G72502N5S2MAV0G22] -->
    <!-- 9 [servlet V_CGAH47L00G72502N5S2MAV0G26] -->
    <!-- 10 [portlet 3_CGAH47L00G72502N5S2MAV0G21] -->
    <!-- 11 [portletinstance 5_H24EGKG100G350I0OR9K0000Q3] -->
    <!-- 12 [component 7_H24EGKG100G350I0OR9K0000Q1] -->
    <!-- 13 [component 7_H24EGKG100G350I0OR9K000064] -->
    <!-- 14 [web-app 1_CGAH47L00G72502N5S2MAV0012] -->
    <!-- 15 [portlet-app 2_CGAH47L00G72502N5S2MAV0016] -->
    <!-- 16 [servlet V_CGAH47L00G72502N5S2MAV0011] -->
    <!-- 17 [portlet 3_CGAH47L00G72502N5S2MAV0015] -->
    <!-- 18 [portletinstance 5_H24EGKG100G350I0OR9K000060] -->
    <request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" build="wp6101_115_01" type="update" version="6.1.0.1" xsi:noNamespaceSchemaLocation="PortalConfig_6.1.0.xsd">
    <portal action="locate">
    <web-app action="locate" domain="rel" objectid="1_CGAH47L00G72502N5S2MAV0G24" uid="BlurbPortlet.3088d83ae7690017105c9e64cce97eb8">
    <servlet action="locate" domain="rel" name="Welcome to WebSphere Portal.$appuid.BlurbPortlet.3088d83ae7690017105c9e64cce97eb8.1" objectid="V_CGAH47L00G72502N5S2MAV0G26"/>
    <portlet-app action="locate" domain="rel" name="Information Portlet Application" objectid="2_CGAH47L00G72502N5S2MAV0G22" uid="BlurbPortlet.3088d83ae7690017105c9e64cce97eb8.1">
    <portlet action="locate" domain="rel" name="Welcome to WebSphere Portal" objectid="3_CGAH47L00G72502N5S2MAV0G21" uniquename="wps.p.Welcome To WebSphere Portal"/>
    </portlet-app>
    </web-app>
    <web-app action="locate" domain="rel" objectid="1_CGAH47L00G72502N5S2MAV0012" uid="com.ibm.wps.portlets.welcome">
    <servlet action="locate" domain="rel" name="Welcome Portlet.$appuid.com.ibm.wps.portlets.welcome.1" objectid="V_CGAH47L00G72502N5S2MAV0011"/>
    <portlet-app action="locate" domain="rel" name="Welcome" objectid="2_CGAH47L00G72502N5S2MAV0016" uid="com.ibm.wps.portlets.welcome.1">
    <portlet action="locate" domain="rel" name="Welcome Portlet" objectid="3_CGAH47L00G72502N5S2MAV0015" uniquename="wps.p.Welcome"/>
    </portlet-app>
    </web-app>
    <content-node action="locate" domain="rel" objectid="6_000000000000000000000000A0" uniquename="wps.content.root"/>
    <content-node action="locate" domain="rel" uniquename="ibm.portal.admin.vp.Home"/>
    <content-node action="update" active="true" allportletsallowed="true" content-parentref="6_CGAH47L00G72502N5S2MAV00I3" create-type="explicit" domain="rel" objectid="6_H24EGKG100G350I0OR9K0000Q4" ordinal="200" type="page" uniquename="com.wpcertification.xmlaccess.test">
    <supported-markup markup="html" update="set"/>
    <localedata locale="en">
    <title>XMLAccess Test page</title>
    </localedata>
    <parameter name="com.ibm.portal.IgnoreAccessControlInCaches" type="string" update="set"><![CDATA[false]]></parameter>
    <parameter name="com.ibm.portal.bookmarkable" type="string" update="set"><![CDATA[Yes]]></parameter>
    <parameter name="com.ibm.portal.remote-cache-expiry" type="string" update="set"><![CDATA[0]]></parameter>
    <parameter name="com.ibm.portal.remote-cache-scope" type="string" update="set"><![CDATA[NON-SHARED]]></parameter>
    <access-control externalized="false" owner="uid=wasadmin,o=defaultwimfilebasedrealm" private="false"/>
    <component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_H24EGKG100G350I0OR9K0000Q2" ordinal="100" orientation="H" skinref="undefined" type="container" width="undefined">
    <component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_H24EGKG100G350I0OR9K0000Q6" ordinal="100" orientation="V" skinref="undefined" type="container" width="undefined">
    <component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_H24EGKG100G350I0OR9K0000Q7" ordinal="100" skinref="undefined" type="control" width="undefined">
    <portletinstance action="update" domain="rel" objectid="5_H24EGKG100G350I0OR9K0000Q3" portletref="3_CGAH47L00G72502N5S2MAV0G21" shareref="5_H24EGKG100G350I0OR9K0000Q3"/>
    </component>
    </component>
    <component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_H24EGKG100G350I0OR9K0000Q1" ordinal="200" orientation="V" skinref="undefined" type="container" width="undefined">
    <component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_H24EGKG100G350I0OR9K000064" ordinal="100" skinref="undefined" type="control" width="undefined">
    <portletinstance action="update" domain="rel" objectid="5_H24EGKG100G350I0OR9K000060" portletref="3_CGAH47L00G72502N5S2MAV0015" shareref="5_H24EGKG100G350I0OR9K000060"/>
    </component>
    </component>
    </component>
    </content-node>
    </portal>
    <status element="all" result="ok"/>
    </request>

    The export script has lot of information

    • web-app: There are two web-app elements at the start that represent two portlets included on your page. The value of action attribute is locate for the web-app as they are just for locating references

    • parent content-node: First two content nodes are used to locate the parent of the page from content root. Both those elements have action equal to locate, so they are used to find the objectid of the page.

    • Page content-node: The page content node is the third node with action equal to update thats the page definition for xmlaccess. It has child elements indicating page level parameters, access control,.. Then it has one component node which is the horizontal container on the page. The Horizontal container has one child vertical container that has one child for the portlet instance that is used to indicate the actual portlet instance on the page. Since we have two portlet instances on the page we have two porteltinstance nodes. If your portlet window has any preferences attached to it then those preferences would be included here.


    When you look at the file, you notice that it includes not only the page itself but also other configuration elements that are referred to by the page, for example the portlet that is placed on the page. These other elements have a locate action. The export does not include their full configuration data, but just enough information to look them up in the portal, assuming they already exist. Note how the configuration of the page makes references to the objectid attributes of other resources, for example in the portletref attribute of the portletinstance elements.

    All those references are described by object IDs. Therefore, if the object IDs are correct, the referenced resources could be looked up in the portal even if they were not included in the export. Locating resources before they are referenced is only necessary if you do not know their actual object IDs, so the resources need to be found by some other identifying attribute (see the XML reference documentation). That way, for example a portlet can be identified by its name and by the uid attributes of its parents, and the referencing will still work, even if the object ID is not available for looking up the portlet.

  • Since our page export is ready we will import it on my remote machine using this xmlaccess command

    ./xmlaccess.sh -in /tmp/xmlaccess/exportpageresult.xml -out /tmp/xmlaccess/importpageresult.xml -user wasadmin -password wasadmin -url http://192.168.2.105:10040/wps/config


  • Once the xlmaccess command is executed check importpageresult.xml to see if the result is success.



Important Note: In order for your page import to work all the referenced resources should be present on the target server. i.e. resources with action=locate if say you dont have the portlet installed on target then it will result in error. Or say you try to import page and one of its parent is missing on the target it will fail.

When you crate new VP it wont have ibm.portal.Home page created by default so if you try to import exportpageresult.xml on that blank vp it will fail.

No comments:

Post a Comment