The tcImportOperationsIntf interface API being used to import the Event Handler in MDS OIM repository.
Pre-Requisite:
Initial Setup.
Please follow the link and setup the OIM client environment to use to create the OIM Objects.Client Code Setup
tcImportOperationsIntf API Usage:
1. Import the Event Handler in the OIM Reposiory.
Tasks Needs to be Performed:
1. Create the OIMClient Handle
OIMClient client= new OIMClient();
client.login(username,password.toCharArray());
2. Get PlatformService and PlatformUtilsService service object
tcImportOperationsIntf importOperationsIntf = client.getService(tcImportOperationsIntf.class);3. Create the EventHandler.xml file
<?xml version = '1.0' encoding = 'UTF-8'?>
<xl-ddm-data version="2.0.1.0" user="XELSYSADM" database="jdbc:oracle:thin:@localhost:1521/oim" exported-date="1397256851696" description="EventHandler.xml">
<eventhandlers repo-type="MDS" name="/metadata/" mds-path="/metadata/" mds-file="EventHandlers.xml">
<completeXml>
<eventhandlers>
<eventhandlers xmlns="http://www.oracle.com/schema/oim/platform/kernel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/schema/oim/platform/kernel orchestration-handlers.xsd">
<action-handler class="test.eventhandlers.NamePreProcessEventHandlers" entity-type="User" operation="CREATE" name="NamePreProcessEventHandlers" stage="preprocess" order="FIRST" sync="TRUE"/>
<action-handler class="test.eventhandlers.NamePreProcessEventHandlers" entity-type="User" operation="MODIFY" name="NamePreProcessEventHandlers" stage="preprocess" order="LAST" sync="TRUE"/>
</eventhandlers>
</eventhandlers>
</completeXml>
</eventhandlers>
</xl-ddm-data>
In the above xml you can replace the following parameters according to your naming convention. They are
1. name="/metadata/". For example you want to store event handler in the metadata/EventHandler.xml in the MDS repository. You should specify the name="/metadata/".
2. mds-path="/metadata/". For example you want to store event handler in the metadata/EventHandler.xml in the MDS repository. You should specify the mds-path="/metadata/".
3. class="test.eventhandlers.NamePreProcessEventHandlers". Replace with your class name.
4. name="NamePreProcessEventHandlers". Replace with your name. Class Name and Name should be the same.
4. Read the EventHander.xml file Content
String filename="/tmp/EventHandler.xml";
StringBuffer sb= new StringBuffer();
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
String readLine=null;
while((readLine =br.readLine()) != null)
{
sb.append(readLine+"\n");
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
if(br != null)
{
try {
br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
4. Import the EventHander.xml file into MDS repo.
String operation=" - Import Event Handler - ";
String category="eventhandlers";
try
{
importOperationsIntf.acquireLock(true);
if(importOperationsIntf.isLockAcquired())
{
List<RootObject> importObjects= new ArrayList<RootObject>();
System.out.println(operation + "Import File Name - "+filename);
Collection<RootObject> importFiles=importOperationsIntf.addXMLFile(filename, sb.toString());
for (RootObject rootObject : importFiles)
{
if(rootObject.isNewObject())
{
importObjects.add(rootObject);
}
else if(rootObject.isImportable())
{
importObjects.add(rootObject);
}
else if(rootObject.isSharedObject())
{
importObjects.add(rootObject);
}
else
{
System.out.println(operation + category + " - Not Importing Objects "+rootObject.getName());;
}
}
Collection<RootObject> missingDepndencies= importOperationsIntf.getMissingDependencies(importFiles, category);
if(missingDepndencies != null && !missingDepndencies.isEmpty())
{
System.out.println(operation + category + " - Missing Dependencies "+missingDepndencies);
throw new RuntimeException("The "+category + " - "+missingDepndencies + " Dependencies missing.");
}
HashMap messages=importOperationsIntf.getImportMessages(importObjects);
for(Object obj:messages.keySet())
{
System.out.println(operation + "Import Task Messages "+messages.get(obj));
}
if(!importObjects.isEmpty())
{
System.out.println(operation + "Import "+filename + " is going to Start");
importOperationsIntf.performImport(importObjects);
System.out.println(operation + " Import "+filename + " is Successfully completed");
}
}
else
{
System.out.println(operation + "Lock Not Acquired");
throw new OIMDeploymentException("Lock Not Acquired");
}
} catch (tcAPIException e)
{
System.out.println(operation +e);
throw new OIMDeploymentException(e);
} catch (DDMException e) {
System.out.println(operation +e);
throw new OIMDeploymentException(e);
} catch (TransformationException e) {
System.out.println(operation +e);
throw new OIMDeploymentException(e);
}
catch (NamingException e)
{
System.out.println(operation +e);
throw new OIMDeploymentException(e);
} catch (tcBulkException e)
{
System.out.println(operation +e);
throw new OIMDeploymentException(e);
} catch (SQLException e) {
System.out.println(operation +e);
throw new OIMDeploymentException(e);
}
No comments:
Post a Comment