Tuesday 20 November 2012

How to remove unused files/artifacts from MDS?

In development phase of project, we will be adding different artifacts to the MDS so that can be accessed by different processes. In course of development /design changes, applying best practices, there is bound to be lot of unused folders /artifacts lying around in the MDS store. So it is always advised to remove the unwanted artifacts, test the processes before we export them to other environments. I always used a workaround to remove the files, even though it was not the best approach.

Workaround
 There is a table called MDS_PATHS where there would be entries corresponding to each artifact. I used to delete the entries from the table and the artifacts never used to show up, even though there will be entries in other related tables.

BestApproach
The best approach/solution is to use WLST command for cleaning up the MDS store. There is a function called deleteMetadata in WLST which will do the job for you.
This is how Oracle documentation describes the command. It deletes the selected documents from the application repository. When this command is run against repositories that support versioning, that is a database-based repository, delete is logical and marks the tip version (the latest version) of the selected documents as "deleted" in the MDS repository partition.

For more attributes and options available with the command refer this doc

The WLST script is located at:

(UNIX) MIDDLEWARE_HOME/ORACLE_SOA1/common/bin/wlst.sh
(Windows) MIDDLEWARE_HOME\Oracle_SOA1\common\bin\wlst.cmd

Once the scripting tool is initialized, Connect to the server

offline>connect(‘username,’pwd’, ‘hostname:7001’)

For running deleteMetada function you need a minimum of 3 inputs
-          application  - since we are deleting from shared artifacts of soa-infra, the value should be soa-infra
-          server -  value should be ‘soa_server1’ or the server u use for SOA other than admin server.
-          docs – the folder path or artifact which you want to delete.

wls:/GEO_domain/serverConfig> deleteMetadata(application='soa-infra',server='soa
_server1',docs='/apps/dvm/oracle/dvm/*')

Executing operation: deleteMetadata.

Operation "deleteMetadata" completed. Summary of "deleteMetadata" operation is:

List of documents successfully deleted:
/apps/dvm/oracle/dvm/GeoXRef.dvm

1 documents successfully deleted.

No comments:

Post a Comment

xslt padding with characters call template for left pad and right pad

  Could a call-template be written that took two parameters ?   a string, and a   number) return the string with empty spaces appended t...