Sunday, December 11, 2011

Oracle UCM Java Filters

Filters are a way to add your own custom logic or java code to the content server to get the required behaviour.
As Bex explained in his book, Filters trigger the execution of custom code when specific events occur in content server, ex : validateStandard occurs during check-in .

In the following example i would use the very simple java filter, which generates the ContentID with a custom prefix [based on the ContentType value chosen during Check-in]. and we want to insert that logic during content check-in.

Steps to follow:
1. I would first create a custom component in ComponentWizard and name it AlterPrefix.
2. Write the logic to add a prefix the ContentID sequence with the content type.[use the idcserver.jar* file to properly compile and execute the java file ]
3. place the compiled '.class' file under 'classes' folder under custom component [AlterPrefix] Directory.
4. add the java class name and the filter where you want to execute your code.

1. Create a component in CompWizard as AlterPrefix.
2. Write the java code : [i used Eclipse IDE]


  2.a  Add the jar file idcserver.jar to the project
3. place the .class file under 'classes' folder
4. add the filter name to the component's glue file under 'Filters' result set section. filter name = 'preComputeDocName'




 enable the custom component in the UCM and restart the server.


Now Once you check-in a content in UCM , the above event is triggered during check-in and it looks into the component .hda file which has the filter preComputeDocName and also for the Location of the custom code to be executed - which is mentioned as - - alterprefix.CustomFilter.
eventually , following the java code , it takes the content type and prefixes as shown below

I check-in a content choosing the type as utilities:


 and the custom java filter add the prefix as shown below :





Hope this made a clear and simple example about adding a custom java code to content server using Filters.
personally , i feel that it takes equal effort to find and decide the right filter for the job as with the logic , depending on the requirement.

* You can find the idcserver.jar file at "Oracle\<Middleware>\Oracle_ECM1\ucm\idc\jlib" under your ucm installation directories