Scripting old-style imports using CatalogMover's command line

image

For over a decade, WebCenter Sites (FutureTense Content Server, OpenMarket Content Server, FatWire Content Server, etc.) used a text-based import format exclusively for bulk content import and export. The format was HTML-based and essentially exported a database table into a HTML table.  Files were written to disk in folders alongside the HTML file.

A mini Swing Java app was created that allowed you to connect to the UI, and you then had a few tools you could use to list catalog data, select database rows to export, and import one or more files. Lightweight and very basic, it did the job for a very long time. But today we have CSDT, and this has really enabled the use of command line tools more in the import process.


CatalogMover main screen

 

But what about using the command line for old-style CatalogMover files?  Well, it turns out it is possible.

CatalogMover includes some basic information in the "usage" about its command line operation, but it is really not sufficient for any substantial work.

For starters, I created a handy-dandy convenience script that is located in my PATH. I use this all the time:

#! /bin/ksh
# Start Catalog Mover
ulimit -n 1024
OLDPWD=`pwd`
cd $(dirname $0)
CP=./classes/
CP=$CP:./lib/commons-logging-1.1.1.jar
CP=$CP:./lib/cs-core.jar
CP=$CP:./lib/cs.jar
CP=$CP:./lib/MSXML.jar
CP=$CP:./lib/commons-httpclient-3.1.jar
CP=$CP:./lib/commons-codec-1.4.jar
CP=$CP:./lib/commons-lang-2.4.jar
CP=$CP:./lib/sun-redistribs.jar
CP=$CP:./lib/spring-2.5.5.jar
CP=$CP:./lib/wem-sso-api-1.1.2.jar

java -classpath $CP COM.FutureTense.Apps.CatalogMover $*
cd $OLDPWD

Notice how it's designed to take an arbitrary argument. So I call this and pass in -h and get back:

Triton-II:~ tfield$ catalogmover.sh -h
Usage:
-p password
-u user name
-s server name (optional)
-b base URL (optional)
-t catalog name (can be repeated, export only)
-x function to perform (import, import_all, export, export_all)
-d directory to export to or import all from
-f file to import
-c catalog data directory (optional)
-a ACL list (optional)
-i ini file(s) to merge (optional)

CatalogMover exited.
Triton-II:~ tfield$

Which, still, is somewhat obscure. Let's focus on two arguments that give us the most control: -f and -c. -f lets you specify the 'file' containing the data you want to import. This almost always refers to a HTML file, since that is the native data format for CatalogMover. The other argument is -c, which stands for "Catalog Data", but really, this is a directory that contains the files that are exported when a catalog is exported. Usually this folder has the same name as the HTML file, and is located beside it. e.g.

-f ElementCatalog.html
-c ElementCatalog/

If you specify these two arguments, you can import a catalog and its data very easily.


CatalogMover Login Screen

Of course, when your'e talking to CatalogMover via the command line, you can't log using a GUI, so you also have to specify the URL (url base) of the host, the username, and password, or (-b, -u, -p respectively):

-b http://localhost:7001/cs/CatalogMover
-u ContentServer
-p password

And the actual command (-x), in this case, import:

-x import

And that's it. Put it all together and you have:

#!/bin/sh

echo
echo Importing elements

ENV_ROOT=/Users/tfield/MyProject
cd $ENV_ROOT/FutureTense
CLASSPATH=. #enter the required classpath from catalogmover.sh from the isntall kit, or above
CM_SHARED_ARGS="-b http://localhost:7001/cs/CatalogManager -u ContentServer -p password -x import"

VM_ARGS=-Xmx256M

ulimit -n 1024

echo ...Importing MyProject content
CM_ARGS="-f /Users/tfield/svn/MyProject/Populate/SiteCatalog.html"
java $VM_ARGS -classpath $CLASSPATH COM.FutureTense.Apps.CatalogMover $CM_SHARED_ARGS $CM_ARGS
CM_ARGS="-f /Users/tfield/svn/MyProject/Populate/ElementCatalog.html -c /Users/tfield/svn/MyProject/Populate/ElementCatalog"
java $VM_ARGS -classpath $CLASSPATH COM.FutureTense.Apps.CatalogMover $CM_SHARED_ARGS $CM_ARGS

# note that here, your script might repeat this for a different project, another tool, etc...

echo ...done.
echo

That's it! This feature has been available since 1998. Hope you enjoy it!

Comments

Subscribe to Our Newsletter

Stay In Touch