public void revokeEntityFromCurrentPublications(String entityKey, String type){
final String logp = CN + " :: revokeEntityFromCurrentPublications - ";
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);
//Revoke entity from current publications
entityPubService.removeEntityPublications(currentPubList);
LOGGER.debug(logp + "Successfully removed entity from current publications");
}catch(Exception e){
LOGGER.error(logp + "Exception while revoking entity from current publications");
}
LOGGER.debug(logp + "END");
}
Happy Learning!!!
final String logp = CN + " :: revokeEntityFromCurrentPublications - ";
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);
//Revoke entity from current publications
entityPubService.removeEntityPublications(currentPubList);
LOGGER.debug(logp + "Successfully removed entity from current publications");
}catch(Exception e){
LOGGER.error(logp + "Exception while revoking entity from current publications");
}
LOGGER.debug(logp + "END");
}
Happy Learning!!!
No comments:
Post a Comment