class AlfrescoSyncService implements ApplicationEventPublisherAware {

    public void queryAlfrescoAuditApplications()
    {
        if (MDC.get(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY) == null)
        {
            MDC.put(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, "admin");
            MDC.put(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, UUID.randomUUID().toString());
        }

        List<EcmEvent> allEvents = new ArrayList<>();

        for (Map.Entry<String, EcmAuditResponseReader> auditApplication : getAuditApplications().entrySet())
        {
            List<EcmEvent> eventsForAuditApp = collectAuditEvents(auditApplication.getKey(), auditApplication.getValue());
            if (eventsForAuditApp != null && !eventsForAuditApp.isEmpty())
            {
                log.info("Fetched {} audit records for audit application {}", eventsForAuditApp.size(), auditApplication.getKey());
                allEvents.addAll(eventsForAuditApp);
            }
        }

        allEvents.stream().sorted(Comparator.comparing(EcmEvent::getAuditId)).forEach(e -> applicationEventPublisher.publishEvent(e));

    }

}