Integrating CA Software Change Manager with a Java EE application

CA’s Software Change Manager is a tool that we use to manage software and documents.  Although much of our development staff is using GIT, many of our engineers still use SCM (or Harvest as it used to be known).  The primary way our web applications use Harvest is as a version controlled repository for documents.  Our web apps can link directly to the latest versions of documents and can even allow our users to checkout and modify documents through the web.  I’d like to share some of the techniques we’ve used to build a relationship between a Java EE application apps and Harvest.

The obvious choice for using Harvest with java is the JHSDK (Java Harvest SDK).  But through trial and error, I’ve learned that JHSDK fails in Java EE because it’s classes are not thread safe.  At the CA World conference a few years ago, I had the privilege of consulting with the father of Harvest (can’t remember his name) about this problem.  He said that I have two options, make the API thread safe or just make system calls to the command line interface (Harvest CLI).  Not knowing exactly how to make the API thread safe, I chose the latter.  It has never failed us.

Things to consider when designing a Harvest-related web app:

1.  The server on which your app server resides must have a Harvest client installed.   You’re essentially creating an automated Harvest user in your web app.

2.  Because you’re using a CLI instead of JHSDK, you have to retrieve errors and exceptions by reading logs.  Each Harvest command creates its own log file on the server.  So you have to manage log files in real time.  We create a new log file with a new random name with every command.  After the command runs, we check the log messages so that we can send the messages (including errors) back to the browser.  And finally, we delete the log file.  This is handled differently for asynchronous calls (see #5).

3.  Each Harvest command must contain user credentials.  When the user logs in, you could capture his/her username and password, but this isn’t very secure.  Ultimately, you want to use an auth file on the server.  This can be generated with a command using the username and password one time and never again (unless the password changes).  You name the auth file after the user name and then you can reference it anytime you need it.  The svrenc command looks like this:

String[] command = new String[11];
int i = 0;
command[i++] = “svrenc”;
command[i++] = “-f”;
command[i++] = userName+”.auth”;
command[i++] = “-usr”;
command[i++] = userName;
command[i++] = “-pw”;
command[i++] = password;
command[i++] = “-dir”;
command[i++] = siService.getAuthRootPath();
command[i++] = “-o”;
command[i++] = log;

4.  Building commands can be error prone if it’s done in one big String.  Fortunately, Java’s Runtime class takes a String array.  It’s best to build your commands this way. (see above example for building a command)

5.  Commands can be run asynchronously for long-running processes by putting the command into a thread.  As the thread runs it writes the progress of the log file output into the database and the client polls it with AJAX calls.  That way you can show progress on the process.

6.  When the user needs to view a file, it’s easier and quicker to use SQL rather than the hco command to get a blob and stream it out to the browser

7.  When the user needs to checkout a file (hci command), you’re checking it out to the server’s file system then streaming a copy of that file back to the web browser.

8.  To check in a file, upload the file through the web browser to the exact spot where it was checked out to, then run the hco command on it.

9.  Finally, use the documentation.  It comes with your installation and is called “CA Software Change Manager Command Line Reference Guide”.  Everything you can do with the SCM client can be done via the CLI, and therefore can be done in a web app.

Integrating your web apps with CA SCM can be a very powerful asset to your users.  We allow users to list, view, and manage files, promote/demote packages, edit forms, create comments, and approve/deny packages.  We had hoped that CA would be a decent web version of SCM, but it never happened, so we built the parts that we need.  We’ve been very successful, and using CLI calls has been very reliable.

Thanks for reading!  If you would like to see what else I’m up to, check out Whiff


  1. […] davidwburns Integrating a Java EE app with Allfusion Software Mgr, Java Harvest SDK, Uncategorized Allfusion Software Change Manager, Deployment, Harvest, Java EE, JHSDK 3 Comments [EDIT:  Ok. New info. JHSDK is not thread-safe. We've been very successful wrapping the CDI commands in java classes.  JHSDK is only appropriate for a Java SE environment.  Integrating CA Software Change Manager with a Java EE application […]

  2. RAJP,
    Great article. I found it very informative. The Father of Harvest, well that would have to be the distinguished Kevin Lin who is still the technical leader of the product.

  3. Hey David!! Thanks for the article. Let me ask some questions. I’m Brazilian and I not understand english with fluency. Therefore, I would like if you would have some examples where I could mirror to develop a similar solution? Basically what I need to do is a simple application in python that makes checkout a specific folder. Thanks in advance.

    • I don’t know Python, so I can’t give you examples. What you have to do is use Python code to execute Harvest commands on your operating system. See the SCM “Reference Guide” for how to construct Harvest commands.

  4. Hi,
    I am trying to promote a package using java as below.

    JCaMovePackage jPro = context.getMovePackage();
    jPro.setToState(“ACEDEV13.06.00.00”, “Integration Test (AIT)”);

    But i am getting exception, E03090050: ERROR: Could not get Move Package Process from Context.

    Please help me with this. Thanks in Advance!

  5. Hi David, hope everything is well with you.
    I wonder if you could help me with an issue:
    I have to create a package in Harvest from my desktop Java application (.jar) , it is a very simple process, and I just have to create some packages in harvest and then update those packages with some info, that my application previously retrieved and processed from another source.
    Do I need the JHSDK API on my application to make it execute these tasks? I heard I can just invoke some commands from my Java app, like commands I would execute on DOS:
    hcp “packagename” -b harwin64 -en “Package Description” -st Initial -usr user -pw password
    Will it work? I don’t have harvest on my machine, so I just can’t test this…

Leave a Reply to davidwburns Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s