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…..

Handling – ORA-01858: a non-numeric character was found where a numeric was expected

Requirement – Executing an sql query and found very weird error.ORA-01858: a non-numeric character was found where a numeric was expected.

Solutions –

the query i am executing

Select Count(*) As Amount, To_Char(Dactiondate, 'YYYY-MM') "month" From Docmeta,Revisions,Workflowhistory,
(Select Ddocname As Docname,Max(Drevisionid) As Revisionid From Revisions Group By Ddocname) A Where  Revisions.Ddocname=A.Docname
And Revisions.Drevisionid=A.Revisionid And  Revisions.Did=Docmeta.Did
And  Workflowhistory.Ddocname=Revisions.Ddocname And Daction='Approve' And ((  Dwfname='InternalBUReviewProcess'
And Trunc(Dactiondate)<Trunc(To_Date(Substr(Substr(Xreviewerdeadline,Instr(Xreviewerdeadline,Dwfstepname,1,1),Instr(Xreviewerdeadline || ',',',',Instr(Xreviewerdeadline,Dwfstepname,1,1),1)), Instr(Substr(Xreviewerdeadline,Instr(Xreviewerdeadline,Dwfstepname,1,1),Instr(Xreviewerdeadline || ',',',',Instr(Xreviewerdeadline,Dwfstepname,1,1),1)),Duser,1,1)+(Length(Duser)) + 2, 8),'MM-DD-YY') ))
AND UPPER(xIsRushRelease) = UPPER('true')
And  Dactiondate Between To_Date ('2013-06' , 'YYYY-MM') And Last_Day(To_Date ( '2013-08 23:59:59' ,'YYYY-MM hh24:mi:ss'))
 
Group By To_Char(Dactiondate, 'YYYY-MM') Order By To_Char(Dactiondate, 'YYYY-MM')

It is working fine when, i am executing in toad.but when i am adding another clause i.e UPPER(xIsRushRelease) = UPPER(‘true’), it start giving this error.Big problem,not able to understand what went wrong.
This sql query is very big.

ORA-01858 occurs in string-to-DATE conversions, when the string being converted doesn’t match the format string. You can expect errors like that whenever you store date information in string columns.

I thought of creating an sql function and checking , where it getting wrong.

i created a function like –

create or replace function getDateNew (DUSER IN varchar2,Dwfstepname IN varchar2,Xreviewerdeadline IN varchar2)
return date is

  l_sysdate date;

begin

 select cast(To_Date(Substr(Substr(Xreviewerdeadline,Instr(Xreviewerdeadline,Dwfstepname,1,1),
Instr(Xreviewerdeadline || ',',',',Instr(Xreviewerdeadline,Dwfstepname,1,1),1)), 
Instr(Substr(Xreviewerdeadline,Instr(Xreviewerdeadline,Dwfstepname,1,1),
Instr(Xreviewerdeadline || ',',',',Instr(Xreviewerdeadline,Dwfstepname,1,1),1)),Duser,1,1)+(Length(Duser)) + 2, 8),'MM-DD-YY')as date) Into L_Sysdate
From Dual;
   Return L_Sysdate;

End;

Ok, now i am using function in my query like

Select Duser,Xreviewerdeadline,Dactiondate,Docmeta.Did,Xbu,Xoccasionevent,Getdatenew(Duser,Dwfstepname,Xreviewerdeadline) as deadline, Trunc(Dactiondate) As Dactiondate From Docmeta,Revisions,
Workflowhistory, 
(Select Ddocname As Docname,Max(Drevisionid) As Revisionid From Revisions Group By Ddocname) A Where  
 Revisions.Ddocname=A.Docname And Revisions.Drevisionid=A.Revisionid And  Revisions.Did=Docmeta.Did 
AND Daction='Approve' And Workflowhistory.Ddocname=Revisions.Ddocname 
And   Dwfname='InternalBUReviewProcess' 
And Trunc(Dactiondate)<Trunc(Getdatenew(Duser,Dwfstepname,Xreviewerdeadline)) 

Its working fine.But when i added another clause , it again giving me same error.I am totally frustrated.Then , i try to handle the exception in my function.There is some exception coming, when i am adding another clause i.e Xbu=Upper(‘H IM SY’)

I need to handle the exception in my function.Finally adding exception part in my query like

create or replace function getDateNew (DUSER IN varchar2,Dwfstepname IN varchar2,Xreviewerdeadline IN varchar2)
return date is

  l_sysdate date;

begin

 select cast(To_Date(Substr(Substr(Xreviewerdeadline,Instr(Xreviewerdeadline,Dwfstepname,1,1),
Instr(Xreviewerdeadline || ',',',',Instr(Xreviewerdeadline,Dwfstepname,1,1),1)), 
Instr(Substr(Xreviewerdeadline,Instr(Xreviewerdeadline,Dwfstepname,1,1),
Instr(Xreviewerdeadline || ',',',',Instr(Xreviewerdeadline,Dwfstepname,1,1),1)),Duser,1,1)+(Length(Duser)) + 2, 8),'MM-DD-YY')as date) Into L_Sysdate
From Dual;
 DBMS_OUTPUT.PUT_LINE(L_Sysdate);
  Return L_Sysdate;
    DBMS_OUTPUT.PUT_LINE(L_Sysdate);
  Exception 
  when others then return null;

End;

After handling exception, it working fine.I handled exception.

Happy coding with Vinay kumar in Techartifact….

Handling OK and Cancel button in af:dialog using popup in Oracle ADF by dialogListener

Requirement – We are displaying a popup message to user and on selecting on OK and CANCEl by user , writing custom code inside bean

Solution – You can have af:popup component in the page .Inside the popup , drag drop af:dialog component. You can call the pop up programmatic using my
another post of popup

For the dialog , you need to have some dialog listener. write it like

<af:dialog title="handling Ok and cancel event}"
           type="okCancel"
           dialogListener="#{techartifact.headerManage.dialogListener1}"
           id="d1">

The method of dialogListener1 can be written as below.Write inside a headerManage bean.

public void dialogListener1(DialogEvent dialogEvent)
  {
    if (dialogEvent.getOutcome() == DialogEvent.Outcome.ok)
    {
     // write your custom code for ok event
    } else
    {
      // write your custom code for cancel event
   } 
  }

Happy coding with techartifact….