Hi All,
We are trying to get the entitlement description using the search method but it is giving an empty iterator and we have also tried with context.getObjects but it is giving an empty list. If we hardcode the values it gives an description but it does not give an description through the process.
Requiremnt is getting the description of th entitlement , can you help me on it
1st
public String description(String appName, String entitlmentName, String attribute) throws GeneralException {
QueryOptions qo = new QueryOptions();
qo.add(Filter.and(Filter.eq(“application.name”, appName), Filter.eq(“attribute”, attribute), Filter.or(Filter.eq(“displayName”, entitlmentName), Filter.eq(“value”, entitlmentName))));
Iterator iter = context.search(ManagedAttribute.class, qo);
while (null != iter && iter.hasNext()) {
ManagedAttribute manageAttr = (ManagedAttribute) iter.next();
if (null != manageAttr && null != manageAttr.getDescription("en_US")) {
log.trace("Exiting getDescription (trace=" + (String) manageAttr.getDescription("en_US") + ")");
return (String) manageAttr.getDescription("en_US");
}
}
}
2nd
---
public String description(String appName, String entitlementName, String attribute) throws GeneralException {
log.error("Entered getEntRoleDesc");
Application app = context.getObjectByName(Application.class, appName);
if (app == null) {
log.error("Application not found: " + appName);
return "N/A";
}
log.debug("Searching for entitlement: " + entitlementName + ", attribute: " + attribute + ", app: " + appName);
// Build the query
QueryOptions qo = new QueryOptions();
qo.add(Filter.and(
Filter.eq("application", app),
Filter.eq("value", entitlementName),
Filter.eq("type", "group")
) );
// Fetch the first matching ManagedAttribute directly
List ManagedAttribute ma = context.getObjects(ManagedAttribute.class, qo);
log.error("maaaaaaaa"+ma.toString());
if (ma != null @and !ma.isEmpty()) {
ManagedAttribute ma1=ma.get(0);
if(ma1 != null){
String desc = ma1.getDescription("en_US");
}