Hi Francesco and all,

Following your advice, I used the UserProvisioningManager to update the user 
from within a SchedTask.
Here is the very simplified view of the code I run:

for (Any<?> any: anySearchDAO.search(...) { // do the stuff on a list of users
   User = (User)any;
   UserUR patch = new UserUR.Builder(user.getKey()).build();
   // remove a relationship that is mapped as follows in the resource
   // {
   //   "intAttrName" : 
"relationships[RELATION_USER_COLLABORATION][COLLABORATION].name",
   //   "extAttrName" : "__GROUPS__",
   //   "purpose" : "PROPAGATION"
   // }
   RelationshipTO attachment = new 
RelationshipTO.Builder("RELATION_USER_COLLABORATION").build();
   attachment.setOtherEndKey(KEY);
   attachment.setOtherEndName("c1");
   attachment.setOtherEndType(GiinConstants."COLLABORATION");
   patch.getRelationships().add(
        new 
RelationshipUR.Builder(attachment).operation(PatchOperation.DELETE).build()
   );
   Pair<UserUR, List<PropagationStatus>> result = 
userProvisioningManager.update(patch, false, AuthContextUtils.getUsername(), 
"myProcess");

}

This code is working fine, the user (who had initially 2 relationships to "c1" 
and "c2") is properly propagated. The core-connid log gives: (why 2 lines?):

instance='jsonfile' Enter: update(ObjectClass: COMPUTINGACCOUNT, Attribute: 
{Name=__UID__, Value=[1425]}, [Attribute: {Name=__GROUPS__, Value=[c2]}, ...], 
null)        Method: update
instance='jsonfile' Enter: update(ObjectClass: COMPUTINGACCOUNT, Attribute: 
{Name=__UID__, Value=[1425]}, [Attribute: {Name=__GROUPS__, Value=[c2]}, ...], 
OperationOptions: {})        Method: update



Now the weird part of my question:
I read user's current relationships before updating as follows:

for (Any<?> any: anySearchDAO.search(...) { // do the stuff on a list of users
   User = (User)any;
   user.getRelationships();
   UserUR patch = new UserUR.Builder(user.getKey()).build();
   ...
}

In this case, on the same user data, the USER update is fine, but the 
propagation does not send correct values:
instance='jsonfile' Enter: update(ObjectClass: COMPUTINGACCOUNT, Attribute: 
{Name=__UID__, Value=[1425]}, [Attribute: {Name=__GROUPS__, Value=[c1, c2]}, 
...], null)    Method: update
instance='jsonfile' Enter: update(ObjectClass: COMPUTINGACCOUNT, Attribute: 
{Name=__UID__, Value=[1425]}, [Attribute: {Name=__GROUPS__, Value=[c1, c2]}, 
...], OperationOptions: {})    Method: update

Are you able to reproduce this? Do you have any idea what could happen in the 
core to give this behavior?

Best regards
Lionel

----- Le 9 Jan 26, à 10:10, Lionel SCHWARZ [email protected] a écrit :

> ----- Le 31 Déc 25, à 7:57, Francesco Chicchiriccò [email protected] a 
> écrit :
> 
>> Hi,
>> I have just replicated your use case via REST and audit is working as 
>> expected.
>> 
>> I suppose that in your example the output is not updated because of the
>> transactional layout that is set up for REST invocations.
>> 
>> Invoking Logic classes from within Implementations (SchedTask in your case) 
>> is
>> discouraged as it might lead to inconsistencies, as the one you are reporting
>> below.
>> I would suggest to rely on calling the UserProvisioningManager instead.
> 
> Thanks Francesco
> I was not aware of this
> Regards
> Lionel

Reply via email to