OIM 11G R2 PS2 (11.1.2.2.0) Publishing Role to an Organization using OIM API

In this post, I will talk about the API which lets you publish a role or an app instance to a particular organization.

public void addPublication(String roleKey, String orgKeyIntValue) {
        EntityPublicationService eps = Platform
                .getService(EntityPublicationService.class);

        EntityPublication ep = new EntityPublication(roleKey,
                PolicyConstants.Resources.ROLE, Long.parseLong(orgKeyIntValue),
                true);

        List<EntityPublication> epl = new ArrayList<EntityPublication>();

        epl.add(ep);

        eps.addEntityPublications(epl);

    }





What the above will do is take a role and publish it to specific organization specified here by organization key.

Removing(Unpublishing) is far more complicated as you will have to get the publication ID

public void removePublication(String roleKey, String orgKey,
            String roleName, String newOrgKey) {
        HashMap hm = new HashMap();

        hm.put("STARTROW", 0);

        hm.put("ENDROW", 1);

        EntityPublicationSearchCriteria epsc = new EntityPublicationSearchCriteria();

        epsc.setRoleName(roleName);

        epsc.setEntityId(roleKey.toString());

        epsc.setEntityType(PolicyConstants.Resources.ROLE);

        epsc.setScopeId(orgKey);

        EntityPublicationService eps = Platform
                .getService(EntityPublicationService.class);

        List<EntityPublication> epl = eps.search(epsc, null);

        for (EntityPublication ep : epl) {

            Long pubId = ep.getEntityPublicationId();

            EntityPublication ep2 = new EntityPublication(roleKey,
                    PolicyConstants.Resources.ROLE, newOrgKey, true);

            ep2.setEntityPublicationId(pubId);

            epl.add(ep);

            eps.removeEntityPublications(epl, true);

        }

    }

Comments

Popular posts from this blog

OIM 11g R2 PS2 : SOA Approval Workflow Sample

Oracle Identity Manager (OIM) Interview Questions

OHS 12c (12.1.3) webgate deployment and configuration