This describes the usage of a validation handler used in validating the data entered as part of creating a request. This validation handler will be attached to the request dataset and which inturn will be invoked by OIM.
public class DataSetValidator implements oracle.iam.request.plugins.RequestDataValidator{
public void validate(RequestData requestdata) throws InvalidRequestDataException {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
System.out.println("Entering the Data Validation Handler");
List<Beneficiary> beneficiaries = null;
List<RequestBeneficiaryEntity> benEntities = null;
List<RequestBeneficiaryEntityAttribute> benAttrs = null;
beneficiaries = requestdata.getBeneficiaries();
if (beneficiaries != null && !beneficiaries.isEmpty()){
for (Beneficiary beneficiary : beneficiaries){
benEntities = beneficiary.getTargetEntities();
if (benEntities != null && benEntities.size() > 0){
for (RequestBeneficiaryEntity benEntity : benEntities) {
System.out.println("Inside the For loop");
benAttrs = benEntity.getEntityData();
if (benAttrs != null && benAttrs.size() > 0){
System.out.println("Inside If");
for (RequestBeneficiaryEntityAttribute benAttr : benAttrs){
System.out.println("Inside the attributes For loop");
System.out.println("Attribute Name is: "+benAttr.getName());
System.out.println("Attribute Name is: "+benAttr.getValue());
if(benAttr.hasChild()){
List <RequestBeneficiaryEntityAttribute> list = benAttr.getChildAttributes();
Iterator iterator = list.iterator();
while(iterator.hasNext()){
RequestBeneficiaryEntityAttribute attribute =(RequestBeneficiaryEntityAttribute)iterator.next();
System.out.println("GenericRequestValidator.validate() Name "+attribute.getName());
System.out.println("GenericRequestValidator.validate()) Value "+attribute.getValue());
}
}
}
}
}
}
}
}else{
System.out.println("RequestData is null");
}
}
After this we will have to package it and register this as a plugin in OIM. Later we will have to modify the request dataset xml as follows:
<DataSetValidator name="SampleValidator" classname="com.test.ad.DataSetValidator"/>
Note: We will have to export the dataset from the MDS and then modify it and then import the xml back. To export the dataset follow the steps below:
First, export the document by modifying the following values in
the weblogic.properties file and running the
weblogicExportMetadata.sh/weblogicExportMetadata.bat file:
wls_servername=oim server name, for example oim_server1
application_name=oim
metadata_to_loc=/scratch/data
metadata_files=/metadata/user/custom/EventHandlers.xml
The document will be exported to the /scratch/data/metadata/user/custom folder.
Under /scratch/data, if the folder structure /metadata/user/custom does not exist,
MDS will create it.
Importing into MDS:
To import the file into MDS, modify the following values in the
weblogic.properties file and run the
weblogicImportMetadata.sh/weblogicImportMetadata.bat file:
wls_servername=oim server name, for example oim_server1
application_name=oim
metadata_from_loc=/scratch/data
The above tag will be added as a child element under the request-data-set. So there will be only one dataset validator for one request dataset. Its a one to one.
public class DataSetValidator implements oracle.iam.request.plugins.RequestDataValidator{
public void validate(RequestData requestdata) throws InvalidRequestDataException {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
System.out.println("Entering the Data Validation Handler");
List<Beneficiary> beneficiaries = null;
List<RequestBeneficiaryEntity> benEntities = null;
List<RequestBeneficiaryEntityAttribute> benAttrs = null;
beneficiaries = requestdata.getBeneficiaries();
if (beneficiaries != null && !beneficiaries.isEmpty()){
for (Beneficiary beneficiary : beneficiaries){
benEntities = beneficiary.getTargetEntities();
if (benEntities != null && benEntities.size() > 0){
for (RequestBeneficiaryEntity benEntity : benEntities) {
System.out.println("Inside the For loop");
benAttrs = benEntity.getEntityData();
if (benAttrs != null && benAttrs.size() > 0){
System.out.println("Inside If");
for (RequestBeneficiaryEntityAttribute benAttr : benAttrs){
System.out.println("Inside the attributes For loop");
System.out.println("Attribute Name is: "+benAttr.getName());
System.out.println("Attribute Name is: "+benAttr.getValue());
if(benAttr.hasChild()){
List <RequestBeneficiaryEntityAttribute> list = benAttr.getChildAttributes();
Iterator iterator = list.iterator();
while(iterator.hasNext()){
RequestBeneficiaryEntityAttribute attribute =(RequestBeneficiaryEntityAttribute)iterator.next();
System.out.println("GenericRequestValidator.validate() Name "+attribute.getName());
System.out.println("GenericRequestValidator.validate()) Value "+attribute.getValue());
}
}
}
}
}
}
}
}else{
System.out.println("RequestData is null");
}
}
After this we will have to package it and register this as a plugin in OIM. Later we will have to modify the request dataset xml as follows:
<DataSetValidator name="SampleValidator" classname="com.test.ad.DataSetValidator"/>
Note: We will have to export the dataset from the MDS and then modify it and then import the xml back. To export the dataset follow the steps below:
First, export the document by modifying the following values in
the weblogic.properties file and running the
weblogicExportMetadata.sh/weblogicExportMetadata.bat file:
wls_servername=oim server name, for example oim_server1
application_name=oim
metadata_to_loc=/scratch/data
metadata_files=/metadata/user/custom/EventHandlers.xml
The document will be exported to the /scratch/data/metadata/user/custom folder.
Under /scratch/data, if the folder structure /metadata/user/custom does not exist,
MDS will create it.
Importing into MDS:
To import the file into MDS, modify the following values in the
weblogic.properties file and run the
weblogicImportMetadata.sh/weblogicImportMetadata.bat file:
wls_servername=oim server name, for example oim_server1
application_name=oim
metadata_from_loc=/scratch/data
The above tag will be added as a child element under the request-data-set. So there will be only one dataset validator for one request dataset. Its a one to one.
Fot the plugin.xml use the following plugin point:
ReplyDelete