Thursday, November 24, 2011

Oracle SOA Suite – Purging the Xref Data through JAVA API.

Oracle SOA Suite  – Purging the Xref Data through JAVA API.

The Oracle SOA Suite 11g and Oracle SOA Suite 12cprovides the Java API’s that can be used to purge the Xref Data.

The client API provides the Locator class to purge the Xref Data based on the filter.

locator.purgeXRefData(XRefPurgeFilter purgeFilter);

The XRefPurgeFilter class is used to set the filter condition to purge the Xref Data.

XRefPurgeFilter purgeFilter =new XRefPurgeFilter();

purgeFilter.setPurgeXRefTableURI ("oramds:/apps/EAIMetaData/Xref/Test.xref");

Specify the Xref Table for which data needs to be purged. If no column names are provided, all data for that XRef Table would be purged.

purgeFilter.setPurgeXRefTableURI – Can be used only combination with purgeFilter.addColumnToPurge, 

if we are using purgeFilter.setPurgeXRefTableURI with other filter conditions like purgeFilter.setPurgeDataBefore, we would receive the following error.

EJB Exception: ; nested exception is: java.lang.RuntimeException: oracle.tip.xref.exception.RepositoryException: Unable to access Cross Reference Values from Database.The SQL Exception is: "ORA-00933: SQL command not properly ended " Please ensure that the database is accessible. If accessible, please look at the stack trace and fix the issue. If unable to fix contact Oracle Support Fetching Data...

purgeFilter.addColumnToPurge("ColumnA");
Add column names for specified XRef Table whose column data would be purged. 

If we are using purgeFilter.addColumnToPurge with any other filter condition other than purgeFilter.setPurgeXRefTableURI would be ignored.

purgeFilter.setPurgeDataBefore(purgeDataAfter);
Last modified date before which all data in the database would be purged.

purgeFilter.setPurgeAllData(true);
All data in the database would be purged

purgeFilter.setPurgeDataAfter(purgeDataAfter);
Last modified date after which all data in the database would be purged.

The following code snippet will enable you to purge the Xref Data based on the filter condition.

Jar File required - <JDEV_HOME>\soa\modules\oracle.soa.mgmt_11.1.1\soa-infra-mgmt.jar

try
{
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL,"t3://soahost:soaport");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL,"weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS,"xxxxxx");
jndiProps.put("dedicated.connection","true");
Locator locator = LocatorFactory.createLocator(jndiProps);
java.util.Date purgeData=new Date(2011,11,24);

XRefPurgeFilter purgeFilter =new XRefPurgeFilter();
purgeFilter.setPurgeXRefTableURI("oramds:/apps/EAIMetaData/Xref/Test.xref");
// purgeFilter.addColumnToPurge("ColumnA");
//purgeFilter.setPurgeDataBefore(purgeData);
//purgeFilter.setPurgeDataAfter(purgeData);
// purgeFilter.setPurgeAllData(true);
locator.purgeXRefData(purgeFilter);
}catch(Exception e)
{
e.printStackTrace();
}


No comments:

Post a Comment