Pages

Thursday, June 11, 2009

RIDC - New Connector to Oracle UCM

As required sometime, you might need to access and interact with Oracle UCM externally.

Originally, Oracle UCM exposes two kinds of interfaces to be used:

1. SOAP Web Service

2. Content Integration Suite (CIS)

Remote Intradoc Client (RIDC) is new in latest release.

In contrast with both CIS and SOAP, the RIDC connector is very lightweight and simple to use. There's no WSDL or J2EE bloat at all; RIDC is just a "Plain Old Java Object" wrapper around UCM web services... so it's very easy to embed in a Java application.

To get started, download the most recent version of the Content Integration Suite from Oracle. This ZIP file contains two folders: one for the new RIDC connector, and one for the standard CIS connector. I'd suggest you take a look at the "ridc-developer-guide.pdf" before you go any further. The samples and JavaDocs are also very useful, but you can peruse them later.

Basically, it's a very simple API in which you create and open a connection with UCM, build up a dataset, and call a service. The data is then returned to you that you can map to java objects to act upon.

The hardest part is to figure out what services in UCM to call and what parameters to pass. You'd better to bookmark our Services Reference Guide for those information.

Before using it, copy the RIDC library "oracle-ridc-client-10g.jar" to the java project.

Here are some sample snippets:

(1) Create and Open a connection to UCM

//arguments needs to connect to UCM
String idcConnectionURL = "idc://localhost:4444";
String username = "sysadmin";
String password = "idc";

//Create the IdcClient
IdcClientManager clientManager = new IdcClientManager ();
IdcClient client = clientManager.createClient (idcConnectionURL);
IdcContext userContext = new IdcContext(username, password);

(2) Ping Server

//Create the DataBinder and populated it with needed information for
//the service call
DataBinder dataBinder = client.createBinder ();
dataBinder.putLocal ("IdcService", "PING_SERVER");

//Join the binder and the user context and perform the service call
ServiceResponse response = client.sendRequest (userContext, dataBinder);

//Convert the response to a dataBinder
DataBinder responseData = response.getResponseAsBinder ();

//Display the status of the service call
System.out.println (String.format("Ping Server response: %s", responseData.getLocal ("StatusMessage")));

15 comments:

Ritesh Sail said...

When i call GET_FILE service with dDocName and RevisionSelectionMethod, I am able to get the file and display it in the browser. but when the content with the dDocName doesn't exist in the Content Server then it returns few stream data ..no exception is thrown...
How can I check whether the stream received is the content from the Content server or just some data..

Brenda said...

You have to check the status info to see if the service GET_FILE is executed successfully. Then to get the stream data which is the one you need.

Monika Sood said...

Hi, i m new to UCM and i want to get the contents of some asset checked-in in UCM into my Java code. I have the docName and redention.Can i use GET_FILE service here? If yes then, what does it return and how?

Brenda said...

Sorry to reply so late. I am quite busy these days.

Monica, i have written a sample before. Do you still need it? Please let me know.

Monika Sood said...

Hi Brenda,

Thanks for your response. It would be great if you can repost the example as i am not able to find it here.

Thanks in advance.

Brenda said...

public void getFile (String dID) throws IdcClientException, IOException {
//Get the client (from the base class) and create a new binder
IdcClient client = getClient();
DataBinder dataBinder = client.createBinder ();

//retrieve the file, check the file size
dataBinder.putLocal ("IdcService", "GET_FILE");
dataBinder.putLocal ("dID", dID);
ServiceResponse response = client.sendRequest (getUserContext(), dataBinder);
int reportedSize = Integer.parseInt (response.getHeader ("Content-Length"));
int retrievedSize = 0;
String contentsInHex = "";

//The file is streamed back to us in the response
InputStream stream = response.getResponseStream ();
try {
int read = 0;
byte [] buf = new byte [256];
while ((read = stream.read (buf)) != -1) {
retrievedSize += read;
contentsInHex += toHexString (buf);
}
} finally {
//It is very important that we close the stream thus releasing the connection
stream.close ();
}

System.out.println(String.format("First 10 bytes in hex: %s", contentsInHex.substring (0, 10).toUpperCase ()));
System.out.println(String.format("Total bytes retrieved: %d of reported: %d", retrievedSize, reportedSize));
}

Brenda said...

You also can find this sample in the download package of RIDC with the documentation.

Monika Sood said...

Thanks Brinda for your help.

Unknown said...

I have verified the samples folder, i have got the connectivity for UCM, Now my doubt over here is how can I check in (or move in ) a new file or document into this UCM. The samples directory provides examples for searching, getting the latest file that is recently checked and deleting a file. What If I need to check in my own file

Mahender said...

Brenda,

Do you have an idea why the following error message occurs when i try execute 'PING_SERVER' example from sample code.
Appreciate your help.

Feb 1, 2010 3:25:16 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
Feb 1, 2010 3:25:16 PM org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: Failure authenticating with BASIC
'Idc Security /idc/idcplg'@epmdoss1.tgslc.org:8044
oracle.stellent.ridc.protocol.http.HttpProtocolException: HTTP/1.1 401 Access denied
at oracle.stellent.ridc.protocol.http.IdcHttpProtocol.writeRequest (IdcHttpProtocol.java:151)
at oracle.stellent.ridc.IdcClient.sendRequest(IdcClient.java:140)
at com.org.SamplesBase.pingServer(SamplesBase.java:170)
at com.org.PingServer.main(PingServer.java:18)
Process exited with exit code 0.

TigerLin said...

I am writing an ADF web application and am using GET_FILE via RIDC to get a media file (e.g. wmv) file from UCM. Right now, I have to write the data return by GET_FILE to an temp file in a staging area and then use ADF Media control to launch player to play the video.

Is there a way to have GET_FILE launch the player directly via RIDC?

George said...

Nice post! Save me a lot of time!

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi ,

Can any one let me know will this Java code is valid and can be embedded into Java Embedded Activity.
Iam new to UCM and SOA.

Iam using 11.1.1.6

Regards,
Suman

Siva Sankar said...

nice very useful,when I call GET_FILE i ma able to download.but here How can I set the Content Type at runtime.
ServiceResponse responseString =
idcClient.sendRequest(userContext, dataBinder);
String contentType = responseString.getHeader("Content-Type");
I am doing the same but its showing null value as null.
can you please give me some solution for the same