Skip to content

Commit

Permalink
Add user recomputation on membership change
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 5, 2019
1 parent 3f20433 commit f1f3967
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@
import com.evolveum.midpoint.schema.util.*
import com.evolveum.midpoint.prism.path.*
import com.evolveum.midpoint.schema.constants.*
import com.evolveum.midpoint.prism.delta.*

PLAIN_GROUP_OBJECT_CLASS = new ItemName(MidPointConstants.NS_RI, 'CustomPlainGroupObjectClass')
TRIGGER_FIRE_AFTER = 60000
TRIGGER_SAFETY_MARGIN = 10000

esbEvent = midpoint.getMessageBodyAsMap(message)['esbEvent'][0]
log.info('esbEvent = {}', esbEvent)
Expand All @@ -120,6 +123,10 @@
return null
}
subjectId = esbEvent['subjectId']
if (subjectId == null) {
log.info('Null subject ID in membership change message, ignoring it: {}', sourceId)
return null
}
log.info('### {} - {} - {}', subjectId, eventType, groupName)
identifiers = new HashMap()
identifiers.put(ICFS_NAME, groupName)
Expand All @@ -132,6 +139,12 @@
delta = new ObjectDeltaType()
delta.changeType = ChangeTypeType.MODIFY
delta.itemDelta.add(itemDelta)

added = midpoint
.getOptimizingTriggerCreator(TRIGGER_FIRE_AFTER, TRIGGER_SAFETY_MARGIN)
.createForNamedUser(subjectId)
log.info('Recompute trigger for {}: {}', subjectId, added ? 'added' : 'not added (already present or user not found)')

return UcfChangeUtil.create(PLAIN_GROUP_OBJECT_CLASS, identifiers, delta, prismContext)
} else if (eventType == 'GROUP_ADD' || eventType == 'GROUP_DELETE') {
groupName = esbEvent['name']
Expand Down

0 comments on commit f1f3967

Please sign in to comment.