As with any applications, the overall emphasis is always to have an automated mechanism for configuration changes to be moved from source to target servers once the testing phase is over. This enables administrators to have an easy and controlled mechanism for setting up higher environments once QA testing on lower environments are completed.

Solution

WebCenter Content has rich API which can be used from Java or Soap frameworks to build on existing solutions or build a command line based automation mechanism for the majority of the functionality.

One of the use cases for this is Configuration Migration Utility (CMU) which is used extensively by WCC administrators to move configurations, views, rules, profiles, metadata, etc., from one server environment to the other.

You can find extensive details on this utility in the Oracle Documentation here: https://docs.oracle.com/middleware/12211/wcc/webcenter-content-admin/GUID-73251F2D-0FAF-4BA6-9F5B-CF8484860758.htm#WCCSA891

During the course of environments being set up for Development, Test, UAT, and finally Production, it is very often needed to move the configurations between the setups. Even though UI is one of the options for accomplishing this, it is much more efficient to have a command line based mechanism.

To achieve this requirement, here we are providing a small Java program, which leverages the Idc Services of CMU along with the relevant additional parameters.

Code sample:

import java.io.*;
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.*;
import java.util.zip.ZipInputStream;

public class CMU {
               InputStream fileStream = null;           
               private static final String filename = ""; 
               private static final String taskname = "";   	                    
               private static final String IDC_PROTOCOL = "";
               private static final String RIDC_SERVER = "";
               private static final String RIDC_PORT = "";
               private static IdcClientManager m_idcClientManager;
               private static IntradocClient m_idcClient;
               private static final String UTF8 = "UTF-8";
               private static final String USER = "";
               private static Properties prop = new Properties();
               private static InputStream input = null;
           

       public static DataBinder executeService(DataBinder binder, final String userName) throws IdcClientException {
                final HdaBinderSerializer serializer = new HdaBinderSerializer (UTF8, getIntradocClient().getDataFactory ());

                try {
                        System.out.println("Service binder before executing:");
                        serializer.serializeBinder (System.out, binder);
                } catch (final IOException ioe) {
                        ioe.printStackTrace(System.out);
                }

                // Execute the request
                final ServiceResponse response = getIntradocClient().sendRequest(new IdcContext(userName), binder);

                // Get the response as a DataBinder
                binder = response.getResponseAsBinder();

                 try {
                        System.out.println("Service binder after executing:");
                        serializer.serializeBinder (System.out, binder);
                } catch (final IOException ioe) {
                        ioe.printStackTrace(System.out);
                }

                // Return the response as a DataBinder
                return binder;
        }

        public static IdcClientManager getIdcClientManager() {
                if (m_idcClientManager == null) {
                        // Needed to create IntradocClient
                        m_idcClientManager = new IdcClientManager();
                }
                return m_idcClientManager;
        }

        public static IntradocClient getIntradocClient() throws IdcClientException {
               
                     try{ 
                       //Properties file initialized  		 
                        input = new FileInputStream("config.file");  
                        prop.load(input);
                     
                if (m_idcClient == null) {
                          m_idcClient = (IntradocClient)getIdcClientManager().createClient(prop.getProperty("IDC_PROTOCOL")+"://" + prop.getProperty("RIDC_SERVER") + ":" + prop.getProperty("RIDC_PORT"));
                }
               } catch (IOException ioe){
                        ioe.printStackTrace();
                      }
              return m_idcClient;
        }

      /**
         * This method gets a new DataBinder.
         * @return A new DataBinder.
         * @throws IdcClientException
         */
        public static DataBinder getNewDataBinder() throws IdcClientException {
                return getIntradocClient().createBinder();
        }
       
       public static void main(final String[] args){
                        
                        UploadCMU(filename);
                        ImportCMU(taskname);

                }                           	
      
      private static void UploadCMU(String filename) {
                     
                      try{                        
                        final DataBinder serviceBinder = getNewDataBinder();
                        serviceBinder.putLocal("IdcService", "CMU_UPLOAD_BUNDLE");
                        serviceBinder.addFile("bundleName",new File(prop.getProperty("filename")));
                        serviceBinder.putLocal("createExportTemplate","1");
                        serviceBinder.putLocal("forceBundleOverwrite","1");
                        // Execute service
                        executeService(serviceBinder, prop.getProperty("user"));
                      } catch (IdcClientException ice){
                        ice.printStackTrace();
                      }
                         catch (IOException ioe){
                        ioe.printStackTrace();
                      }

                  }                         

     private static void ImportCMU(String taskname){
                        try {                        
                        final DataBinder serviceBinder = getNewDataBinder();
                        serviceBinder.putLocal("IdcService", "CMU_UPDATE_AND_CREATE_ACTION");
                        serviceBinder.putLocal("TaskName",prop.getProperty("taskname"));
                        serviceBinder.putLocal("isImport","1"); // Parameter to indicate the operation is Import
                        serviceBinder.putLocal("sectionItemList","") //Mandatory parameter to be set. Leave it blank for whole bundle to be uploaded.                    
                        
                       /** Optional Parameters – Can be enabled based on requirement **/
                        serviceBinder.putLocal("IsContinueOnError",""); // By default not set hence blank. To enable set the value to 1
                        serviceBinder.putLocal("emailResults","") // By default not set hence blank. To enable set the value to 1
                        serviceBinder.putLocal("cb_addDependencies","1") // By default set to 1. If this is set to 1 then the next parameter is mandatory .
                        serviceBinder.putLocal("addDependencies","") // Leave this field as blank.
                        serviceBinder.putLocal("cb_isOverwrite","1") // For full iterations when configurations are being migrated on continuous basis this option should be enabled . Set to 1 . 
                        serviceBinder.putLocal("isOverwrite","1") // If the value for cb_overWrite is set to 1 then this parameter should be set to 1 as well.                         
                        executeService(serviceBinder, prop.getProperty("user"));
  
                      } catch (IdcClientException ice){
                        ice.printStackTrace();
                      }
                  }
              }

Conclusion

This code sample can be modified per specific requirements and can be run as a one-time operation for moving the entire configuration to a new environment or on an incremental basis, depending on test phases.

It can be run manually or using a cron job on specific intervals as well.

If you’d like help upgrading your Oracle WebCenter Content environment from 11g to 12c before the December Premier Support deadline, contact us at Inspired ECM to let our experienced consultants get your environment running efficiently and successfully today.