@Test public void onNotificationDoesNotAuditEventsWhenProcessorOfTypeEchoComponent() { auditConfig.setMuleFlowsLoggingEnabled(true); auditConfig.setMuleFlowsLoggingMessageEnabled(true); auditConfig.setMuleFlowsLoggingMessagePropertiesEnabled(true); expect(mockNotification.getSource()).andReturn(mockMuleEvent).anyTimes(); expect(mockNotification.getAction()).andReturn(MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE).anyTimes(); DefaultJavaComponent messageProcessor = new DefaultJavaComponent(); ObjectFactory mockObjectFactory = new SingletonObjectFactory(EchoComponent.class); messageProcessor.setObjectFactory(mockObjectFactory); expect(mockNotification.getProcessor()).andReturn(messageProcessor).anyTimes(); replayAll(); listener.onNotification(mockNotification); verifyAll(); }
@Override public void onNotification(MessageProcessorNotification notification) { log.trace("Mule message processor notification listener called"); MuleEvent event = notification.getSource(); if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE) { if ((event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) == null) && (event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) != null)) { event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } MDC.put(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE) { if (isAuditable(notification)) { audit(notification); } } }
AcmMessageProcessorNotificationListener implements MessageProcessorNotificationListener<MessageProcessorNotification> { @Override public void onNotification(MessageProcessorNotification notification) { log.trace("Mule message processor notification listener called"); MuleEvent event = notification.getSource(); if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE) { if ((event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) == null) && (event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) != null)) { event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } MDC.put(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE) { if (isAuditable(notification)) { audit(notification); } } } }
AcmMessageProcessorNotificationListener implements MessageProcessorNotificationListener<MessageProcessorNotification> { @Override public void onNotification(MessageProcessorNotification notification) { log.trace("Mule message processor notification listener called"); MuleEvent event = notification.getSource(); if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE) { if ((event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) == null) && (event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) != null)) { event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } MDC.put(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE) { if (isAuditable(notification)) { audit(notification); } } }  }
AcmMessageProcessorNotificationListener implements MessageProcessorNotificationListener<MessageProcessorNotification> { @Override public void onNotification(MessageProcessorNotification notification) { log.trace("Mule message processor notification listener called"); MuleEvent event = notification.getSource(); if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE) { if ((event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) == null) && (event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) != null)) { event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } MDC.put(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE) { if (isAuditable(notification)) { audit(notification); } } }  @Override void onNotification(MessageProcessorNotification notification); AuditService getAuditService(); void setAuditService(AuditService auditService); AuditConfig getAuditConfig(); void setAuditConfig(AuditConfig auditConfig); }
AcmMessageProcessorNotificationListener implements MessageProcessorNotificationListener<MessageProcessorNotification> { @Override public void onNotification(MessageProcessorNotification notification) { log.trace("Mule message processor notification listener called"); MuleEvent event = notification.getSource(); if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE) { if ((event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) == null) && (event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY) != null)) { event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); event.setSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getMessage().getInboundProperty(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } MDC.put(MDCConstants.EVENT_MDC_REQUEST_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_REMOTE_ADDRESS_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_USER_ID_KEY)); MDC.put(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY, event.getSessionVariable(MDCConstants.EVENT_MDC_REQUEST_ALFRESCO_USER_ID_KEY)); } if (notification.getAction() == MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE) { if (isAuditable(notification)) { audit(notification); } } }  @Override void onNotification(MessageProcessorNotification notification); AuditService getAuditService(); void setAuditService(AuditService auditService); AuditConfig getAuditConfig(); void setAuditConfig(AuditConfig auditConfig); static final String EVENT_TYPE; }