OIM API to Search Admin Roles


  1. package com.oimacademy.NeedEvaluate;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import com.oimacademy.connection.Platform;
  5. import oracle.iam.identity.rolemgmt.utils.MembersLookupable.SortOrder;
  6. import oracle.iam.platform.authopss.vo.AdminRole;
  7. import oracle.iam.platform.entitymgr.vo.SearchCriteria;
  8. import oracle.iam.platformservice.api.AdminRoleService;
  9. public class AdminRoleSearchAPI {
  10.  public static void main(String args[]){
  11.   AdminRoleService aRoleServ= Platform.getService(AdminRoleService.class); 
  12.      HashMap<String,Object> configParams = new HashMap<String,Object>(); 
  13.      configParams.put("STARTROW", 1); 
  14.      configParams.put("ENDROW",50); 
  15.      configParams.put("SORTORDER",SortOrder.DESCENDING); 
  16.      configParams.put("SORTEDBY","role_id");     
  17.      SearchCriteria criteria1=new  SearchCriteria("role_display_name","OrclOIMApplicationInstanceAdministratorRole",SearchCriteria.Operator.EQUAL); 
  18.      SearchCriteria criteria2=new  SearchCriteria("scoped","0",SearchCriteria.Operator.EQUAL); 
  19.      SearchCriteria criteriaFinal1=new  SearchCriteria(criteria1,criteria2,SearchCriteria.Operator.OR); 
  20.      SearchCriteria criteriaFinal2 = new SearchCriteria(criteria2, criteria1, SearchCriteria.Operator.OR);     
  21.      try{ 
  22.        System.out.println("========== First query ==========");
  23.              searchRolesPerCriteria(aRoleServ, null, criteriaFinal1);    
  24.       System.out.println("========== Second query ==========");
  25.          searchRolesPerCriteria(aRoleServ, null, criteriaFinal2);       
  26.      } catch (Exception e) {
  27.             e.printStackTrace();
  28.         }    
  29.  }
  30.     private static void searchRolesPerCriteria(AdminRoleService aRoleServ, HashMap<String, Object> configParams,
  31.             SearchCriteria criteriaFinal1) throws Exception {
  32.       List<AdminRole> adminRoleList = aRoleServ.search(criteriaFinal1, configParams);
  33.        System.out.println("Using Search: List Size [" + adminRoleList.size() + "]");
  34.       }
  35. }

No comments:

Post a Comment