public void publishEntityToOrganization(String entityKey, String type, String targetOrgName, boolean includeSubOrgs) {
final String logp = CN + " :: publishEntityToOrganization - ";
LOGGER.debug(logp + "START");
try {
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);
}
List<EntityPublication> newPubList = new ArrayList<EntityPublication>();
Organization org = orgManager.getDetails("Organization Name", targetOrgName, null);
EntityPublication entPub = new EntityPublication(entityKey, resourceType, Long.valueOf(org.getEntityId()), includeSubOrgs);
entPub.setEntityType(type);
newPubList.add(entPub);
//publish entity to organization
entityPubService.addEntityPublications(newPubList);
LOGGER.debug(logp + "Successfully published...");
}catch(Exception e){
LOGGER.error(logp + "Exception while publishing entity to organization");
}
LOGGER.debug(logp + "END");
}
final String logp = CN + " :: publishEntityToOrganization - ";
LOGGER.debug(logp + "START");
try {
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);
}
List<EntityPublication> newPubList = new ArrayList<EntityPublication>();
Organization org = orgManager.getDetails("Organization Name", targetOrgName, null);
EntityPublication entPub = new EntityPublication(entityKey, resourceType, Long.valueOf(org.getEntityId()), includeSubOrgs);
entPub.setEntityType(type);
newPubList.add(entPub);
//publish entity to organization
entityPubService.addEntityPublications(newPubList);
LOGGER.debug(logp + "Successfully published...");
}catch(Exception e){
LOGGER.error(logp + "Exception while publishing entity to organization");
}
LOGGER.debug(logp + "END");
}
No comments:
Post a Comment