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
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
Hello,
ReplyDeletePls. do mention some samples on Oracle UCM Java Filters ... as it is very urgent
We want to filter file of exe,dll etc using custom Component. Please guide help
ReplyDeleteHi,
DeleteI have a similar situation. Did you find any solution for this?
Thanks
Tanuj
Hey Pradeep,
ReplyDeleteWe have a requirement to display UCM documents in another application i.e. we have a meta data mapping between the applications. So whenever there is any update to any of the meta data fields in UCM it should be updated simultaneously.
We are planning to use filters in a component during different life cycle events like (Checkin, Update, Delete etc.) which can invoke external web services.
Can you please guide us in how these events can be retrieved using filters.
Regards,
Sajeev
Good Explaination...
ReplyDeleteHi Pradeep,
ReplyDeleteCan you share how i will call checkin service in javacode.
Regards,
VK parmar
Very well written and I find it very easy to test.
ReplyDeleteThank You!