Oracle

Install Oracle UCM 10gR3 on Windows XP

Installing Oracle UCM 10gR3 on Windows is very similar to the Linux installation. Basically you'll have to go through the same steps:

  • Install and configure the Oracle XE Database
  • Install Oracle UCM
  • Install and configure the Apache Webserver

Install and configure the Oracle XE Database

Simply install the Oracle XE 10g Database, nothing special here.

After installing the database, you'll have to create a new tablespace for UCM. Connect to the database as SYSDBA using SQL*Plus and run the following commands:

CREATE TEMPORARY tablespace idc_temp 
  tempfile 'c:\oraclexe\oradata\XE\idc_temp.dbf' 
  SIZE 200M reuse autoextend ON NEXT 5120k maxsize unlimited;
 
CREATE tablespace idc_sys 
  datafile 'c:\oraclexe\oradata\XE\idc_sys.dbf' 
  SIZE 200M reuse autoextend ON NEXT 5120k maxsize unlimited;
 
CREATE USER idc 
  IDENTIFIED BY idc 
  TEMPORARY tablespace idc_temp 
  DEFAULT tablespace idc_sys 
  quota unlimited ON idc_sys;
 
GRANT CONNECT, resource TO idc;

Install Oracle UCM

Download the required file from the Oracle website and unzip it in your home directory. Now go to the following directory:

UCM -> ContentServer -> win32

And run the setup script:

setup.bat

The Oracle Content Server setup script will walk you through several steps. Most of them should be left as default, but some should have different values:

Oracle User: idc
Oracle Password: idc
Oracle Instance Name: XE
Attempt to create database tables: yes

Install and configure the Apache Webserver

The final step is to configure the Apache Webserver.

After installing the webserver, edit the file

LoadModule IdcApacheAuth "C:/stellent/shared/os/win32/lib/IdcApache22Auth.dll"
IdcUserDB idc "C:/stellent/data/users/userdb.txt"
 
Alias /idc "C:/stellent/weblayout"
<Location /idc>
        Order allow,deny
        Allow from all
        DirectoryIndex portal.htm
        IdcSecurity idc
</Location>

And that's all!

Parsing a HDA file from a Java application

Sometimes you might want to parse a .hda file in a custom Java application, outside of the Oracle UCM.

Here is a sample code:

/*
 * Main.java
 */
package hdatest;
 
import intradoc.data.DataBinder;
import intradoc.data.DataSerializeUtils;
import intradoc.resource.ResourceUtils;
import intradoc.serialize.DataBinderSerializer;
 
public class Main {
 
	public static void main(String[] args) {
		DataBinder dataBinder = null;
		String dir = "/usr/lib/oracle/ucm/data/profiles/document/";
		String file = "dprules.hda";
 
		DataSerializeUtils.setDataSerialize(new DataBinderSerializer());
 
		try {
			dataBinder = ResourceUtils.readDataBinderHeader(dir, file);
		} catch (Exception e) {
			e.printStackTrace();
			return;
		}
 
		String str = dataBinder.getLocal("blDateFormat");
		System.out.println("blDateFormat: " + str);
	}
}

To compile the above source code you'll have to include the file /shared/classes/server.zip in your classpath:

javac -classpath /usr/lib/oracle/ucm/shared/classes/server.zip hdatest/Main.java

The important bit here is the initialization of the serializer. Without it you will get an ugly exception like this one:

intradoc.common.ServiceException: !csResourceUtilsFileIOError!csResourceUtilsFileReadError,dprules.hda
	at intradoc.resource.ResourceUtils.serializeDataBinderWithEncoding(ResourceUtils.java:251)
	at intradoc.resource.ResourceUtils.serializeDataBinderEx(ResourceUtils.java:86)
	at intradoc.resource.ResourceUtils.readDataBinderHeader(ResourceUtils.java:283)
	at hdareadtest.Main.main(Main.java:18)
Caused by: java.lang.NullPointerException
	at intradoc.data.DataSerializeUtils.detectEncoding(DataSerializeUtils.java:157)
	at intradoc.resource.ResourceUtils.serializeDataBinderWithEncoding(ResourceUtils.java:224)
	... 3 more

Running Oracle UCM in Debug Mode

Remote debugging is a standard Java feature that allows you to attach to a remote running Java process and start debugging it.

This is also possible with the Content Server process. Coupled with a capable IDE like Eclipse, it can help you debug custom components.

To enable the debug mode, you have to edit the file /bin/intradoc.cfg.

For Linux, you have to add the following line:

JAVA_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

For Windows, it's a different approach:

JAVA_OPTIONS_debug_enable=-Xdebug
JAVA_OPTIONS_debug_transport=-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

The "address" option tells the process to accept remote debugging over the port 8000. The option "suspend=n" tells the process not to wait for the attachment of the debugging client.

Install Oracle UCM 10gR3 on Ubuntu

Installing Oracle UCM 10gR3 on Ubuntu is quite easy. Here are the steps you'll have to take:

  • Install Apache Webserver
  • Install Oracle XE Database
  • Configure the database
  • Install Oracle UCM

Install Apache Webserver

To install Apache as a webserver, run the following command:

sudo apt-get install apache2

The UCM apache module requires some dependencies that are no longer available in modern ubuntu versions:

wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-2.95/libstdc++2.10-glibc2.2_2.95.4-24_i386.deb
sudo dpkg -i libstdc++2.10-glibc2.2_2.95.4-24_i386.deb

Install Oracle XE Database

Oracle databases have the bad habit of requiring at least 1GB of swap space, no matter the amount of RAM your system has. If you don't use a swap partition or the system swap space is less than 1GB, you can create a swap file only for the purpose of the install.

sudo dd if=/dev/zero of=/swapfile bs=1M count=600
sudo mkswap /swapfile
sudo swapon /swapfile

Thanks to Oracle's efforts to support Linux, installing the Oracle XE Database is a breeze.

deb http://oss.oracle.com/debian unstable main non-free to /etc/apt/sources.list
sudo wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | sudo apt-key add - 
sudo apt-get update
sudo apt-get install oracle-xe
sudo /etc/init.d/oracle-xe configure

Configure the database

Now you'll have to create a new tablespace for UCM. Connect to the database as SYSDBA using SQL*Plus and run the following commands:

CREATE TEMPORARY tablespace idc_temp 
  tempfile '/usr/lib/oracle/xe/oradata/XE/idc_temp.dbf' 
  SIZE 200M reuse autoextend ON NEXT 5120k maxsize unlimited;
 
CREATE tablespace idc_sys 
  datafile '/usr/lib/oracle/xe/oradata/XE/idc_sys.dbf' 
  SIZE 200M reuse autoextend ON NEXT 5120k maxsize unlimited;
 
CREATE USER idc 
  IDENTIFIED BY idc 
  TEMPORARY tablespace idc_temp 
  DEFAULT tablespace idc_sys 
  quota unlimited ON idc_sys;
 
GRANT CONNECT, resource TO idc;

Install Oracle UCM

Download the required file from the Oracle website and unzip it in your home directory. Now go to the following directory:

UCM -> ContentServer -> linux

And run the setup script:

sh setup.sh

The Oracle Content Server setup script will walk you through several steps. Most of them should be left as default, but some should have different values:

Oracle User: idc
Oracle Password: idc
Oracle Instance Name: XE
Attempt to create database tables: yes

Configure Apache Webserver

The final step is to configure the Apache Webserver. The best practice is to create a new site configuration file /etc/apache2/sites-available/ucm with the following lines:

LoadModule IdcApacheAuth /usr/lib/oracle/ucm/shared/os/linux/lib/IdcApache22Auth.so
IdcUserDB idc "/usr/lib/oracle/ucm/data/users/userdb.txt"
 
Alias /idc "/usr/lib/oracle/ucm/weblayout"
<Location /idc>
        Order allow,deny
        Allow from all
        DirectoryIndex portal.htm
        IdcSecurity idc
</Location>

Than enable the newly created site:

sudo a2ensite ucm

Oracle Dual table trick

The other day I had to create a simple SELECT query. The query should return a single column result set or a default value if there was no data in the table. I know this would be a no brainer for somebody proficient in SQL, but I still find the solution neat enough to post it here.

SELECT NVL((SELECT COLUMN FROM TABLE WHERE KEY=VALUE), default_value)
  FROM DUAL;