Friday, May 25, 2012

Accessing Webcenter Content repository using RIDC

My preferable way to access Webcenter Content (former UCM) repository from Java code is RIDC API. To establish RIDC connection you can use below code:

/*The Remote Intradoc Client (RIDC) provides a thin communication API 
for communication with Oracle Content Server. This API removes data 
abstractions to the content server while still providing a wrapper to 
handle connection pooling, security, and protocol specific
Intradoc communication is handled via the content server Intradoc port (typically
4444). This communication method requires a trusted connection between the
client and content*/
IdcClientManager manager = new IdcClientManager (); 

/*idc://localhost:4444 Intradoc communication. Uses the Intradoc port, 
only requires hostname and port number.
idcs://localhost:4433 SSL communication. Uses SSL over the 
Intradoc port; requires extra configuration*/
IdcClient client = manager.createClient("idc://hostname:4444");

/*Configuration of the clients can be done after they are created. Configuration
parameters include setting the socket timeouts, connection pool size, etc. The
configuration is specific to the protocol; if you cast the IdcClient object to the specific
type, you can then retrieve the protocol configuration object for that type.*/
client.getConfig().setSocketTimeout(30000); // 30 seconds
client.getConfig().setConnectionSize(20); // 20 connections

/*RIDC allows Secure Socket Layer (SSL) communication with Oracle Content Server
using the Intradoc communication protocol. To establish SSL connection you must install and enable 
the Security Providers component on the instance of the content server you wish 
to access and configure the content server for SSL communication.*/
client.getConfig().setKeystoreFile ("ketstore/client_keystore"); // keystore file
client.getConfig().setKeystorePassword ("password"); // keystore password
client.getConfig().setKeystoreAlias ("SecureClient"); // keystore aliaa
client.getConfig().setKeystoreAliasPassword ("password"); // keystore alias password

/*All calls to RIDC require some user identity. Optionally, this identity can be
accompanied by credentials as required by the protocol used. The user identity is
represented by the IdcContext object; once created, it can be reused for all subsequent
calls.*/
IdcContext context = new IdcContext("sysadmin");

/*You can also pass identity with passowrd: 
IdcContext userPasswordContext = new IdcContext ("sysadmin", "idc");*/

/*To invoke a service, use the ServiceRequest object, which can be obtained from the
client. Creating a new request will also create a new binder and set the service name in
the binder along with any other default parameters. You can then populate the binder
as needed for the request.*/
DataBinder dataBinder = client.createBinder ();

dataBinder.putLocal ("IdcService", "DOC_INFO_BY_NAME");

dataBinder.putLocal ("dDocName", "123simple");

ServiceResponse response = client.sendRequest (context, dataBinder);

DataBinder responseData = response.getResponseAsBinder ();

String docUrl = responseData.getLocal("DocUrl");

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java EE Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete