How To Associate WebCenter Content Items To Any Folder In Bulk

As documented in the previous blog WebCenter Content – Useful Administrative SQL Queries there can be cases where content items become disassociated from their folders (for example, after a content migration). There are two options to correct this, using the BatchLoader with Action=Update command or by using much more generic Java code leveraging RIDC and IDC Services.

This blog gives the steps to achieve this requirement using RIDC.

The Logic used here is as follows:

  1. Identify the content ID’s which are not associated with folders.
  2. Format the list of content ID’s in this syntax:

dDocName <matches> ‘ABC123’

  1. Create the helper file which will act as service parameter inputs to code.
  2. Run the code with the files.

Here are the specific details for Steps 1-4:

1. Identify Content ID’s

Use the following query to get the list of all such content ID’s which are not part of any folders:

select distinct ddocname as ContentID from prod_ocs.revisions rev,prod_ocs.docmeta doc   where rev.did=doc.did and rev.ddoctype=’abc’
and rev.ddocname NOT IN (select fold.ddocname as ContentID FROM prod_ocs.folderfiles fold,prod_ocs.revisions rev,prod_ocs.documents docum
where fold.ddocname=rev.ddocname and rev.ddoctype=’abc’);

2. Format the List of Contents

The code here is developed with the assumption that the list of ID’s in the input file will be in the following format:

dDocName <matches> ‘ABC123’

Once the list is generated from Step 1, it needs to be formatted as mentioned above. This can be done using a script or Java code utilizing Regex mechanism.

The list will look like this:

dDocName <matches> ‘ABC123’

dDocName <matches> ‘ABC456’

dDocName <matches> ‘XYZ123’

dDocName <matches> ‘XYZ456’

Remove any other texts from the input file and save it.

3. Create the Helper File for Passing Parameters to Code

This file will hold all the basic details like the WebCenter Content host name, intradoc server port, user name for executing the code, and the Target Folder ID to which contents should be associated.

Here are examples for this Step:





4. RIDC Code

Here is the code snippet that does the processing on these WebCenter Content items and associates each of them to the specified folder:


import oracle.stellent.ridc.*;

import oracle.stellent.ridc.model.*;

import oracle.stellent.ridc.protocol.*;

import oracle.stellent.ridc.protocol.intradoc.*;

import oracle.stellent.ridc.common.log.*;

import oracle.stellent.ridc.model.serialize.*;

import oracle.stellent.ridc.protocol.http.*;

import java.util.List;

import java.util.*;

import java.text.*;

public class ItemsSearchandUpdate {

public static void main(String[] args) {

// Create a new IdcClientManager

IdcClientManager manager = new IdcClientManager ();

Properties prop = new Properties();

InputStream input = null;


input = new FileInputStream(“ContentUpdate.config”);

// load a properties file


// Create a new IdcClient Connection using idc protocol (i.e. socket connection to Content Server)

IdcClient idcClient = manager.createClient (prop.getProperty(“IDC_PROTOCOL”)+”://” + prop.getProperty(“RIDC_SERVER”) + “:” + prop.getProperty(“RIDC_PORT”));

idcClient.getConfig ().setSocketTimeout (900000);

IdcContext userContext = new IdcContext(prop.getProperty(“user”));

HdaBinderSerializer serializer = new HdaBinderSerializer (“UTF-8”, idcClient.getDataFactory ());

/** This is the section which reads the content list input.txt and iterates **/

BufferedReader br = new BufferedReader(new FileReader(“items.txt”));

for (String line = br.readLine(); line != null; line = br.readLine())


// Databinder for Search Request based on input.txt file

DataBinder dataBinder = idcClient.createBinder();

dataBinder.putLocal(“IdcService”, “GET_SEARCH_RESULTS”);


dataBinder.putLocal(“SearchQueryFormat” ,”Universal”);


// Write the data binder for the request to stdout

serializer.serializeBinder (System.out, dataBinder);

// Send the request to Content Server

ServiceResponse response = idcClient.sendRequest(userContext,dataBinder);

// Get the data binder for the response from Content Server

DataBinder responseData = response.getResponseAsBinder();

//Write the response data binder to stdout – only needed to view the entire result set

// serializer.serializeBinder (System.out, responseData);

// Retrieve the SearchResults ResultSet from the response

DataResultSet resultSet = responseData.getResultSet(“SearchResults”);

/** For every content item run Update service to add it to folder **//

for (DataObject dataObject : resultSet.getRows ()) {

System.out.println(“Content Id being updated is ” + dataObject.get(“dDocName”));

DataBinder dataBinder1 = idcClient.createBinder();

dataBinder1.putLocal(“IdcService”, “UPDATE_DOCINFO”);


dataBinder1.putLocal(“dID” ,dataObject.get(“dID”));




// Write the data binder for the request to stdout

serializer.serializeBinder (System.out, dataBinder1);

// Send the request to Content Server

ServiceResponse response1 = idcClient.sendRequest(userContext,dataBinder1);

} // Update loop ends

} // For loop ends

} catch (IdcClientException ice){


} catch (IOException ioe){





Once all the items from the list are processed, you need to verify from WebCenter Content that the items are listed under the folder specified in the ContentUpdate.config file TargetFolderID.

If you need more assistance administering WebCenter Content, or if you’d like help upgrading your Oracle WebCenter Content environment from 11g to 12c before the November deadline, contact us at Inspired ECM to let our experienced consultants get your environment upgraded and running successfully today.