2828import org .apache .commons .lang3 .BooleanUtils ;
2929import org .apache .commons .lang3 .exception .ExceptionUtils ;
3030import org .apache .syncope .common .lib .request .AnyUR ;
31+ import org .apache .syncope .common .lib .request .GroupUR ;
3132import org .apache .syncope .common .lib .request .StringPatchItem ;
3233import org .apache .syncope .common .lib .to .AnyTO ;
3334import org .apache .syncope .common .lib .to .Provision ;
4041import org .apache .syncope .common .lib .types .UnmatchingRule ;
4142import org .apache .syncope .core .persistence .api .entity .Any ;
4243import org .apache .syncope .core .persistence .api .entity .ExternalResource ;
44+ import org .apache .syncope .core .persistence .api .entity .group .Group ;
4345import org .apache .syncope .core .persistence .api .entity .task .PushTask ;
4446import org .apache .syncope .core .persistence .api .entity .user .User ;
4547import org .apache .syncope .core .provisioning .api .AuditManager ;
@@ -210,11 +212,22 @@ protected void provision(final Any any, final Boolean enable, final Provisioning
210212 }
211213 }
212214
215+ protected void copyDynMembershipConds (final Any any , final AnyUR req ) {
216+ if (any instanceof Group group && req instanceof GroupUR gur ) {
217+ Optional .ofNullable (group .getUDynMembership ()).
218+ ifPresent (udc -> gur .setUDynMembershipCond (udc .getFIQLCond ()));
219+
220+ group .getADynMemberships ().
221+ forEach (adc -> gur .getADynMembershipConds ().put (adc .getAnyType ().getKey (), adc .getFIQLCond ()));
222+ }
223+ }
224+
213225 protected void link (final Any any , final boolean unlink , final ProvisioningReport result ) {
214226 AnyUR req = getAnyUtils ().newAnyUR (any .getKey ());
215227 req .getResources ().add (new StringPatchItem .Builder ().
216228 operation (unlink ? PatchOperation .DELETE : PatchOperation .ADD_REPLACE ).
217229 value (profile .getTask ().getResource ().getKey ()).build ());
230+ copyDynMembershipConds (any , req );
218231
219232 update (req );
220233
@@ -226,6 +239,7 @@ protected void unassign(final Any any, final ConnectorObject beforeObj, final Pr
226239 req .getResources ().add (new StringPatchItem .Builder ().
227240 operation (PatchOperation .DELETE ).
228241 value (profile .getTask ().getResource ().getKey ()).build ());
242+ copyDynMembershipConds (any , req );
229243
230244 update (req );
231245
@@ -237,6 +251,7 @@ protected void assign(final Any any, final Boolean enabled, final ProvisioningRe
237251 req .getResources ().add (new StringPatchItem .Builder ().
238252 operation (PatchOperation .ADD_REPLACE ).
239253 value (profile .getTask ().getResource ().getKey ()).build ());
254+ copyDynMembershipConds (any , req );
240255
241256 update (req );
242257
0 commit comments