Sunday 1 April 2018

OIM API - Code Snippet to get Current Publications(Organizations) for the given Entity.

public void getCurrentPublicationsForEntity(String entityKey, String type) {
    final String logp = CN + " :: getCurrentPublicationsForEntity - ";
    LOGGER.debug(logp + "START");
    EntityPublicationService entityPubService = null;
   
    try{
        entityPubService = Platform.getService(EntityPublicationService.class);
       
        PolicyConstants.Resources resourceType = null;

        if("Entitlement".equalsIgnoreCase(type)){
            resourceType = PolicyConstants.Resources.IT_RESOURCE_ENTITLEMENT;
        }else if("Application Instance".equalsIgnoreCase(type)) {
            resourceType = PolicyConstants.Resources.APPLICATION_INSTANCE;
        }else{
            LOGGER.error(logp + "Invalid entity type - " + type);
            throw new Exception("Invalid entity type - " + type);
        }

        //get current publications
        List<EntityPublication> currentPubList = entityPubService.listEntityPublications(resourceType, entityKey, null);
        LOGGER.info(logp + "Obtained current publications for entity " + entityName + " - " + currentPubList);
       
    }catch(Exception e){
        LOGGER.error(logp + "Exception while fetching current publications for entity - " + entityKey);
    }

    LOGGER.debug(logp + "END");
}


Happy Learning!!!

No comments:

Post a Comment