主题、外观和Portlet开发好以后,一般都是从Portal的界面上,由管理员进行安装。但如果需要制作安装程序自动安装,就需要另一种方式了,这里使用IBM自带的xmlaccess工具来完成任务。该工具位于<profile_root>/PortalServer/bin中,例如C:\IBM\WebSphere\wp_profile\PortalServer\bin。另外在<portal_server_root>/bin下也能找到一个xmlaccess工具,具体差别我没有比较过。
完整的命令行示例:
xmlaccess.bat -in DeployPortlet.xml -user wpsadmin -password 123123 -out Out_ DeployPortlet.xml -url http://localhost:10040/wps/config
xmlaccess支持很多命令行参数,在命令提示符环境下,直接执行xmlaccess可以显示详细的帮助信息,这里我只介绍用到的几个:
-in:指定输入xml文件路径。需要让xmlaccess做的事情,在命令行里没法写,太多了,因此需要保存在一个专门的xml文件中,具体格式后面详细介绍。
-user:用户名。
-password:密码。
-out:输出文件名,如果没有,则xmlaccess会将结果直接输出到控制台。这个选项对于“发布”这种一次性工作没有多大用处,但对于后面要说到的页面迁移,则是必不可少的。
-url:门户网站配置 URL,缺省为http://localhost/wps/config。
知道怎么运行xmlaccess之后,接下来就是要准备输入文件了。需要说明的是,xmlaccess只是负责将配置信息写入到Portal中,因此在运行xmlaccess之前,先要将主题和外观拷贝到对应目录中,并将Portlet的war文件拷贝到服务器上。
完整的输入文件示例:
<?xml version="1.0" encoding="UTF-8"?> <request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PortalConfig_6.1.0.xsd" type="update" create-oids="true"> <portal action="locate"> <skin action="locate" domain="rel" objectid="noSkin" uniquename="wps.skin.noSkin"/> <skin action="locate" domain="rel" objectid="thinSkin" uniquename="wps.skin.thinSkin"/> <skin action="update" active="true" objectid="EKP_Html_skin" uniquename="landray.portal.skin.EKP_Html" resourceroot="EKP_Html"> <localedata locale="zh"> <title>EKP_夏</title> <description>EKP蓝色风格皮肤</description> </localedata> </skin> <theme action="update" active="true" defaultskinref="EKP_Html_skin" uniquename="landray.portal.theme.Portal_EKP_Blue" resourceroot="Portal_EKP_Blue"> <localedata locale="zh"> <title>EKP_夏</title> </localedata> <allowed-skin skin="EKP_Html_skin" update="set"/> <allowed-skin skin="noSkin" update="set"/> <allowed-skin skin="thinSkin" update="set"/> </theme> <web-app action="update" active="true" uid="com.landray.portal.portlet.navigation.EKPNavigationTreePortlet.webmod"> <url>file:///$server_root$/installableApps/EKP_navigation_tree.war</url> <servlet action="update" active="true" objectid="EKPNavigationTreeServlet" referenceid="EKPNavigationTreePortlet.servlet"/> <portlet-app action="update" active="true" uid="com.landray.portal.portlet.navigation.EKPNavigationTreePortlet"> <portlet action="update" active="true" objectid="EKPNavigationTreePortlet" name="EKPNavigationTreePortlet" servletref="EKPNavigationTreeServlet"/> </portlet-app> </web-app> </portal> </request>
下面具体来看相关配置项
<skin action="locate" domain="rel" objectid="noSkin" uniquename="wps.skin.noSkin"/>
表明定义了一个外观对象,该外观对象通过唯一名称"wps.skin.noSkin"与Portal中IBM自带的“无外表”外观对应。因为下文中我们要发布的主题,需要使用到此外观,因此要在前面先定义好,然后通过objectid进行引用。
skin节点定义了我们自己开发的一个外观。
<skin action="update" active="true" objectid="EKP_Html_skin" uniquename="landray.portal.skin.EKP_Html" resourceroot="EKP_Html"> <localedata locale="zh"> <title>EKP_夏</title> <description>EKP蓝色风格皮肤</description> </localedata> </skin>
theme节点定义了我们自己开发的一个主题。
<theme action="update" active="true" defaultskinref="EKP_Html_skin" uniquename="landray.portal.theme.Portal_EKP_Blue" resourceroot="Portal_EKP_Blue"> <localedata locale="zh"> <title>EKP_夏</title> </localedata> <allowed-skin skin="EKP_Html_skin" update="set"/> <allowed-skin skin="noSkin" update="set"/> <allowed-skin skin="thinSkin" update="set"/> </theme>
web-app节点定义一个Portlet。这个节点的配置就比较容易出错了,一定要小心。
<web-app action="update" active="true" uid="com.landray.portal.portlet.navigation.EKPNavigationTreePortlet.webmod"> <url>file:///$server_root$/installableApps/EKP_navigation_tree.war</url> <servlet action="update" active="true" objectid="EKPNavigationTreeServlet" referenceid="EKPNavigationTreePortlet.servlet"/> <portlet-app action="update" active="true" uid="com.landray.portal.portlet.navigation.EKPNavigationTreePortlet"> <portlet action="update" active="true" objectid="EKPNavigationTreePortlet" name="EKPNavigationTreePortlet" servletref="EKPNavigationTreeServlet"/> </portlet-app> </web-app>
另外还要注意输入文件本身的编码,如果包含中文,最好使用系统缺省编码,否则可能会出现安装上去的主题和外观的名称是乱码的情况。
正常执行xmlaccess,成功的话,可以在输出文件或控制台中看到如下执行成功提示:
<status element="all" result="ok"/>