package com.role; import oracle.iam.identity.exception.RoleCategoryAlreadyExistsException; import oracle.iam.identity.exception.RoleCategoryCreateException; import oracle.iam.identity.exception.ValidationFailedException; import oracle.iam.identity.rolemgmt.api.RoleCategoryManager; import oracle.iam.identity.rolemgmt.api.RoleManagerConstants; import oracle.iam.identity.rolemgmt.vo.RoleCategory; import oracle.iam.identity.rolemgmt.vo.RoleManagerResult; import oracle.iam.platform.authz.exception.AccessDeniedException; import java.util.HashMap; import com.connection.Platform; public class CreateRoleCategory { public CreateRoleCategory() { } public void createCategory(String categoryName, String categoryDescription) { try { RoleCategoryManager rmgr = Platform.getService(RoleCategoryManager.class); RoleCategory rcategory = new RoleCategory(categoryName); rcategory.setDescription(categoryDescription); rcategory.setName(categoryName); RoleManagerResult result = rmgr.create(rcategory);
System.out.println(" Role Category " + categoryName + " Status " + result.getStatus()); }catch(Exception e) { e.printStackTrace(); } } public static void main(String args[]) { try { CreateRoleCategory obj = new CreateRoleCategory(); for (int i =1;i<20;i++){ obj.createCategory("CategoryName"+i,"CategoryDescription"+i); } }catch(Exception e) { e.printStackTrace(); } } public void createCategory() throws ValidationFailedException,
RoleCategoryAlreadyExistsException, RoleCategoryCreateException,
AccessDeniedException { String categoryName = "RoleCategoryName"; RoleCategoryManager roleCategoryMgr = Platform.getService(RoleCategoryManager.class); RoleManagerResult roleResult = null; HashMap<String, Object> createAttributes = new HashMap<String, Object>(); createAttributes.put(RoleManagerConstants.ROLE_CATEGORY_NAME, categoryName); createAttributes.put(RoleManagerConstants.ROLE_CATEGORY_DESCRIPTION, categoryName + " Description"); RoleCategory roleCategory = new RoleCategory(createAttributes); roleResult = roleCategoryMgr.create(roleCategory); String entityId = roleResult.getEntityId(); System.out.println("Created role category with key = " + entityId); } }
No comments:
Post a Comment