Wednesday, November 17, 2004

ILWWCM 2.0.1

I began working with ILWWCM 2.0.1 this week. I can't believe that they call this thing a production-level content management system (it feels very much like a beta product, and is limited in so many ways).

Setting it up was a little bit of a hassle. At least for me, Mr. Microsoft, who has been spoiled with Installshields for everything in the past. I had to pull out the old text editor to make a lot of configuration changes--things that I would have hoped that W.A.S. could have taken care of.

And since I installed it four different times, that meant doing the manual steps of the installation four different times. This includes copying the contents of the web-app folder into the installedapps .war folder, and editing the aptrixjpe.properties, aptrixsearch.properties, and connect.cfg files to find-and-replace about five variables to match your configuration.

I got wise after that and created a VBScript file (executed using Windows Scripting Host) to do these manual steps for me. And, thanks to the Internet, I'm placing it here for the world to use. Disclaimer: This is provided as is with no warranty or support. Use at your own risk.

Install ILWWCM into WebSphere Application Server per the IBM instructions. Some specific things that I chose to do:

context = ilwwcm
app name = ILWWCM
binding = server1 (port 9080)

When I got to the part of the installation instructions where they talk about editing the config/property files and copying the web-app directory, I just run my script. Then a restart of WAS and I was on my way.

Save this script to a .vbs file in the ILWWCM install directory (the one that has "app", "contentportlet", and "web-app" directories in it), edit the script to change the values to match the server's configuration (comments tell you what to replace), and then run the script either using wscript (i.e., double-click in Explorer) or cscript (i.e., from cmd prompt).

Tip: Copy this and paste it into Notepad, then save as a .VBS file (i.e., configme.vbs) in your ILWWCM install directory



'---------------------------------------------------------------------------------
' ILWWCM INSTALL HELPER SCRIPT by JASON F011@$ 11-17-2004
'
' JUST TO HELP GET AROUND THE PAIN-IN-THE-A$$ FILE COPYING AND FILE EDITING
' THAT IS REQUIRED WHEN SETTING UP ILWWCM 2.0 (and perhaps earlier)
'
' OBVIOUSLY, THIS IS A WINDOWS SCRIPTING HOST FILE, INTENDED TO BE EXECUTED
' ON A WINDOWS SERVER. NOT USING WINDOWS? FOLLOW IBM'S PAINFUL INSTRUCTIONS
'
' ALL RIGHT, IT'S NOT ALL THAT PAINFUL, SINCE THERE'S ONLY 3 FILES THAT NEED
' A BUNCH OF FIND-AND-REPLACINGS, BUT AFTER ABOUT THE 3RD INSTALL, I STARTED
' LOOKING FOR AN EASIER WAY TO DO THESE LITTLE TASKS
'---------------------------------------------------------------------------------
option explicit

dim scriptpath
dim WAS_INSTALLED_APPS
dim WAS_APP_NAME

scriptpath = left(wscript.scriptfullname, instrrev(wscript.scriptfullname, "\"))


dim variables
set variables = createobject("scripting.dictionary")

'------------------------------------------------------
' CHANGE THIS VALUE TO THE PATH WHERE YOUR WAS INSTALLED
' APPLICATIONS ARE (no ending slash)
'------------------------------------------------------

WAS_INSTALLED_APPS = "C:\WebSphere\AppServer\installedApps\myserver"




'------------------------------------------------------
' CHANGE THIS VALUE TO THE NAME THAT YOU GAVE THE
' APPLICATION WHEN YOU INSTALLED IT INTO WAS
'------------------------------------------------------

WAS_APP_NAME = "ILWWCM"




'------------------------------------------------------
' REPLACE THE FOLLOWING VALUES WITH ENVIRONMENT-SPECIFIC
' VALUES AS NECESSARY
'------------------------------------------------------

variables("[HOST]") = "myserver"
variables("[PORT]") = "9080"
variables("[CONTEXT_ROOT]") = "ilwwcm"
variables("[WEB_APP_HOME]") = replace(WAS_INSTALLED_APPS, "\", "/") & "/" & WAS_APP_NAME & ".ear/ilwwcm.war"
variables("[ILWWCM_HOME]") = replace(scriptpath, "\", "/") & "app"

variables("file:///") = "file:" ' Per IBM documentation






'-------------------------------------------------------------------
' Everything that you need to change should be above this point
'-------------------------------------------------------------------







' Kind of messy, inefficient because each set of code is repeated for each config
' file, but I'm okay with that for now. If I get a chance to refactor, then I'll
' make this a lot cleaner.


dim fso
set fso = createobject("scripting.filesystemobject")


'--- Make sure that the samples are where they're supposed to be, else abort

if not fso.FileExists(scriptpath & "app\config\samples\aptrixjpe.properties") then
wscript.echo "Could not file sample aptrixjpe.properties. Be sure that you
run this script from the root of your ILWWCM install directory."
wscript.quit
end if

if not fso.FileExists(scriptpath & "app\config\samples\aptrixsearch.properties") then
wscript.echo "Could not file sample aptrixsearch.properties. Be sure that you run this script from the root of your ILWWCM install directory."
wscript.quit
end if

if not fso.FileExists(scriptpath & "app\config\samples\connect.cfg") then
wscript.echo "Could not file sample connect.cfg. Be sure that you run this script from the root of your ILWWCM install directory."
wscript.quit
end if






'--- Back up any current existing config files using timestamp-based suffixes

if fso.FileExists(scriptpath & "app\config\aptrixjpe.properties") then
fso.MoveFile scriptpath & "app\config\aptrixjpe.properties", scriptpath & "app\config\aptrixjpe.properties." & cdbl(now)
end if

if fso.FileExists(scriptpath & "app\config\aptrixsearch.properties") then
fso.MoveFile scriptpath & "app\config\aptrixsearch.properties", scriptpath & "app\config\aptrixsearch.properties." & cdbl(now)
end if

if fso.FileExists(scriptpath & "app\config\connect.cfg") then
fso.MoveFile scriptpath & "app\config\connect.cfg", scriptpath & "app\config\connect.cfg." & cdbl(now)
end if





'--- Copy/Edit the config files to replace all variable placeholders with values set above

dim f, contents, v

set f = fso.OpenTextFile(scriptpath & "app\config\samples\aptrixjpe.properties", 1)
contents = f.ReadAll
f.close

for each v in variables.keys
contents = replace(contents, v, variables(v))
next

set f = fso.OpenTextFile(scriptpath & "app\config\aptrixjpe.properties", 2, true)
f.write contents
f.close


set f = fso.OpenTextFile(scriptpath & "app\config\samples\aptrixsearch.properties", 1)
contents = f.ReadAll
f.close

for each v in variables.keys
contents = replace(contents, v, variables(v))
next

set f = fso.OpenTextFile(scriptpath & "app\config\aptrixsearch.properties", 2, true)
f.write contents
f.close


set f = fso.OpenTextFile(scriptpath & "app\config\samples\connect.cfg", 1)
contents = f.ReadAll
f.close

for each v in variables.keys
contents = replace(contents, v, variables(v))
next

set f = fso.OpenTextFile(scriptpath & "app\config\connect.cfg", 2, true)
f.write contents
f.close




'--- Copy the web files to the web app home
wscript.echo "About to copy the web directory. After copying is complete, a message stating 'Done!' will be shown."

fso.CopyFolder scriptpath & "web-app\*", replace(variables("[WEB_APP_HOME]"), "/", "\"), true

wscript.echo "Done!"