OIM API to Create/Provision Application Instance via Request


  1. package com.oimacamedy.request;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import com.oimacademy.connection.Platform;
  5. import oracle.iam.api.OIMService;
  6. import oracle.iam.platform.utils.vo.OIMType;
  7. import oracle.iam.provisioning.api.ApplicationInstanceService;
  8. import oracle.iam.provisioning.vo.ApplicationInstance;
  9. import oracle.iam.request.vo.Beneficiary;
  10. import oracle.iam.request.vo.RequestBeneficiaryEntity;
  11. import oracle.iam.request.vo.RequestBeneficiaryEntityAttribute;
  12. import oracle.iam.request.vo.RequestConstants;
  13. import oracle.iam.request.vo.RequestData;
  14. import oracle.iam.vo.OperationResult;
  15. public class CreateAppInstanceProvisioningRequest {
  16.  public static void main(String[] args) throws Exception {
  17.         OIMService unifiedService = Platform.getService(OIMService.class);        
  18.         ApplicationInstanceService applicationInstanceService=Platform.getService(ApplicationInstanceService.class);
  19.   ApplicationInstance applicationInstance=applicationInstanceService.findApplicationInstanceByName("DisconnectedA");  
  20.   System.out.println("ApplicationInstanceName   ->"+applicationInstance.getApplicationInstanceName());        
  21.         String applicationInstanceName = applicationInstance.getApplicationInstanceName();
  22.         String applicationInstanceKey = applicationInstance.getApplicationInstanceKey()+"";        
  23.         RequestData requestData = new RequestData();
  24.         RequestBeneficiaryEntity requestEntity = new RequestBeneficiaryEntity();
  25.         requestEntity.setRequestEntityType(OIMType.ApplicationInstance);
  26.         requestEntity.setEntitySubType(applicationInstanceName);
  27.         requestEntity.setEntityKey(applicationInstanceKey); 
  28.         requestEntity.setOperation(RequestConstants.MODEL_PROVISION_APPLICATION_INSTANCE_OPERATION);        
  29.         List<RequestBeneficiaryEntityAttribute> attrs = new ArrayList<RequestBeneficiaryEntityAttribute>();
  30.   //Need to Change "Account Login" /  "Account ID" / "Password" as per form attributes
  31.         RequestBeneficiaryEntityAttribute attr = new RequestBeneficiaryEntityAttribute("Account Login", "TUSER"+Math.random(), RequestBeneficiaryEntityAttribute.TYPE.String); 
  32.         attrs.add(attr);
  33.         attr = new RequestBeneficiaryEntityAttribute("Password", "Welcome1", RequestBeneficiaryEntityAttribute.TYPE.String);
  34.         attrs.add(attr);
  35.         attr = new RequestBeneficiaryEntityAttribute("Account ID", "FEDERER", RequestBeneficiaryEntityAttribute.TYPE.String);
  36.         attrs.add(attr);        
  37.         requestEntity.setEntityData(attrs);        
  38.         List<RequestBeneficiaryEntity> entities = new ArrayList<RequestBeneficiaryEntity>();
  39.         entities.add(requestEntity);        
  40.         Beneficiary beneficiary = new Beneficiary();        
  41.         String userKey = "11780";  //user key from USR Table
  42.         beneficiary.setBeneficiaryKey(userKey);
  43.         beneficiary.setBeneficiaryType(Beneficiary.USER_BENEFICIARY);        
  44.         beneficiary.setTargetEntities(entities);        
  45.         List<Beneficiary> beneficiaries = new ArrayList<Beneficiary>();
  46.         beneficiaries.add(beneficiary);
  47.         requestData.setBeneficiaries(beneficiaries);        
  48.         OperationResult result = unifiedService.doOperation(requestData, OIMService.Intent.REQUEST);
  49.         System.out.println("Request ID :: " + result.getEntityId());     
  50.  }
  51. }

No comments:

Post a Comment