Article
In reference to the article Importing your own Portlets in UserApp, here are some example scripts to build an install package from your sources and install this package in a UserApp portal.
For my own portlets, I have some scripts to build an archive from my sources and then install everything in the WAR file.
Build
My install scripts are in a "my-portlets/install" folder and my sources are in "my-portlets/webapps":
1 #!/bin/sh 2 3 echo ========================================================= 4 echo Portlets Build Script 5 echo ========================================================= 6 7 echo 8 echo [INFO___] Building NovellConsultingPortlets-0.3_install.tar.gz 9 10 cd ../webapps 11 tar cfz ../install/NovellConsultingPortlets-0.3_install.tar.gz * 12 cd ../install 13 14 echo [INFO___] Finished! 15 echo
There is a portlet_XXX.xml file in the "my-portlets/webapps/WEB-INF" folder with my portlets configuration:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" 3 version="1.0" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> 6 <portlet> 7 <description xml:lang="en">Display Accounts Detail</description> 8 <description xml:lang="de">Display Accounts Detail</description> 9 <description xml:lang="fr">Affiche la liste des comptes</description> 10 <description xml:lang="es">Display Accounts Detail</description> 11 <description xml:lang="it">Display Accounts Detail</description> 12 <description xml:lang="ja">Display Accounts Detail</description> 13 <description xml:lang="nl">Display Accounts Detail</description> 14 <description xml:lang="pt">Display Accounts Detail</description> 15 <description xml:lang="zh-CN">Display Accounts Detail</description> 16 <description xml:lang="zh-TW">Display Accounts Detail</description> 17 <portlet-name>NovellAccountsPortlet</portlet-name> 18 <display-name xml:lang="en">Novell - Accounts</display-name> 19 <display-name xml:lang="de">Novell - Accounts</display-name> 20 <display-name xml:lang="fr">Novell - Comptes</display-name> 21 <display-name xml:lang="es">Novell - Accounts</display-name> 22 <display-name xml:lang="it">Novell - Accounts</display-name> 23 <display-name xml:lang="ja">Novell - Accounts</display-name> 24 <display-name xml:lang="nl">Novell - Accounts</display-name> 25 <display-name xml:lang="pt">Novell - Accounts</display-name> 26 <display-name xml:lang="zh-CN">Novell - Accounts</display-name> 27 <display-name xml:lang="zh-TW">Novell - Accounts</display-name> 28 <portlet-class>com.novell.consulting.portlets.JSPPortlet</portlet-class> 29 <expiration-cache>0</expiration-cache> 30 <supports> 31 <mime-type>text/html</mime-type> 32 <portlet-mode>VIEW</portlet-mode> 33 <portlet-mode>EDIT</portlet-mode> 34 <portlet-mode>HELP</portlet-mode> 35 </supports> 36 <supported-locale>en</supported-locale> 37 <supported-locale>de</supported-locale> 38 <supported-locale>fr</supported-locale> 39 <supported-locale>es</supported-locale> 40 <supported-locale>it</supported-locale> 41 <supported-locale>ja</supported-locale> 42 <supported-locale>nl</supported-locale> 43 <supported-locale>pt</supported-locale> 44 <supported-locale>zh-CN</supported-locale> 45 <supported-locale>zh-TW</supported-locale> 46 <resource-bundle>nls.NovellAccountsPortlet</resource-bundle> 47 <portlet-info> 48 <title>Novell Accounts Portlet</title> 49 <keywords>jsp, accounts, NovellConsultingPortlets</keywords> 50 </portlet-info> 51 <portlet-preferences> 52 <preference> 53 <name>contentPage</name> 54 <value>/jsps/novell-consulting-portlets/accountsportlet/content.jsp</value> 55 </preference> 56 <preference> 57 <name>editPage</name> 58 <value>/jsps/novell-consulting-portlets/accountsportlet/edit.jsp</value> 59 </preference> 60 <preference> 61 <name>helpPage</name> 62 <value>/jsps/novell-consulting-portlets/accountsportlet/help.jsp</value> 63 </preference> 64 <preference> 65 <name>debug</name> 66 <value>off</value> 67 </preference> 68 <preference> 69 <name>myAccountsMode</name> 70 <value>on</value> 71 </preference> 72 <preference> 73 <name>attributeAccountsMode</name> 74 <value>off</value> 75 </preference> 76 <preference> 77 <name>ldapFilterAccountsMode</name> 78 <value>off</value> 79 </preference> 80 <preference> 81 <name>userDN</name> 82 <value>${User/id}</value> 83 </preference> 84 <preference> 85 <name>userPwd</name> 86 <value>${Application/login-pass}</value> 87 </preference> 88 <preference> 89 <name>ldapHost</name> 90 <value>localhost</value> 91 </preference> 92 <preference> 93 <name>usersAttributeName</name> 94 <value>directReports</value> 95 </preference> 96 <preference> 97 <name>usersLdapFilter</name> 98 <value>(&(objectClass=user)(isManager=TRUE))</value> 99 </preference> 100 <preference> 101 <name>entitlements</name> 102 <value>cn=SapAccountEnt,cn=SapUser,cn=driverset,dc=idm,dc=system~SAP~Primary</value> 105 <value>cn=NotesAccountEnt,cn=Notes,cn=driverset,dc=idm,dc=system~Notes~Primary</value> 108 </preference> 109 <preference> 110 <name>associatedAccounts</name> 111 <value>cn=SapUser,cn=driverset,dc=idm,dc=system~SAP~SAP Account</value> 112 <value>cn=Notes,cn=driverset,dc=idm,dc=system~Notes~Notes Account</value> 113 </preference> 114 <preference> 115 <name>parametersSeparator</name> 116 <value>\*</value> 117 </preference> 118 </portlet-preferences> 119 </portlet> 120 </portlet-app>
Installation
The script asks for the folder where the WAR file is and for its exact name (IDM.war or IDMProv.war). JBoss should be stopped before launching the script. Java and the command "jar" in particular should be present in the path, or you can adapt the script to specify the full path.
1 #!/bin/sh
2
3 DEFAULT_USER_APP_WAR_FILE_DIR=/opt/novell/idm/jboss/server/IDM/deploy
4 DEFAULT_USER_APP_WAR_FILE=IDM.war
5 PORTLET_ID=NovellConsultingPortlets-0.3
6 PORTLET_NAME="Novell Consulting Portlet v0.3"
7
8 echo =========================================================
9 echo Portlets Installer Script
10 echo =========================================================
11 echo
12 echo [INFO___] Starting!
13 echo [INFO___] Package to install: $PORTLET_NAME
14 echo [INFO___] Checking if package data present
15
16 if [ -f ${PORTLET_ID}_install.tar.gz ]; then
17
18 echo [INFO___] Checking if JBoss server not running
19 pid=`ps -ef | grep org.jboss.Main | grep -v grep | awk '{print $2}'`
20 if [ "${pid}" = "" ]
21 then
22 echo [INFO___] JBoss server is not running
23 else
24 echo [ERROR__] JBoss server is running. Stopping installation.
25 echo [INFO___] Please check that your JBoss server is stopped...
26 echo
27 exit
28 fi
29
30 echo
31 echo -n User Application WAR file directory [$DEFAULT_USER_APP_WAR_FILE_DIR]:
32 read USER_APP_WAR_FILE_DIR
33 if [ "$USER_APP_WAR_FILE_DIR" = "" ]; then
34 USER_APP_WAR_FILE_DIR=$DEFAULT_USER_APP_WAR_FILE_DIR
35 fi
36
37 echo -n User Application WAR file name [$DEFAULT_USER_APP_WAR_FILE]:
38 read USER_APP_WAR_FILE
39 if [ "$USER_APP_WAR_FILE" = "" ]; then
40 USER_APP_WAR_FILE=$DEFAULT_USER_APP_WAR_FILE
41 fi
42
43 echo
44 echo [INFO___] Using WAR file directory: $USER_APP_WAR_FILE_DIR
45 echo [INFO___] Using WAR file name: $USER_APP_WAR_FILE
46
47 if [ -f $USER_APP_WAR_FILE_DIR/$USER_APP_WAR_FILE ]; then
48 echo [INFO___] ... Removing temp directory /tmp/${PORTLET_ID}Installer
49 rm -rf /tmp/${PORTLET_ID}Installer
50 echo [INFO___] ... Creating temp directory /tmp/${PORTLET_ID}Installer
51 mkdir /tmp/${PORTLET_ID}Installer
52 echo [INFO___] ... Creating temp directory /tmp/${PORTLET_ID}Installer/work
53 mkdir /tmp/${PORTLET_ID}Installer/work
54
55 echo [INFO___] ... Copying $USER_APP_WAR_FILE file to /tmp/${PORTLET_ID}Installer/orig.$USER_APP_WAR_FILE
56 cp $USER_APP_WAR_FILE_DIR/$USER_APP_WAR_FILE /tmp/${PORTLET_ID}Installer/orig.$USER_APP_WAR_FILE
57
58 echo [INFO___] ... Copying Portlet package ${PORTLET_ID}_install.tar.gz
59 cp ${PORTLET_ID}_install.tar.gz /tmp/${PORTLET_ID}Installer
60
61 echo [INFO___] ... Extracting $USER_APP_WAR_FILE file content to /tmp/${PORTLET_ID}Installer/work
62 cd /tmp/${PORTLET_ID}Installer/work
63 jar xf ../orig.$USER_APP_WAR_FILE
64
65 echo [INFO___] ... Installing Portlet content ${PORTLET_ID}_install.tar.gz
66 tar xzf ../${PORTLET_ID}_install.tar.gz
67
68 if [ -f WEB-INF/portlet.orig.xml ]; then
69 echo [INFO___] ... Checking portlet.orig.xml content
70 else
71 echo [INFO___] ... Backuping portlet.xml file to portlet.orig.xml
72 cp WEB-INF/portlet.xml WEB-INF/portlet.orig.xml
73 fi
74
75 PORTLET_ENTRY=`grep ${PORTLET_ID} WEB-INF/portlet.orig.xml`
76
77 if [ "$PORTLET_ENTRY" = "" ]; then
78 echo [INFO___] ... Updating portlet.xml content
79 head WEB-INF/portlet.orig.xml -n-1 > ../portlet.xml
80 tail WEB-INF/portlet_${PORTLET_ID}.xml -n+6 >> ../portlet.xml
81 cp ../portlet.xml WEB-INF/portlet.xml
82 else
83 echo [WARNING] ... Portlet already exists in portlet.orig.xml, no update
84 fi
85
86 echo [INFO___] ... Building new $USER_APP_WAR_FILE file
87 jar cfm ../$USER_APP_WAR_FILE META-INF/MANIFEST.MF *
88
89 echo [INFO___] ... Deploying new $USER_APP_WAR_FILE file
90 cp ../$USER_APP_WAR_FILE $USER_APP_WAR_FILE_DIR
91
92 echo [INFO___] Finished!
93 echo [INFO___] You can now restart your JBoss server
94 echo
95 else
96 echo [ERROR__] WAR file $USER_APP_WAR_FILE not found. Stopping installation.
97 echo
98 fi
99 else
100 echo [ERROR__] Portlet package ${PORTLET_ID}_install.tar.gz not found. Stopping installation.
101 echo
102 fi
Don't hesitate to adapt these scripts to your needs. Hope this can help!
| Attachment | Size |
|---|---|
| NovellConsultingPortlets_build.sh_.zip | 349 bytes |
| NovellConsultingPortlets_install.sh_.zip | 1.16 KB |
| portlet_NovellConsultingPortlets-0.3.xml_.zip | 1.19 KB |
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 5136 reads



0