UCM

...now browsing by category

 

UCM: Search, GetFile, Checkin with PL/SQL

Tuesday, June 5th, 2012

“Proof of concept” programming in many cases is the first draft of a finished product. Several of my starter programs are in the download section of this blog. They are PL/SQL programs that demonstrate simple Checkin, GetFile, and Search functionality. Besides using RIDC, when needing to retrieve content or Check-in content, these little programs can really help.

These are just proof of concept programs, so you will need to add any additional logging. Also, this program uses functionality originally found in flex_ws_api. This can be found on Jason Straub’s blog. Flex_ws_api has also been incorporated into Oracle’s Application Express in the APEX_WEB_SERVICE API. This code has also found its way into Alexandria, a PL/SQL Utils library.

With just a few additional lines of code, you can pull documents out of a database, and check them into UCM. All with PL/SQL code.

UCM 11g – Upgrade in Process

Tuesday, April 19th, 2011

Just started working on upgrading from Oracle’s UCM 10gR3 to 11g. The upgrade is going well. I am following the migration guide from Oracle. So far so good. I’ll let you know what problems I run into!

Converting .csv file to .hda for importing in Content Server

Friday, October 29th, 2010

One of my peers was talking to me about the pain he was having getting data from another system into UCM. I have done a lot of Java programming, so my thinking was to help out with a java solution. It works. Could this be done differently. Of course! I just picked one way that wouldn’t take up a lot of time. I did including a couple of third party libraries though.

Commons CLI

opencsv

In the first iteration, I was given a sample csv file, the expected result hda file, and a quick mapping of the metadata fields that were defined in the csv file. The initial idea was that each csv might have a different structure, so having a map file that listed which metadata fields were in the file would solve this. I said, “uh huh.” I left to code this. I put on my headphones and had this working in less than an hour.

I’m laughing because I didn’t give the code to my peer for another three or four hours. Seems simple. Just compile the code, and email a class, and two jar files. Should be simple. Not! Well, maybe it is, but I couldn’t get this to run outside of my development environment (A directory with several sub-directories for src, classes, libs, build, etc.). I kept getting a class not found error. I felt like the dumbest smart person for a while, which can happen a lot, just doesn’t last long in most cases. Well here, the feeling lasted a while. Honestly, I still don’t know what I was doing wrong. I already had a compiled class that worked fine in my ANT environment defined in the build.xml file. I finally created a jar file for the class, and added information in the manifest to point to the main class, and added the two jar files in the classpath. Now it works.

So on with the story.

I send over the three jar files and a quick command line call. With the Commons CLI, I setup the call to include three parameters, -csv, -src, and -out. I was sitting at my desk feeling great for about eight seconds, which was the time it took for my peer to walk over to my desk. Okay, maybe a minute, as he had to run the program before coming over to my desk.

The conversation kind of went like this. “You forgot to set this up to allow default values to be added. Also, there needs to be a way to add another metadata field that actually points to data in the csv file.”

Welcome to the life of a programmer.

On to the next iteration. I added the changes and the code works fine. Not exactly what was asked for, but it gets the job done. There may be another interation or two or three… But the bulk of the code is stable. The file is on the Downloads page. It is only about 130 lines of code, and most of that was for setting up for specific parameters in a specific format. Always those requirements – everything is in the details!

If anyone figures out or knows how to make this work with just the third party jars and the class file, please let me know. Must be something obvious!

You will need to download the commons CLI and opencsv libraries, and add these two jar files. Happy coding!

How to validate against a system table when checking in a document

Thursday, April 22nd, 2010

One of the problems we continue to face is comboboxes that contain a lot of data. 40,000 rows of data. Just having a few of these on a form can really make the system slow enough to be unusable. One solution is to just validate the data on submit. The key is to not loose the data if there are any problems.

Using examples from the howtobundle of examples from Oracle and also using Bex’s book – Custom Java Components chapter, I have put together a quick example. First create a component in the ComponentWizard. I named mine EmployeeCheckinValidation. Once you have this created (Follow the directions in Bex’s book if you are having trouble) create a project in JDeveloper. For this to work, you have to use the same JDK that is used in your UCM instance. In my case, I created a Samba mount point, and was able to point to the correct JDK using this method. You also have to add UCM’s server.jar file to your project’s jar library. To make things easier, I also set the projects source directory and output directories to directories named src and classes in the component – in my example ucm/server/cusom/EmployeeCheckinValidation/src and ucm/server/cusom/EmployeeCheckinValidation/classes. The last change was to the hda file. I added the following line below the line containing the version:
classpath=$COMPONENT_DIR/classes

Now when I rebuild the project, both the src and classes get updated automatically. Don’t forget to restart your server anytime you rebuild your file!

Here is the sample file that I have created. Basically, this will check that the title is not in the list of doctypes, which is one of the system tables. I’m sure there are other ways to accomplish this, but I thought I would share one way to do this. If you have ideas to make this better, please leave me a comment!

package testing;

import intradoc.common.ExecutionContext;
import intradoc.common.ServiceException;
import intradoc.common.SystemUtils;

import intradoc.data.DataBinder;
import intradoc.data.DataException;
import intradoc.data.DataResultSet;
import intradoc.data.ResultSet;
import intradoc.data.Workspace;

import intradoc.provider.Provider;
import intradoc.provider.Providers;

import intradoc.shared.FilterImplementor;

import intradoc.util.IdcMessage;


public class CheckinFilter implements FilterImplementor {
    public int doFilter(Workspace ws, DataBinder binder, ExecutionContext cxt) throws DataException, ServiceException {
        SystemUtils.trace("system", "Starting doFilter for EmployeeCheckinValidation");
        
        // Display the binder
        // System.out.println(binder);
        
        String dDocTitle = binder.getLocal("dDocTitle");
        SystemUtils.trace("system", "dDocTitle=" + dDocTitle);

        String SQL = "select count(*) counter from doctypes where upper(ddoctype) = '" + dDocTitle.trim().toUpperCase() + "'";
        String ResultSetName = "DDOCTYPECOUNT";
        SystemUtils.trace("system", "SQL=" + SQL);
        
        // Search database for ddoctitle in doctypes.ddoctype  Fail if
        // this this is true
                
        if (ws == null) {
            SystemUtils.trace("system", "ws is null, getting ws from call to getSystemWorkspace()");
            ws = getSystemWorkspace();
        }
        
        String value = "";
        int ivalue=0;
        DataResultSet result = null;
        DataException error = null;
        SystemUtils.trace("system", "try-catch block to get ResultSet from SQL");
        try {
            ResultSet temp = ws.createResultSetSQL(SQL);
            result = new DataResultSet();
            result.copy(temp);
            binder.addResultSet(ResultSetName,result);  // Makes results avilable for other Java methods or IdocScript templates.
        } catch (DataException de) { 
            error = de;
        } finally {
            // ws.releaseConnection();  // do NOT uncomment this, unless you like broken code!
        }

        try {
            result.first();
            // value = result.getStringValueByName("counter");
            value = result.getStringValue(0);
            SystemUtils.trace("system", "value(getStringValue(0)) = " + value);
            ivalue = Integer.parseInt(value);
            SystemUtils.trace("system", "ivalue=" + ivalue);
        } catch (NumberFormatException nfe) {
            SystemUtils.trace("system", "nfe.getMessage()=" + nfe.getMessage());
        }

        
        if (ivalue > 0) {
            SystemUtils.trace("system", "Throw error since dDocTitle cannot be a dDocType");
            throw new ServiceException("dDocTitle cannot be a dDocType");
        }
        
        if (error != null) {
            SystemUtils.trace("system", "Throw error since error condition exists.");
            throw error;
        }

        SystemUtils.trace("system", "Ending doFilter for EmployeeCheckinValidation");
        return CONTINUE;
    }
    
    public Workspace getSystemWorkspace() {
        Workspace workspace = null;
        Provider wsProvider = Providers.getProvider("SystemDatabase");
        if (wsProvider != null) {
            workspace = (Workspace)wsProvider.getProvider();
        }
        return workspace;        
    }
}

First week of training on UCM Admin down, one week of Site Studio training to go!

Saturday, January 23rd, 2010

Had a great week of on-site training with Jason Stortz as our instructor. I have to give two big thumbs up, as the training Jason provided was both tailored to our needs, and the amount of knowledge that he brings is inspiring.

What was the biggest take away?
Creating components in Java was really simple and powerful. The examples found at HowToComponentsBundle are a must have. Setting up JDeveloper to build the class files was really easy. There is a tutorial on building components. Unfortunately, the only source was on metalink. If you have access, go to community/Middleware/Universal Content Management – Then look in the popular documents section.

Other important notes: Repeating the mantra, “You need a component to do that” was the phrase of the week. With training, you realize that UCM is like many other Oracle products. You purchase a very base model, but get tools that, once you learn them, have the capability to get the job done. You have to think in UCM. This means that you need to learn IDocScript, and follow the component model system to get the functionality you need. So, what does that mean? Simple, you need a component to do that!

To give you an example. We have lots of documents that we need to import, but a large percentage of these documents have spaces in them. By using a little IDocScript and the RemoveWs function in the batch uploader, we were able to upload the documents with name without spaces. Now when we link to this content from our web server, we don’t have to deal with spaces and encoding links.

In order to get check-in documents to be space free, we created a component that removed spaces from the Original Name during the check-in. We were able to create a component using two lines of Java code to get this done. Of course there is more to it than this. Setting up a component to call the java code was done with the component manager, and we used one of the components found in the howto bundle as a template. We also needed to know what event to hook into. As you can see, a lot of setup just to get two lines of code to get the job done.

I will try to add more code that is UCM based as that is the direction my employer is taking. There seems to be a dearth of documentation on “How To” with UCM. Even though Bex’s Book is very helpful, more is needed!