public void updateEntitlementDetails(String entName) {
final String logp = CN + ":: updateEntitlementDetails - ";
LOGGER.debug(logp + "START");
try {
//get entitlement service
EntitlementService entServ = Platform.getService(EntitlementService.class);
//get Entitlement from OIM for the given Entitlement Name
Entitlement entitlement = getEntitlement(entName, entServ);
//Set Display Name
entitlement.setDisplayName("Entitlement Display Name");
//Set Description
entitlement.setDescription("Entitlement Description");
//Update Entitlement Details
entitlementService.updateEntitlement(entitlement);
LOGGER.info(logp + "Successfully updated basic entitlement details for - " + entitlement);
}catch (Exception e) {
LOGGER.error(logp + "Exception while updating entitlement in OIM - " + e, e);
}
LOGGER.debug(logp + "END");
}
public Entitlement getEntitlement(String entName, EntitlementService entServ){
final String logp = CN + ":: getEntitlementDetails - ";
LOGGER.debug(logp + "START");
if(null == entName || entName.trim().length() == 0){
LOGGER.error(logp + "Entitmement name is null or empty");
return null;
}
entName = entName.trim();
Entitlement ent = null;
try{
SearchCriteria criteria = new SearchCriteria(Entitlement.ENTITLEMENT_NAME, entName, SearchCriteria.Operator.EQUAL);
List<Entitlement> entList = entServ.findEntitlements(criteria, null);
if (entList.size() == 0 || entList.size() > 1) {
LOGGER.error(logp + "Improper number of entitlements found for entitlement name " + entName + " - " + entList.size());
}else{
ent = entList.get(0);
LOGGER.info(logp + "Successfully obtained entitlement - " + ent);
}
}catch (Exception e){
LOGGER.error(logp + "Exception while fetching entitlement for entitlement name " + entName + " - " + e, e);
}
LOGGER.debug(logp + "END");
return ent;
}
Happy Learning!!!
final String logp = CN + ":: updateEntitlementDetails - ";
LOGGER.debug(logp + "START");
try {
//get entitlement service
EntitlementService entServ = Platform.getService(EntitlementService.class);
//get Entitlement from OIM for the given Entitlement Name
Entitlement entitlement = getEntitlement(entName, entServ);
//Set Display Name
entitlement.setDisplayName("Entitlement Display Name");
//Set Description
entitlement.setDescription("Entitlement Description");
//Update Entitlement Details
entitlementService.updateEntitlement(entitlement);
LOGGER.info(logp + "Successfully updated basic entitlement details for - " + entitlement);
}catch (Exception e) {
LOGGER.error(logp + "Exception while updating entitlement in OIM - " + e, e);
}
LOGGER.debug(logp + "END");
}
public Entitlement getEntitlement(String entName, EntitlementService entServ){
final String logp = CN + ":: getEntitlementDetails - ";
LOGGER.debug(logp + "START");
if(null == entName || entName.trim().length() == 0){
LOGGER.error(logp + "Entitmement name is null or empty");
return null;
}
entName = entName.trim();
Entitlement ent = null;
try{
SearchCriteria criteria = new SearchCriteria(Entitlement.ENTITLEMENT_NAME, entName, SearchCriteria.Operator.EQUAL);
List<Entitlement> entList = entServ.findEntitlements(criteria, null);
if (entList.size() == 0 || entList.size() > 1) {
LOGGER.error(logp + "Improper number of entitlements found for entitlement name " + entName + " - " + entList.size());
}else{
ent = entList.get(0);
LOGGER.info(logp + "Successfully obtained entitlement - " + ent);
}
}catch (Exception e){
LOGGER.error(logp + "Exception while fetching entitlement for entitlement name " + entName + " - " + e, e);
}
LOGGER.debug(logp + "END");
return ent;
}
Happy Learning!!!
What are the packages you need to import? I'm getting flagged on
ReplyDeleteLOGGER.debug,entitlementService and "CN"? Not sure how to resolve it? Thanks