11 Replies Latest reply: Jan 31, 2013 7:09 AM by 926363 RSS

    beneficiary attributes are not saved in OIM request

    926363
      Hi experts, while submitting OIM request, I am setting beneficiary attributes as :

      beneficiary.setAttributes(map);

      I use oimService.doOperation to submit request and I am getting back request number.

      When I call reqService.getBasicRequestData(reqID) and it is returning Request object with beneficiaries object.

      When traced benericiaries object, I can see the beneficiary but the attributes object is null.

      I am not sure how to retrieve beneficiary attributes from a request. I am not sure whether the beneficiary attributes are saved or not.

      Appreciate your quick help.


      thanks
        • 1. Re: beneficiary attributes are not saved in OIM request
          idamGod
          Use this code to get beneficiary attribute details. Provide us your code that is used to create request so that we will let you know our comments.

          String reqId = "42";
          String resourceName="";

          try
          {
          oracle.iam.request.api.RequestService requestService = oimClient.getService(oracle.iam.request.api.RequestService.class);
          oracle.iam.identity.usermgmt.api.UserManager userService = oimClient.getService(oracle.iam.identity.usermgmt.api.UserManager.class);
          tcLookupOperationsIntf lookupIntf=oimClient.getService(tcLookupOperationsIntf.class);
          oracle.iam.request.vo.Request request = requestService.getBasicRequestData(reqId);
          java.util.List<oracle.iam.request.vo.Beneficiary> beneficiaries = request.getBeneficiaries();
          List<RequestBeneficiaryEntityAttribute> benAttrs = null;
          List<RequestBeneficiaryEntity> benEntities = null;
          User userData;

          if (request != null)
          {
          requesterKey = request.getRequesterKey();
          System.out.println("Reguester Key : "+(requesterKey != null ? requesterKey : ""));
          System.out.println("Beneficiary Type : "+(request.getBeneficiaryType() != null ? request.getBeneficiaryType() : ""));
          System.out.println("Status : "+(request.getRequestStatus() != null ? request.getRequestStatus() : ""));
          beneficiaries = request.getBeneficiaries();
          if (beneficiaries != null && !beneficiaries.isEmpty())
          {   
          for (Beneficiary beneficiary : beneficiaries)
          {
          benEntities = beneficiary.getTargetEntities();

          if (benEntities != null && benEntities.size() > 0)
          {
          System.out.println("BenEntities Size :"+benEntities.size());

          for (RequestBeneficiaryEntity benEntity : benEntities)
          {
          System.out.println("Beneficiary Entities : Entity : Key (Obj Key):"+ benEntity.getEntityKey());
          System.out.println("Beneficiary Entities : Entity : Type:"+benEntity.getEntityType());
          resourceName= benEntity.getEntitySubType();
          System.out.println("Beneficiary Entities : Entity : SubType (Resource Name):"+resourceName);

          benAttrs = benEntity.getEntityData();
          if (benAttrs != null && benAttrs.size() > 0){
          for (RequestBeneficiaryEntityAttribute benAttr : benAttrs){
          if(benAttr.hasChild()){
          List <RequestBeneficiaryEntityAttribute> list = benAttr.getChildAttributes();
          Iterator iterator = list.iterator();
          while(iterator.hasNext()){
          RequestBeneficiaryEntityAttribute attribute =(RequestBeneficiaryEntityAttribute)iterator.next();
          System.out.println(attribute.getName() + " = "+attribute.getValue());
          }
          }
          }
          }
          }
          }
          }
          }
          else
          {
          System.out.println("Beneficiaries : NULL");
          }
          }
          else
          {
          System.out.println("Request '"+reqId+"' is null\n");
          }
          • 2. Re: beneficiary attributes are not saved in OIM request
            Kevin Pinsky
            You can also use this code to view the information in the request and use your basicRequestData with this snippet:


            List<Beneficiary> benes = basicRequestData.getBeneficiaries();
            for (Beneficiary bene: benes){
            long userKey = Long.parseLong(bene.getBeneficiaryKey());
            SearchCriteria criteria = new SearchCriteria(UserManagerConstants.AttributeName.USER_KEY.getId(), userKey, SearchCriteria.Operator.EQUAL);
            List<User> users = null;
            try {
            users = usrManager.search(criteria, userAttrs, null);
            } catch (AccessDeniedException e) {
            } catch (UserSearchException e) {
            }
            User user = users.get(0);

            //Benefificary Entities
            benEntities = bene.getTargetEntities();
            for (RequestBeneficiaryEntity benEntity:benEntities){

            System.out.println("Request ID[" + requestKey + "] Date[" + basicRequestData.getCreationDate() + "] User[" + user.getLogin() + "]" +
            " Resource Key[" + benEntity.getEntityKey() + "] Resource Name[" + benEntity.getEntitySubType() + "] Template Name[" + basicRequestData.getRequestTemplateName() + "]");

            benAttrs = benEntity.getEntityData();
            for (RequestBeneficiaryEntityAttribute benAttr : benAttrs){
            if (benAttr.hasChild()){
            //Child Entries
            List<RequestBeneficiaryEntityAttribute> childAttrs = benAttr.getChildAttributes();
            for (RequestBeneficiaryEntityAttribute childAttr:childAttrs){
            System.out.println("Attribute Name[" + benAttr.getName() + "]Child Attr Name[" + childAttr.getName() + "]" +
            "Child Attr Value Holder[" + childAttr.getValueHolder() + "]Child Attr Type[" + childAttr.getType() + "]");
            }
            }else{
            System.out.println("Attribute Name[" + benAttr.getName() + "]Attribute Value[" + benAttr.getValueHolder() + "]");
            }
            }


            -Kevin
            • 3. Re: beneficiary attributes are not saved in OIM request
              926363
              I am looking for beneficiay attributes not the beneficiary entity attributes. Beneficiary attributes are for requester where as beneficiary entity attributes are for role attributes.

              I want to set some attributes at beneficiary level not at role level ie., not at entity level. That's why I thought I will use beneficiary.setAttributes(map); But looks like these attributes are not stored any where. I looke into tables but did not find any table storing these attributes. But no idea why beneficiary.setAttributes() is provided if OIM is not storing these attributes.

              thanks

              Edited by: 923360 on Jan 30, 2013 7:02 PM

              Edited by: 923360 on Jan 30, 2013 7:05 PM
              • 4. Re: beneficiary attributes are not saved in OIM request
                idamGod
                Try the below code and see if it is giving your details.
                if (request != null)
                {
                beneficiaries = request.getBeneficiaries();
                if (beneficiaries != null && !beneficiaries.isEmpty())
                {   
                for (Beneficiary beneficiary : beneficiaries)
                {
                     map= beneficiary.getAttributes();
                print the map here
                }
                }
                }
                • 5. Re: beneficiary attributes are not saved in OIM request
                  926363
                  thsi is what I am trying to do.

                  While submitting a request for Role, the user will enter some information which has to be stored at Request level. I am not talking about user attributes. Request level attributes such as :

                  <attr1 key, attr1 value>
                  <attr 2 key, attr2 value>

                  These are specific to the request. When approver clicks on the request, we have custom page which will fetch these attributes and display on the screen so that approver will decide whether to approve or not based on these attribute values.

                  Each request may have multiple role entities. We have again each role level attributes pertaining to each role itself.


                  here is the code :

                  RequestData requestData = new RequestData();
                  Beneficiary beneficiary = new Beneficiary();
                  HashMap map = new HashMap();
                  map.put("req_attr_1", "req_attr1_value");
                  map.put("req_attr_2", "req_attr2_value");
                  beneficiary.setAttributes(map); // I am wondering where is this data going ? I am not finding in any table


                  RequestBeneficiaryEntity requestEntity =new RequestBeneficiaryEntity();
                  //setting info for request beneficiary entity


                  List<RequestBeneficiaryEntity> entities=new ArrayList<RequestBeneficiaryEntity>();
                  entities.add(requestEntity );
                  beneficiary.setTargetEntities(entities);
                  ............................................ //whatever needed


                  List<Beneficiary> beneficiaries = new ArrayList<Beneficiary>();
                  beneficiaries.add(beneficiary);


                  requestData.setBeneficiaries(beneficiaries);


                  now submit request using oimService. /// I am able to submit request successfully.


                  I am trying to retrieve these beneficiary attributes :

                  Request req = reqService.getBasicRequestData("594");
                  I do not see benericiary attributes in the request now.



                  thanks


                  Edited by: 923360 on Jan 30, 2013 7:31 PM

                  Edited by: 923360 on Jan 30, 2013 7:33 PM
                  • 6. Re: beneficiary attributes are not saved in OIM request
                    idamGod
                    did you try this code.

                    String reqId = "594";
                    Request request = requestService.getBasicRequestData(reqId);

                    if (request != null)
                    {
                    beneficiaries = request.getBeneficiaries();
                    if (beneficiaries != null && !beneficiaries.isEmpty())
                    {
                    for (Beneficiary beneficiary : beneficiaries)


                    imap= beneficiary.getAttributes();
                    print the map here
                    }
                    }

                    FYI - Request data will never be saved in any of the OIM tables in 11gR1/R2 as it will be saved in SOA.
                    • 7. Re: beneficiary attributes are not saved in OIM request
                      926363
                      that's how I am trying to retrive the attributes. Exactly the same same code as you mentioned. The beneficiary object has null attributes object !!

                      I think this is bug. Very straight forward concept. but attributes object is null when I get the request based on request number.

                      thanks

                      Edited by: 923360 on Jan 30, 2013 7:44 PM

                      Edited by: 923360 on Jan 30, 2013 7:46 PM

                      Edited by: 923360 on Jan 31, 2013 3:46 AM
                      • 8. Re: beneficiary attributes are not saved in OIM request
                        idamGod
                        I am not sure how you are doing.

                        But when you give System.out.println("Beneficiary Attributes ="+ben.getAttributes()); should print only the beneficairy basic details like manager key, login, first name, last name, display name etc.

                        Also check the request status. If it is in failed status, the above statement will give you nothing.
                        • 9. Re: beneficiary attributes are not saved in OIM request
                          926363
                          there is only one straight way. If we use beneficiay.setAttributes(), obviously we need to use beneficiay.getAttributes(). I do not think there is any othr way to retrive the beneficiary attributes which were submitted in the request using beneficiay.setAttributes().

                          I even used RequestTemplateAttribute concept to send these request level attributes. But same issue.


                          RequestTemplateAttribute reqTempAttr = new RequestTemplateAttribute();
                          reqTempAttr.setValue(map);
                          List<RequestTemplateAttribute> attrList= new ArrayList<RequestTemplateAttribute>();
                          requestData.setTemplateAttributes(attrList);
                          ........ submit request

                          When try to retrive the attributes using request.getTemplateAttributes(), it is empty.

                          No idea why I am not seeing these attributes. Request is in approval stage.

                          thanks

                          Edited by: 923360 on Jan 31, 2013 3:54 AM
                          • 10. Re: beneficiary attributes are not saved in OIM request
                            idamGod
                            As I said in my previous post, beneficiary.getattributes() will give you only basic fields like manager key, user key, user login, first name, last name, display name that's it. If you are looking for some other attributes, I dont think you will get them.
                            • 11. Re: beneficiary attributes are not saved in OIM request
                              926363
                              I do not see even basic information. It is totally empty. I am using 11gR2 and not sure whether it is an issue with 11gR2. Beneficiary.getAttributes is empty.

                              thanks