OIM API To Modify User Details Request


  1. package com.oimacademy.request;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Map;
  5. import oracle.iam.api.OIMService;
  6. import oracle.iam.exception.OIMServiceException;
  7. import oracle.iam.identity.exception.NoSuchUserException;
  8. import oracle.iam.identity.exception.UserLookupException;
  9. import oracle.iam.platform.utils.vo.OIMType;
  10. import oracle.iam.request.vo.RequestConstants;
  11. import oracle.iam.request.vo.RequestData;
  12. import oracle.iam.request.vo.RequestEntity;
  13. import oracle.iam.request.vo.RequestEntityAttribute;
  14. import oracle.iam.vo.OperationResult;
  15. import com.oimacademy.connection.Platform;
  16. public class RequestToModifyUser {
  17.  private final OIMService oimService  =Platform.getService(OIMService.class); 
  18.  public OperationResult modifyUserAttributes(String usrKey, Map<String,String> modAttrs) throws NoSuchUserException, UserLookupException, OIMServiceException
  19.     {     
  20.         List<RequestEntityAttribute> reqModAttrs = new ArrayList<RequestEntityAttribute>();
  21.         for(Map.Entry<String,String> entry : modAttrs.entrySet())
  22.         {
  23.             RequestEntityAttribute modAttr = new RequestEntityAttribute(entry.getKey(), entry.getValue(), RequestEntityAttribute.TYPE.String);
  24.             reqModAttrs.add(modAttr);
  25.         }      
  26.         RequestEntity reqEntity = new RequestEntity();
  27.         reqEntity.setRequestEntityType(OIMType.User);
  28.         reqEntity.setEntityKey(usrKey);
  29.         reqEntity.setOperation(RequestConstants.MODEL_MODIFY_OPERATION);
  30.         reqEntity.setEntityData(reqModAttrs);        
  31.         List<RequestEntity>  entities = new ArrayList<RequestEntity>();
  32.         entities.add(reqEntity);        
  33.         // Setup 
  34.         RequestData reqData = new RequestData();
  35.         reqData.setTargetEntities(entities);        
  36.         // Invoke 
  37.         OperationResult result = oimService.doOperation(reqData, OIMService.Intent.REQUEST);        
  38.         return result;
  39.     }    
  40. }

No comments:

Post a Comment