An alternative strategy to cleaning assets from Oracle Content Management.

An alternative strategy to cleaning assets from Oracle Content Management.

I'm adding a quick snippets (gist) as an alternative way to target & loop through and delete OCM assets. I recently had an issue where the OCM batch jobs using the OCM toolkit were just running too slow or were being unresponsive.. So I quickly pulled together this rough and dirty code to let me monitor and delete  assets in batches of 50.

You shouldn't have this problem if you are using OCM Toolkit to target content to clean-up like this..

cec delete-assets -s <serverName> -r <repositoryName> -q '(type eq \"Image\" and createdDate gt \"2022-09-01\")'
💡
... But for me I was having issues - it was unfortunately just taking hrs and nothing appeared to be clearing up - so here is the code I used to quickly loop through and remove 50 items at a time to delete about 80,000 assets...

.Env

Create an .env file or replace the variables to match your environment

OCM_TOKEN=eyJ4NXQjUz...
OCM_URL=https://<ocminstance>.cec.ocp.oraclecloud.com
repo=F0283....

Gist

Scroll to the bottom of the gist and you will see a method called deleteAssets enter the asset type you would like to remove and how many at a time I kept it at 50 and set the type as Image as  50 is the max OCM asset display you could use to delete if you did this through the browser UI..


Hope it helps!

And again this was just rough code to cleanup and monitor the deletion of assets from the terminal..