Wednesday, June 5, 2013

Java Code: PrePopulate Adapter to populater User ID from OIM form

Prepopulate Adapter: Pre-populate Adapater to populate User ID from OIM form using Java:


Create Jar with below code and place it in lib folder:



Zip lib folder and plugin.xml:



Prepop Code:




Plugin.xml

3 comments:

  1. Your code throws an error:

    Incompatible types: required: oracle.iam.request.vo.Beneficiary; found: java.lang.Object.

    This is for the line:

    for (Beneficiary benf : benList) {

    Where "benf" is red/underlined, I'm not sure what the issue is at the moment.

    ReplyDelete
  2. Check if you got all the supported Jar files.

    ReplyDelete
  3. Here's the code I have (basically copy / paste from this post). I have all import statements "working" / added and the error seems to be around the oracle.iam.request.vo.Beneficiary import which seems to be imported correctly just like the others. I've added the oimclient.jar which contains all the classes needed correct?

    ==================================

    package com.custom.prepop.plugins;

    import java.io.Serializable;

    import java.util.HashSet;

    import java.util.List;

    import java.util.logging.Logger;

    import oracle.iam.identity.usermgmt.api.UserManager;

    import oracle.iam.identity.usermgmt.api.UserManagerConstants;

    import oracle.iam.identity.usermgmt.vo.User;

    import oracle.iam.platform.Platform;

    import oracle.iam.request.exception.RequestServiceException;

    import oracle.iam.request.vo.Beneficiary;

    import oracle.iam.request.vo.RequestData;

    public class PrePopulateFields implements oracle.iam.request.plugins.PrePopulationAdapter {



    public Serializable prepopulate(RequestData requestData)

    {

    System.out.println("Inside Prepopulate Adapter.. ");

    System.out.println("Request Data: " + requestData);

    String prePopUserId = null;

    List benList = requestData.getBeneficiaries();

    UserManager usersvc;

    if (benList.size() == 1) {

    usersvc = (UserManager)Platform.getService(UserManager.class);

    for (Beneficiary benf : benList) {

    HashSet searchAttrs = new HashSet();

    searchAttrs.add(UserManagerConstants.AttributeName.USER_LOGIN.getId());

    try {

    User userBenef = usersvc.getDetails(benf.getBeneficiaryKey(), searchAttrs, false);

    if (userBenef != null)

    prePopUserId = userBenef.getLogin();

    }

    catch (Exception e) {

    e.printStackTrace();

    }

    }

    }

    return prePopUserId;

    }

    }

    ReplyDelete

Other Posts