I have a custom pull action groovy script running when I run my pull action.
My understanding is that the search script fires and builds a conn object
with the attributes I have mapped. Next the custom pull action fires. I can
see this in core.log with lots of logging statements I have in beforeUpdate
function. However at this point none of the parameters passed in seem to
have the attributes on them from the search script step.
Here is the connid.log when I run the pull task. This is the output of the
connid object constructed in the search script:
{Uid=Attribute:
{Name=__UID__, Value=[834f03a5-f5c5-42d5-ac61-21757444e929]},
ObjectClass=ObjectClass: __ACCOUNT__,
Attributes=[
Attribute: {Name=Email_Address,
Value=[[email protected]]},
Attribute: {Name=User_Id, Value=[SomethingInstaller]},
Attribute: {Name=username,
Value=[[email protected]]},
Attribute: {Name=__NAME__,
Value=[834f03a5-f5c5-42d5-ac61-21757444e929]},
Attribute: {Name=__UID__,
Value=[834f03a5-f5c5-42d5-ac61-21757444e929]},
Attribute: {Name=IFSPersonId,
Value=[834f03a5-f5c5-42d5-ac61-21757444e929]},
Attribute: {Name=ActorId, Value=[SomethingInstaller]},
Attribute: {Name=CLRoles, Value=[
{5C56FD1C-8D7E-4CDE-BDEC-88CD4EAD6818=Test-Administrator,
84FABAF6-A66D-410F-8169-469459516E68=TestAdministrator_ST ]},
Attribute: {Name=FamilyName, Value=[Installer]},
Attribute: {Name=GivenName, Value=[Something]}],
Name=Attribute: {Name=__NAME__,
Value=[834f03a5-f5c5-42d5-ac61-21757444e929]}}) Method: handle
Here is my beforeUpdate method. The important parts are just the logging and
trying to find the attributes from the above object, specifically the
CLRoles attribute. From the parameters how can I access the above attributes
or should I be looking in a different function all together?
@Transactional(readOnly = true)
@Override
public <P extends AnyPatch> void beforeUpdate(
org.apache.syncope.core.provisioning.api.pushpull.ProvisioningProfile
profile,
org.identityconnectors.framework.common.objects.SyncDelta delta,
EntityTO entity,
P anyPatch) throws JobExecutionException {
LOG.info("**************************************** before update! " +
entity.getUid().getUidValue());
List tests = getMembAttrValues(delta, profile.getConnector());
LOG.info("****************************************entity.getKey(): " +
entity.getKey());
//I can replace entity here with any of the parameters but I do not see the
properties/attributes from the search script. Specifically I need CLRoles
attribute.
for (Field field : entity.getClass().getDeclaredFields()) {
field.setAccessible(true);
String name = field.getName();
Object value = field.get(entity);
LOG.info("****************************************name: " + name);
LOG.info("****************************************value: " + value);
}
if (anyPatch instanceof UserPatch) {
final UserTO user = ((UserTO) entity);
Group oGroup = null;
String oGroupColumn = "members";
Set<AttrTO> attrsDer = user.getDerAttrs();
LOG.info("****************************************der attr length: "
+ attrsDer.size());
for(AttrTO derattr : attrsDer) {
LOG.info("****************************************der attr
name: " + derattr.getSchema());
LOG.info("****************************************der
attr value: " +
derattr.getValues().get(0).toString());
}
Set<AttrTO> attrsVir = user.getVirAttrs();
LOG.info("****************************************vir attr length: "
+ attrsVir.size());
for(AttrTO virattr : attrsVir) {
LOG.info("****************************************vir attr
name: " + virattr.getSchema());
LOG.info("****************************************vir
attr value: " +
virattr.getValues().get(0).toString());
}
Set<AttrTO> attrs = user.getPlainAttrs();
LOG.info("****************************************attr length: " +
attrs.size());
for(AttrTO attr : attrs) {
LOG.info("****************************************attr name: "
+ attr.getSchema());
LOG.info("****************************************attr value: " +
attr.getValues().get(0).toString());
if(attr.getSchema().equalsIgnoreCase( oGroupColumn)){
LOG.info("We check the schema:"+ attr.getSchema());
//Found
LOG.info("Content:
"+attr.getValues().get(0).toString()); //Found
oGroup =
groupDAO.findByName(attr.getValues().get(0).toString());
LOG.info("Group Key: "+oGroup.getKey()); //Group key
correctly retrieved
final MembershipTO membershipTO = new
MembershipTO.Builder().group(oGroup.getKey()).build();
LOG.info("Check membership :"+
membershipTO.getGroupKey()); //Correct, it corresponds to the previous group
key
LOG.info("Get user key:"+ user.getUsername()); //
Correct, it corresponds to what found in Syncope DB
boolean result =
user.getMemberships().add(membershipTO);
LOG.info("Was the user added to the group?: "+result);
// Returns true
}
//group = user.getPlainAttrMap().get("role");
}
}
/*
groupDAO.findUMemberships(groupDAO.find(entity.getKey())).forEach(uMembership
-> {
Set<String> memb =
membershipsBefore.get(uMembership.getLeftEnd().getKey());
if (memb == null) {
memb = new HashSet<>();
membershipsBefore.put(uMembership.getLeftEnd().getKey(),
memb);
}
memb.add(entity.getKey());
});
*/
}
--
Sent from: http://syncope-user.1051894.n5.nabble.com/