Source:
public void handleEvent(EventBundle events) { RetentionManager retentionManager = Framework.getService(RetentionManager.class); Map<String, Set<String>> docsToCheckAndEvents = new HashMap<String, Set<String>>(); Map<String, Boolean> documentModifiedIgnored = new HashMap<String, Boolean>(); for (Event event : events) { log.trace("Proceeding event " + event.getName()); EventContext evtCtx = event.getContext(); DocumentEventContext docEventCtx = (DocumentEventContext) evtCtx; DocumentModel doc = docEventCtx.getSourceDocument(); String docId = doc.getId(); if (docEventCtx.getProperties().containsKey(RetentionConstants.RETENTION_CHECKER_LISTENER_IGNORE) && !documentModifiedIgnored.containsKey(docId)) { documentModifiedIgnored.put(docId, true); continue; } if (!doc.hasFacet(RetentionConstants.RECORD_FACET)) { log.trace("Document is not a record", doc::getPathAsString); continue; } Record record = doc.getAdapter(Record.class); RetentionRule rule = record.getRule(docEventCtx.getCoreSession()); if (rule == null) { log.trace("Record does not have rule", doc::getPathAsString); continue; } if (!rule.isEventBased()) { log.trace("Rule is not event-based", () -> rule.getDocument().getPathAsString()); continue; } if (record.isRetentionExpired()) { log.trace("Record already expired", doc::getPathAsString); retentionManager.proceedRetentionExpired(record, event.getContext().getCoreSession()); continue; } if (docsToCheckAndEvents.containsKey(docId)) { Set<String> eventsToCheck = docsToCheckAndEvents.get(docId); if (!eventsToCheck.contains(event.getName())) { eventsToCheck.add(event.getName()); } docsToCheckAndEvents.put(docId, eventsToCheck); } else { Set<String> evts = new HashSet<String>(); evts.add(event.getName()); docsToCheckAndEvents.put(docId, evts); } } if (!docsToCheckAndEvents.isEmpty()) { retentionManager.evalRules(docsToCheckAndEvents); } }

Target:
public void handleEvent(EventBundle events) { RetentionManager retentionManager = Framework.getService(RetentionManager.class); Map<String, Set<String>> docsToCheckAndEvents = new HashMap<>(); Map<String, Boolean> documentModifiedIgnored = new HashMap<>(); for (Event event : events) { log.trace("Processing event ", event::getName); EventContext evtCtx = event.getContext(); DocumentEventContext docEventCtx = (DocumentEventContext) evtCtx; DocumentModel doc = docEventCtx.getSourceDocument(); String docId = doc.getId(); if (docEventCtx.getProperties().containsKey(RetentionConstants.RETENTION_CHECKER_LISTENER_IGNORE) && !documentModifiedIgnored.containsKey(docId)) { documentModifiedIgnored.put(docId, true); continue; } if (!doc.hasFacet(RetentionConstants.RECORD_FACET)) { log.trace("Document is not a record", doc::getPathAsString); continue; } Record record = doc.getAdapter(Record.class); RetentionRule rule = record.getRule(docEventCtx.getCoreSession()); if (rule == null) { log.trace("Record does not have rule", doc::getPathAsString); continue; } if (!rule.isEventBased()) { log.trace("Rule is not event-based", () -> rule.getDocument().getPathAsString()); continue; } if (record.isRetentionExpired()) { log.trace("Record already expired", doc::getPathAsString); retentionManager.proceedRetentionExpired(record, event.getContext().getCoreSession()); continue; } docsToCheckAndEvents.computeIfAbsent(docId, k -> new HashSet<>()).add(event.getName()); } if (!docsToCheckAndEvents.isEmpty()) { retentionManager.evalRules(docsToCheckAndEvents); } }