Its not autogenerated it’s id of the managedAttribute so you just get ma.getId() and this value you put to setOwnerId method
got it! I am able to get Managedattribute id… But we cannot passit as string to set ownerid . Do we need to send it as Object classifcation for both ownerid and ownertype
Hi @Preethi
Can you please share your classification object xml and Managed Attribute xml
This are the methods available in ObjectClassification class
It should be possible to just pass the string
This is the code that works for me
<Source>
import sailpoint.object.ManagedAttribute;
import sailpoint.object.Classification;
import sailpoint.object.ObjectClassification;
ManagedAttribute ma = context.getObjectById(ManagedAttribute.class,"ac1fe44c7eda1367817eddf85c457d05");
Classification cl = context.getObjectByName(Classification.class,"FinancialSensitive");
ObjectClassification oc = new ObjectClassification();
oc.setOwnerId(ma.getId());
oc.setOwnerType("ManagedAttribute");
oc.setClassification(cl);
ma.addClassification(oc);
context.saveObject(ma);
context.commitTransaction();
</Source>
Hi satish,
<?xml version='1.0' encoding='UTF-8'?>!DOCTYPE Classification PUBLIC “sailpoint.dtd” “sailpoint.dtd”
Classification created=“1591968047137” displayName=“IT Sensitive” id=“ac1ffeda72a81fac8172a8b0a0210484” modified=“1701290874563” name=“itSensitive” origin=“MRC-SOXApps”>
Attributes>
Map>
entry key=“sysDescriptions”>
value>
Map>
entry key=“en_US” value=“Allows access to IT sensitive Entitlements”/>
/Map>
/value>
/entry>
/Map>
/Attributes>
/Classification>
Managed Attribte:
<?xml version='1.0' encoding='UTF-8'?>!DOCTYPE ManagedAttribute PUBLIC “sailpoint.dtd” “sailpoint.dtd”>
ManagedAttribute attribute=“Entitlement” created=“1701354065639” displayName=“TestVeritax2” hash=“29f7b4c980a0e8a74443aaccb674ff4be760cf75” id=“ac1ffe458b07166b818c209acee6106c” modified=“1701354077036” type=“Entitlement” value=“TestVeritax2”>
ApplicationRef>
Reference class=“sailpoint.object.Application” id=“ac1ffecb8af213c0818af28924ce093c” name=“Veritax”/>
/ApplicationRef>
Attributes>
Map>
entry key=“sysDescriptions”>
value>
Map>
entry key=“en_US”/>
/Map>
/value>
/entry>
/Map>
/Attributes>
/ManagedAttribute>
I have the similar code but still sensitivity is not getting updated. Not sure what I am missing
<?xml version='1.0' encoding='UTF-8'?> This rule is used to mark sensitivity for newly added entitlment by defaultimport sailpoint.object.ObjectClassification;
import java.util.Date;
import org.apache.commons.lang.time.DateUtils;
import sailpoint.api.IncrementalObjectIterator;
import sailpoint.api.Terminator;
import sailpoint.api.*;
import sailpoint.tools.Util;
import java.util.Iterator;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import sailpoint.tools.Util;
import java.util.Iterator;
ManagedAttribute ma = new ManagedAttribute();
String classificationName=“itSensitive”;
QueryOptions qo = new QueryOptions();
Classification classf=context.getObjectByName(Classification.class, classificationName);
log.error (“setClassification list is :”+classf);
ObjectClassification objClassf=new ObjectClassification();
objClassf.setClassification(classf);
log.error (“ObjectClassification list is :”+objClassf);
Date last1DayDate = new Date();
last1DayDate= DateUtils.addDays(last1DayDate, -1);
qo.addFilter(Filter.eq(“application.name”,“Veritax”));
//qo.addFilter(Filter.gt(“created”,last1DayDate));// Filter to Get entitlements created in last 1 day
log.error (“qo list is :”+qo);
IncrementalObjectIterator<ManagedAttribute> managedAttrsIterator = new IncrementalObjectIterator<ManagedAttribute>(context, ManagedAttribute.class, qo);
while (managedAttrsIterator.hasNext()) {
ManagedAttribute managedAttr = (ManagedAttribute) managedAttrsIterator.next();
String managedAttrid = managedAttr.getId() ;
objClassf.setOwnerId(managedAttr.getId()) ;
objClassf.setOwnerType(“ManagedAttribute”);
managedAttr.addClassification(objClassf);
log.error (“managedAttr list is :”+managedAttr);
context.saveObject(managedAttr);
context.commitTransaction();
log.error (“saved managedAttr list is :”+managedAttr);
}
context.commitTransaction();
I just copied your code to my lab environment and it works perfectly correct. It did what it was supposed to do exactly. So I would look for an issue somwhere in your environment - not in the code as it seems to be correct.
With the code I provided it should work fine actually, I have tested the code before I provided you
Can you share the log for the loggers you added here, code seems correct, also can you add the objects .toXml() in logs
Thanks Satish! Code is working fine… I am able to set sensitivity for newly created entitlements. But i have created 5 new entitlements . only for last iterated entitlement sensitivity is getting updated. Do we need to change the iterator or am I missing something in the code .
ManagedAttribute ma = new ManagedAttribute();
String classificationName=“itSensitive”;
QueryOptions qo = new QueryOptions();
Classification classf=context.getObjectByName(Classification.class, classificationName);
log.error (“setClassification list is :”+classf);
ObjectClassification objClassf=new ObjectClassification();
objClassf.setClassification(classf);
log.error (“ObjectClassification list is :”+objClassf);
Date last1DayDate = new Date();
last1DayDate= DateUtils.addDays(last1DayDate, -1);
qo.addFilter(Filter.gt(“created”,last1DayDate));// Filter to Get entitlements created in last 1 day
log.error (“qo list is :”+qo);
IncrementalObjectIterator<ManagedAttribute> managedAttrsIterator = new IncrementalObjectIterator<ManagedAttribute>(context, ManagedAttribute.class, qo);
while (managedAttrsIterator.hasNext()) {
ManagedAttribute managedAttr = (ManagedAttribute) managedAttrsIterator.next();
log.error (“managedAttr list is :”+managedAttr);
objClassf.setOwnerId(managedAttr.getId()) ;
objClassf.setOwnerType(“ManagedAttribute”);
managedAttr.addClassification(objClassf);Preformatted text
context.saveObject(managedAttr);
context.commitTransaction();
}
Put this below code inside while loop, it should work
ObjectClassification objClassf=new ObjectClassification();
objClassf.setClassification(classf);
log.error (“ObjectClassification list is :”+objClassf);
Also Setting Owner ID and owen Type is not really mandatory, but there is no harm in having those
Please try the above change I suggested related to while loop and let me know if it is working for all entitlements.
Perfect! Code is working as expected. Thanks a lot!
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.