Tuesday, April 6, 2010

Lazy Developer


I was reading some tutorials for Oracle WebLogic Portal (WLP), and they mention it is good practice to separate your WLP project in a folder structure  to make it easier to manage and add it to source control.

One structure I found to be good, is to use the following:

HOME/workspaces/projectX/           # workspace directory for Project X

HOME/projects/projectX/             # directory for the Project X projects
                 prjX_portalEAR/    # your EAR project
                 prjX_portalWeb/    # your WAR project
                 prjX_datasync/     # a Datasync project
                 prjX_ejb/          # an EJB project
                 prjX_utility/      # a J2EE utility project
                 prjX_webServices/  # a J2EE utility project

HOME/domains/prjX_domain/           # domain directory for Project X

Note: You may have a structure that looks a bit different, and that is ok. The main point of this post is not the structure itself, but being lazy about it :-)

I started running through tutorials, and first time, you go ahead and manually create the folder structure. Then you try, and nothing works, so you erase it all, and start again. Once again, you go ahead with File Explorer, and make all these folders.

You notice this is a painful process. After all, the whole idea is to have the computer do the work, and not you. Also, I'm a bit lazy developer, and I really like automating things, so I don't have to do the work over and over. BTW, there is also a great post about this -- "When Windows are not enough".

So, I sit down and write the following BAT script that receives 2 parameters:
  • Project_Name -- projectX from example above
  • Project_Prefix -- prjX from example above

Here is the BAT file:
@echo off

IF not "%1"=="" GOTO GOOD
:EXIT
echo "Error in %0 - Invalid Argument Count"
echo "Syntax: %0 Project_Name Project_Prefix"
goto END

:GOOD
echo "SETTING UP PROJECT: %1 [%2]";

echo "CLEAN UP..."
rmdir /s /q domains\%2_domain\
rmdir /s /q projects\%1\
rmdir /s /q workspaces\%1\

echo "CREATE DOMAIN..." 
mkdir domains\%2_domain\

echo "CREATE WORKSPACE..."
mkdir workspaces\%1

echo "CREATE PROJECTS..."
mkdir projects\%1\%2_datasync
mkdir projects\%1\%2_ejb
mkdir projects\%1\%2_portalEAR
mkdir projects\%1\%2_portalWeb
mkdir projects\%1\%2_utility
mkdir projects\%1\%2_webServices

echo "DONE!"

:END

I also created similar script in shell script, as I have dual boot and I keep switching from Ubuntu to Win7.
#!/bin/sh

if [ $# -ne 2 ]
then
    echo "Error in $0 - Invalid Argument Count"
    echo "Syntax: $0 Project_Name Project_Prefix"
    exit
fi

echo "SETTING UP PROJECT: $1 [$2]";


echo "CLEAN UP..."
rm -rf domains/$2_domain/
rm -rf projects/$1/
rm -rf workspaces/$1/

echo "CREATE DOMAIN..."
mkdir -pv domains/$2_domain

echo "CREATE WORKSPACE..."
mkdir -pv workspaces/$1

echo "CREATE PROJECTS..."
mkdir -pv projects/$1/$2_datasync
mkdir -pv projects/$1/$2_ejb
mkdir -pv projects/$1/$2_portalEAR
mkdir -pv projects/$1/$2_portalWeb
mkdir -pv projects/$1/$2_utility
mkdir -pv projects/$1/$2_webServices

echo "DONE!"

Again, the script itself and the folder structure can be different, does not matter. What you really should always strive for is automation! Let the computer do the hard/tedious work, not you. You should be focusing on your solution (or your tutorial :)


Friday, April 2, 2010

N-1 WebCenter-UCM Install


Sometimes, you may want to have a single instance of Oracle UCM shared to multiple instances of Oracle WebCenter. One good example we had for this, is a fellow Oracle employee running a bootcamp in China. Instead of installing 1-1 instances, he would like to have a N-1 topology, where you have N instances of WebCenter pointing to 1 instance of UCM.

The following is a link to Gary's post about how to do this installation -- 
http://blogs.oracle.com/garyniu/2010/04/content_management_for_webcenter_installation_guide.html

It is also a good read if you are having some other issues with your UCM install, specially the last section about "Configuring the Identity Store".

Thanks Gary!