Event handler are nothing but Piece of java code which perform certain task on particular event.In this lab we are going to see the pre process event handler which will take the second and third letter of first name and put it in Middle Name if it is empty.Please see the steps for the same here.
Note: Here we are going to deploy the code using oim custom installer for Jdeveloper. For steps please see the link "http://www.iamidm.com/2013/02/oim-11g-r2-customization-extension.html". Also it is assume that you know the folder structure and how to deploy the code using jdeveloper. For creating folder structure please go to "http://www.iamidm.com/2015/09/folder-structure-after-installing-oim.html
1) Create the java project in jdeveloper and add the following jar as shown in figure.
2) Copy and paste the below code.
package client;
import oracle.iam.platform.context.ContextAware;
import oracle.iam.platform.kernel.vo.AbstractGenericOrchestration;
import oracle.iam.platform.kernel.vo.BulkEventResult;
import oracle.iam.platform.kernel.vo.BulkOrchestration;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import oracle.iam.platform.kernel.vo.EventResult;
import oracle.iam.platform.kernel.vo.Orchestration;
public class MiddleName implements oracle.iam.platform.kernel.spi.PreProcessHandler{
public boolean cancel(long l, long l1, AbstractGenericOrchestration abstractgenericorchestration) {
// TODO Auto-generated method stub
return false;
}
public void compensate(long l, long l1, AbstractGenericOrchestration abstractgenericorchestration) {
// TODO Auto-generated method stub
}
public EventResult execute(long processID, long eventID, Orchestration orchestration) {
// TODO Auto-generated method stub
HashMap<String, Serializable> parameters = orchestration.getParameters();
Set<String> keyset=parameters.keySet();
Iterator<String> itr=keyset.iterator();
while(itr.hasNext()){
String attrName=itr.next();
}
String middleName = getParamaterValue(parameters, "Middle Name");
if (middleName==null||middleName.isEmpty()) {
String firstName = getParamaterValue(parameters, "First Name");
middleName = firstName.substring(1,3);
orchestration.addParameter("Middle Name", middleName);
}
return new EventResult();
}
public BulkEventResult execute(long l, long l1, BulkOrchestration bulkorchestration) {
// TODO Auto-generated method stub
return null;
}
private String getParamaterValue(HashMap<String, Serializable> parameters,
String key) {
String value = (parameters.get(key) instanceof ContextAware)
? (String) ((ContextAware) parameters.get(key)).getObjectValue()
: (String) parameters.get(key);
return value;
}
public void initialize(HashMap<String, String> arg0) {
// TODO Auto-generated method stub
}
}
3) Create the "plugin.xml" with content as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<oimplugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/schema/oim/plugin plugin.xsd">
<plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
<plugin pluginclass="client.MiddleName" version="1.0" name="SamplePreprocessExtension">
</plugin>
</plugins>
</oimplugins>
4) Create "metadata.xml" with content as shown below
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- Custom preprocess event handlers -->
<action-handler
class="client.MiddleName" entity-type="User" operation="CREATE" name="SamplePreprocessExtension" stage="preprocess" order="1000" sync="TRUE"/>
</eventhandlers>
5) Paste the plugin.xml & metadata.xml file inside config folder.
6) Deploy the project. Create user and test the output.Leave the Middle Name empty and create the user. Once the user get created check the middle name.
Note: Here we are going to deploy the code using oim custom installer for Jdeveloper. For steps please see the link "http://www.iamidm.com/2013/02/oim-11g-r2-customization-extension.html". Also it is assume that you know the folder structure and how to deploy the code using jdeveloper. For creating folder structure please go to "http://www.iamidm.com/2015/09/folder-structure-after-installing-oim.html
1) Create the java project in jdeveloper and add the following jar as shown in figure.
2) Copy and paste the below code.
package client;
import oracle.iam.platform.context.ContextAware;
import oracle.iam.platform.kernel.vo.AbstractGenericOrchestration;
import oracle.iam.platform.kernel.vo.BulkEventResult;
import oracle.iam.platform.kernel.vo.BulkOrchestration;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import oracle.iam.platform.kernel.vo.EventResult;
import oracle.iam.platform.kernel.vo.Orchestration;
public class MiddleName implements oracle.iam.platform.kernel.spi.PreProcessHandler{
public boolean cancel(long l, long l1, AbstractGenericOrchestration abstractgenericorchestration) {
// TODO Auto-generated method stub
return false;
}
public void compensate(long l, long l1, AbstractGenericOrchestration abstractgenericorchestration) {
// TODO Auto-generated method stub
}
public EventResult execute(long processID, long eventID, Orchestration orchestration) {
// TODO Auto-generated method stub
HashMap<String, Serializable> parameters = orchestration.getParameters();
Set<String> keyset=parameters.keySet();
Iterator<String> itr=keyset.iterator();
while(itr.hasNext()){
String attrName=itr.next();
}
String middleName = getParamaterValue(parameters, "Middle Name");
if (middleName==null||middleName.isEmpty()) {
String firstName = getParamaterValue(parameters, "First Name");
middleName = firstName.substring(1,3);
orchestration.addParameter("Middle Name", middleName);
}
return new EventResult();
}
public BulkEventResult execute(long l, long l1, BulkOrchestration bulkorchestration) {
// TODO Auto-generated method stub
return null;
}
private String getParamaterValue(HashMap<String, Serializable> parameters,
String key) {
String value = (parameters.get(key) instanceof ContextAware)
? (String) ((ContextAware) parameters.get(key)).getObjectValue()
: (String) parameters.get(key);
return value;
}
public void initialize(HashMap<String, String> arg0) {
// TODO Auto-generated method stub
}
}
3) Create the "plugin.xml" with content as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<oimplugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/schema/oim/plugin plugin.xsd">
<plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
<plugin pluginclass="client.MiddleName" version="1.0" name="SamplePreprocessExtension">
</plugin>
</plugins>
</oimplugins>
4) Create "metadata.xml" with content as shown below
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- Custom preprocess event handlers -->
<action-handler
class="client.MiddleName" entity-type="User" operation="CREATE" name="SamplePreprocessExtension" stage="preprocess" order="1000" sync="TRUE"/>
</eventhandlers>
5) Paste the plugin.xml & metadata.xml file inside config folder.
6) Deploy the project. Create user and test the output.Leave the Middle Name empty and create the user. Once the user get created check the middle name.
No comments:
Post a Comment