How to create custom component in Webcenter Content (UCM)

Requirement – How to Create a UCM custom component

Solutions- Please follow the below steps –

Starting the componentWizard – CD to the path where the component wizard is.
[[email protected] ~]$ cd /oracle/Middleware/user_projects/domains/ucm_domain/ucm/cs/bin // this path will of your weblogic domain
[[email protected] bin]$ ./ComponentWizard

1. Goto Options -> Add
You get the below window.
Fill in the component Name. Click OK.

111

You get below screen.
Custom component gets created here (path may be different for you)
/oracle/ecm/ucm_domain/ucm/cs/custom
The component is created and you can add resources by clicking Add.

222

1. Select service. Click next.

333

Fill in the Name of the Service, Service class, Template. Fill in access levels.
Add actions by clicking on Add.

444

5555

Click OK. Click Finish.

Similarly Add a Resource.

666

image

Resources created
demo_component_resource.htm
demo_component_service.htm
demo_component.hda

Modify the resource.htm as below. Give the Service name, handler name and search order.
The handler name is the fully qualified name of the java file where the service method (printTheName()) is created.

Place the compiled java class file in the classes folder inside the custom component.
cs/custom/demo_component/classes/de/xyz/ucm/service

7777

8888

9999

Build the component to create the manifest.hda file. Demo_component.zip is created that can now be installed on other UCM and used.
Build by clicking on Build.

10000

1212212121212

Enable the component.

1313131313

Hit the browser with the service Name and required parameters
http://192.168.0.118:16200/cs/idcplg?IdcService=PRINT_THE_NAME&IsJava=1&dDocName=HO051621920
My java code is as below. (Calls a standard UCM service from my custom service)

package de.xyz.ucm.service;

import java.io.File;
import java.io.IOException;
import intradoc.common.ExecutionContext;
import intradoc.common.LocaleUtils;
import intradoc.common.Log;
import intradoc.common.ServiceException;
import intradoc.common.SystemUtils;
import intradoc.data.DataBinder;
import intradoc.data.DataException;
import intradoc.data.DataResultSet;
import intradoc.data.ResultSet;
import intradoc.data.Workspace;
import intradoc.provider.Provider;
import intradoc.provider.Providers;
import intradoc.server.Service;
import intradoc.server.ServiceData;
import intradoc.server.ServiceHandler;
import intradoc.server.ServiceManager;
import intradoc.server.UserStorage;
import intradoc.shared.SharedObjects;
import intradoc.shared.UserData;

public class PrintingNames extends ServiceHandler{
	public void printTheName() throws DataException, ServiceException
	{
		
	Log.info("Start printing name"+ true);
	String Docname = m_binder.getLocal("dDocName");
	String serviceName = "DOC_INFO_BY_NAME";
    String userName = m_binder.getLocal("dUser");
    Log.info("environment "+m_binder.getEnvironment());
    Log.info("shared obj val"+SharedObjects.getEnvironmentValue("IntradocServerPort"));
	DataBinder requestBinder = new DataBinder();
	requestBinder.putLocal("dDocName", Docname);
	requestBinder.putLocal("IdcService", serviceName);
	
	
	executeService(requestBinder,"sysadmin",false);	
    final ResultSet docinforesultset = requestBinder.getResultSet("DOC_INFO");
    DataResultSet docinfodataresultset = (DataResultSet)requestBinder.getResultSet("DOC_INFO");

 
	DataResultSet result = new DataResultSet();
	result.copy(docinforesultset);
	
	m_binder.putLocal("Message", "Name printed");
	m_binder.addResultSet("demo_resultset1", docinforesultset);
	m_binder.addResultSet("demo_resultset2", docinfodataresultset);
	Log.info("Finished printing name");

	}
	
	public void executeService(DataBinder binder, String userName, boolean suppressServiceError)
	        throws DataException, ServiceException
	    {       
	        ServiceException error;
	        Workspace workspace = getSystemWorkspace();
	        String cmd = binder.getLocal("IdcService");
	        if(cmd == null)
	            throw new DataException("!csIdcServiceMissing");
	        ServiceData serviceData = ServiceManager.getFullService(cmd);
	        if(serviceData == null)
	            throw new DataException(LocaleUtils.encodeMessage("!csNoServiceDefined", null, cmd));
	        Service service = ServiceManager.createService(serviceData.m_classID, workspace, null, binder, serviceData);
	        UserData fullUserData = getFullUserData(userName, service, workspace);
	        service.setUserData(fullUserData);
	        binder.m_environment.put("REMOTE_USER", userName);
	        error = null;
	        try
	        {
	            service.setSendFlags(true, true);
	            service.initDelegatedObjects();
	            service.globalSecurityCheck();
	            service.preActions();
	            service.doActions();
	            service.postActions();
	            service.updateSubjectInformation(true);
	            service.updateTopicInformation(binder);
	      
	        }
	        catch(ServiceException e)
	        {
	            error = e;
	        }
	        finally{
	        service.cleanUp(true);
	        workspace.releaseConnection();
	        }
	        if(error != null)
	            if(suppressServiceError)
	            {
	                error.printStackTrace();
	                if(binder.getLocal("StatusCode") == null)
	                {
	                    binder.putLocal("StatusCode", String.valueOf(error.m_errorCode));
	                    binder.putLocal("StatusMessage", error.getMessage());
	                }
	            } else
	            {
	                throw new ServiceException(error.m_errorCode, error.getMessage());
	            }
	        return;
	    }
	
	public UserData getFullUserData(String userName, ExecutionContext cxt, Workspace ws)
	        throws DataException, ServiceException
	    {
	        if(ws == null)
	            ws = getSystemWorkspace();
	        UserData userData = UserStorage.retrieveUserDatabaseProfileDataFull(userName, ws, null, cxt, true, true);
	        ws.releaseConnection();
	        return userData;
	    }
	
	public static Workspace getSystemWorkspace()
    {
        Workspace workspace = null;
        Provider wsProvider = Providers.getProvider("SystemDatabase");
        if (wsProvider != null)
        {
            workspace = (Workspace) wsProvider.getProvider();
        }
        return workspace;
    }
}

Happy coding with Vinay Kumar in Techartifact…..

Get intradoc Server port in custom component in Webcenter Content (UCM)

Requirement – How to get intradoc server port in custom component in Webcenter Content.

Solution – We can use one class called sharedObject which give us environment value.One of my friend(Jonathan) helped me in this.

use SharedObjects.getEnvironmentValue(“IntradocServerPort”) will give you intraDocServer port.

SharedObjects.getEnvironmentValue("IntradocServerPort");

Read more on http://jonathanhult.com/intradoc-api/intradoc/shared/SharedObjects.html

Quick tip in end of weekend
Happy coding with Vinay Kumar in Techartifact.

Full text search using RIDC API in webcenter Content (UCM)

Requirment -I got task to accomplish to Search UCM using RIDC.

Solution– After spending so much time on it.I got solution on some blog.Not recall the blog name.for my reference , i am writing here.

We need to change some confi file which is in specified path –

Oracle/middleware/userprojects/yourdomain/ucm/cs/config/confing.cfg

There will be property name ‘SearchIndexerEngineName’ equal OracleTextSearch i.e

SearchIndexerEngineName=OracleTextSearch

Delete this and add the following one

SearchIndexerEngineName=DATABASE.FULLTEXT

Then by calling the RIDC API it enable Full text Search in UCM.

IdcClientManager manager = new IdcClientManager();
IdcClient idcClient = manager.createClient(“idc://192.167.3.232:4444″);

IdcContext userContext =new IdcContext('username', 'pwd'); 
DataBinder binder = idcClient.createBinder();

binder.putLocal(“IdcService”, “GET_SEARCH_RESULTS”);
binder.putLocal(“QueryText”,“dDocFullText <substring> <qsch>” + “our query” +”</qsch>”);

binder.putLocal(“SearchEngineName”, “databasefulltext”);
binder.putLocal(“ResultCount”, “10″);

ServiceResponse response = idcClient.sendRequest(userContext, binder);
DataBinder serverBinder = response.getResponseAsBinder();
binder = response.getResponseAsBinder();

DataResultSet resultSet =binder.getResultSet(“SearchResults”);
for (DataObject dataObject : resultSet.getRows()) 
{
  System.out.println(“Title is: ” + dataObject.get(“dDocTitle”));
  System.out.println(“Author is: ” + dataObject.get(“dDocAuthor”));
}


Restart the UCM server and try search again.

happy coding with Vinay in techartifact . 🙂