Hi,
We have a webservice application in which Entitlements are getting created twice onw with app guid invalue and other with correct display name in value (when we run group aggregation dupe entitlements are getting created twice). In order to remove dupe entitlement one with guid value, wrote a custom rule to remove it from entitlement catalogue but not from target system.
I am gettign object cast error to string value. Can anyone suggest what is missing in below code.
@Preethi
In your original code, you’re using a projection query to pull the “id” field which is a String. You’re trying to cast that id string to a ManagedAttribute which won’t work. As for the NPE, you’re naming your QueryOptions variable qo but then calling it queryOptions on the next line. You probably want something like this:
import sailpoint.object.Filter;
import sailpoint.object.ManagedAttribute;
import sailpoint.object.QueryOptions;
import sailpoint.tools.GeneralException;
import sailpoint.api.IncrementalObjectIterator;
import sailpoint.api.Terminator;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import sailpoint.api.IncrementalObjectIterator;
QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq(“application.name”,“ABC”));
Terminator terminator = new Terminator(context);
IncrementalObjectIterator iter = new IncrementalObjectIterator(context, ManagedAttribute.class, qo)
while(itr.hasNext()){
ManagedAttribute managedAttr = (ManagedAttribute) iter.next();
String DisplayName = managedAttr.getDisplayName();
String Value = managedAttr.getValue();
log.error("DispalyName log error1:::"+DisplayName);
log.error("EntValue log error1:::"+Value);
if (null != DisplayName) {
if (!DisplayName.equals(Value)){
terminator.deleteObject(managedAttribute);
}
}
}
You might need to null check the itr before the itr.hasNext() call and the managedAttr before the managedAttr.getDisplayableName() call as well then. If that doesn’t fix it, you probably need a lot more logging, because there aren’t very many things left that could be null besides the actual log object itself.