Integrating Oracle WebCenter Content Images into Portal

Prerequisites: Oracle WebCenter Content, UCM, WebCenter Portal, RIDC

When we do large portal site development, we usually store enterprise content and images in content repository. Content repository offers library services, content oracle_wc2check-in / out and versioning, etc., which allows content more manageable and traceable.

A common use case is to present images that store in content repository in portal page directly. Let’s see how we do this under Oracle WebCenter Content and Portal environment.

The idea is to build up a HashMap which holds key-value pairs docName-docURL. When portal page renders, it references to the specific docName key defined in the image tag and loads the image based on the value of docURL from content repository. The HashMap is prepared based on a pre-set properties file which holds image element display name and docName pairs. The properties file is pre-loaded, during the loading, the application retrieves docURL from content repository based on docName, and loads docName-docURL pair into the HashMap mentioned.

First, build a ContentMetadata class which holds the attributes for a content piece defined in WebCenter Content;
Second, build up a UCMContentBundle using HashMap. If the specific key is not available in the HashMap, then load it from WebCenter Content using RIDC API;
Third, load docURL from WebCenter Content through RIDC DOC_INFO_BY_NAME service.

Below is code snippets for your reference:

//ContentMetadata
public class ContentMetadata {
   private String dId;
   private String dDocName;
   private String dDocTitle;
   //URL to the content (image file)
   private String docURL;
   private String dDocAuthor;
   private String dDocType;
......

//UCMContentBundle
   contentBundle = new HashMap<String, ContentMetadata>();
   ......
   try {
      if (getContentBundle().get(key) == null)
      loadContent(key.toString());
      value = ((ContentMetadata)getContentBundle().get(key)).getDocURL();
   } catch (ServiceException se) {
   ......
   }

//Get docURL from WebCenter Content through RIDC DOC_INFO_BY_NAME service:
......
public ContentMetadata getDocInfoByName(String dDocName)
   throws IdcClientException, Exception
{
   ServiceResponse seveviceResponseInfo = null;
   IdcClient idcClient = getIdcClient();
   IdcContext userCtxt = getUserContext();
   DataBinder dataBinderInfo = idcClient.createBinder();
   dataBinderInfo.putLocal("IdcService", "DOC_INFO_BY_NAME");
   dataBinderInfo.putLocal("dDocName", dDocName);
   dataBinderInfo.putLocal("RevisionSelectionMethod", "Latest");
   seveviceResponseInfo = idcClient.sendRequest(userCtxt, dataBinderInfo);
   DataBinder response = seveviceResponseInfo.getResponseAsBinder();
   ContentMetadata docInfo = new ContentMetadata();
   docInfo.setDId(response.getLocal("dID"));
   docInfo.setDDocTitle(response.getLocal("dDocTitle"));
   docInfo.setDDocName(response.getLocal("dDocName"));
   docInfo.setDocURL(qualifyURL(response.getLocal("DocUrl")));
   ......
   return docInfo;
}