/** * This function builds the required configuration object for Notification sender and pass it * to the notification sender with the relevant event. * * @param operation Type or operation took place in user operation listener * @param username username of the subjected user for attribute change */ private void sendNotification(String operation, String username) { NotificationSender notificationSender = IdentityMgtServiceComponent.getNotificationSender(); if (notificationSender != null) { try { PublisherEvent event = new PublisherEvent(eventName); event.addEventProperty(operationLabel, operation); event.addEventProperty(usernameLabel, username); if (log.isDebugEnabled()) { log.debug("Invoking notification sender"); } notificationSender.invoke(event); } catch (NotificationManagementException e) { log.error("Error while sending notifications on user operations", e); } } else { log.error("No registered notification sender found. Notification sending aborted"); } } }
@Override public void run() { if (log.isDebugEnabled()) { log.debug("Executing " + module.getModuleName() + " on event" + event. getEventName()); } try { module.sendMessage(event); } catch (NotificationManagementException e) { log.error("Error while invoking notification sending module " + module. getModuleName(), e); } } };
/** * Building per module configuration objects * * @param moduleName Name of the module * @return ModuleConfiguration object which has configurations for the given module name */ private ModuleConfiguration buildModuleConfigurations(String moduleName) { Properties moduleProperties = getModuleProperties(moduleName); List<Subscription> subscriptionList = buildSubscriptionList(moduleName, moduleProperties); return new ModuleConfiguration(getModuleProperties(moduleName), subscriptionList); }
/** * Build a list of subscription by a particular module * * @param moduleName Name of the module * @param moduleProperties Set of properties which * @return A list of subscriptions by the module */ private List<Subscription> buildSubscriptionList(String moduleName, Properties moduleProperties) { // Get subscribed events Properties subscriptions = NotificationManagementUtils.getSubProperties(moduleName + "." + NotificationMgtConstants.Configs.SUBSCRIPTION, moduleProperties); List<Subscription> subscriptionList = new ArrayList<Subscription>(); Enumeration propertyNames = subscriptions.propertyNames(); // Iterate through events and build event objects while (propertyNames.hasMoreElements()) { String key = (String) propertyNames.nextElement(); String subscriptionName = (String) subscriptions.remove(key); // Read all the event properties starting from the event prefix Properties subscriptionProperties = NotificationManagementUtils.getPropertiesWithPrefix (moduleName + "." + NotificationMgtConstants.Configs.SUBSCRIPTION + "." + subscriptionName, moduleProperties); Subscription subscription = new Subscription(subscriptionName, subscriptionProperties); subscriptionList.add(subscription); } return subscriptionList; }
/** * This function builds the required configuration object for Notification sender and pass it * to the notification sender with the relevant event. * * @param operation Type or operation took place in user operation listener * @param username username of the subjected user for attribute change */ private void sendNotification(String operation, String username) { NotificationSender notificationSender = IdentityMgtServiceComponent.getNotificationSender(); if (notificationSender != null) { try { PublisherEvent event = new PublisherEvent(eventName); event.addEventProperty(operationLabel, operation); event.addEventProperty(usernameLabel, username); if (log.isDebugEnabled()) { log.debug("Invoking notification sender"); } notificationSender.invoke(event); } catch (NotificationManagementException e) { log.error("Error while sending notifications on user operations", e); } } else { log.error("No registered notification sender found. Notification sending aborted"); } } }
/** * Building per module configuration objects * * @param moduleName Name of the module * @return ModuleConfiguration object which has configurations for the given module name */ private ModuleConfiguration buildModuleConfigurations(String moduleName) { Properties moduleProperties = getModuleProperties(moduleName); List<Subscription> subscriptionList = buildSubscriptionList(moduleName, moduleProperties); return new ModuleConfiguration(getModuleProperties(moduleName), subscriptionList); }
@Override public void run() { if (log.isDebugEnabled()) { log.debug("Executing " + module.getModuleName() + " on event" + event. getEventName()); } try { module.sendMessage(event); } catch (NotificationManagementException e) { log.error("Error while invoking notification sending module " + module. getModuleName(), e); } } };
/** * Build a list of subscription by a particular module * * @param moduleName Name of the module * @param moduleProperties Set of properties which * @return A list of subscriptions by the module */ private List<Subscription> buildSubscriptionList(String moduleName, Properties moduleProperties) { // Get subscribed events Properties subscriptions = NotificationManagementUtils.getSubProperties(moduleName + "." + NotificationMgtConstants.Configs.SUBSCRIPTION, moduleProperties); List<Subscription> subscriptionList = new ArrayList<Subscription>(); Enumeration propertyNames = subscriptions.propertyNames(); // Iterate through events and build event objects while (propertyNames.hasMoreElements()) { String key = (String) propertyNames.nextElement(); String subscriptionName = (String) subscriptions.remove(key); // Read all the event properties starting from the event prefix Properties subscriptionProperties = NotificationManagementUtils.getPropertiesWithPrefix (moduleName + "." + NotificationMgtConstants.Configs.SUBSCRIPTION + "." + subscriptionName, moduleProperties); Subscription subscription = new Subscription(subscriptionName, subscriptionProperties); subscriptionList.add(subscription); } return subscriptionList; }
PublisherEvent event = new PublisherEvent(eventName); event.addEventProperty(NotificationConstants.TARGET_ID_PROPERTY_LABEL, statusHolder.getKey()); event.addEventProperty(NotificationConstants.USERNAME_PROPERTY_LABEL, statusHolder.getUser()); event.addEventProperty(NotificationConstants.TARGET_PROPERTY_LABEL, statusHolder.getTarget()); event.addEventProperty(NotificationConstants.ACTION_PROPERTY_LABEL, action); if (log.isDebugEnabled()) { log.debug("Invoking notification sender");
/** * Building per module configuration objects * * @param moduleName Name of the module * @return ModuleConfiguration object which has configurations for the given module name */ private ModuleConfiguration buildModuleConfigurations(String moduleName) { Properties moduleProperties = getModuleProperties(moduleName); List<Subscription> subscriptionList = buildSubscriptionList(moduleName, moduleProperties); return new ModuleConfiguration(getModuleProperties(moduleName), subscriptionList); }
@Override public void run() { if (log.isDebugEnabled()) { log.debug("Executing " + module.getModuleName() + " on event" + event. getEventName()); } try { module.sendMessage(event); } catch (NotificationManagementException e) { log.error("Error while invoking notification sending module " + module. getModuleName(), e); } } };
/** * Build a list of subscription by a particular module * * @param moduleName Name of the module * @param moduleProperties Set of properties which * @return A list of subscriptions by the module */ private List<Subscription> buildSubscriptionList(String moduleName, Properties moduleProperties) { // Get subscribed events Properties subscriptions = NotificationManagementUtils.getSubProperties(moduleName + "." + NotificationMgtConstants.Configs.SUBSCRIPTION, moduleProperties); List<Subscription> subscriptionList = new ArrayList<Subscription>(); Enumeration propertyNames = subscriptions.propertyNames(); // Iterate through events and build event objects while (propertyNames.hasMoreElements()) { String key = (String) propertyNames.nextElement(); String subscriptionName = (String) subscriptions.remove(key); // Read all the event properties starting from the event prefix Properties subscriptionProperties = NotificationManagementUtils.getPropertiesWithPrefix (moduleName + "." + NotificationMgtConstants.Configs.SUBSCRIPTION + "." + subscriptionName, moduleProperties); Subscription subscription = new Subscription(subscriptionName, subscriptionProperties); subscriptionList.add(subscription); } return subscriptionList; }
PublisherEvent event = new PublisherEvent(eventName); event.addEventProperty(NotificationConstants.TARGET_ID_PROPERTY_LABEL, statusHolder.getKey()); event.addEventProperty(NotificationConstants.USERNAME_PROPERTY_LABEL, statusHolder.getUser()); event.addEventProperty(NotificationConstants.TARGET_PROPERTY_LABEL, statusHolder.getTarget()); event.addEventProperty(NotificationConstants.ACTION_PROPERTY_LABEL, action); if (log.isDebugEnabled()) { log.debug("Invoking notification sender");
/** * Will register message sending modules dynamically. This method is used to bind the notification sending * modules in to msg mgt component * * @param module MessageSendingModule */ protected void addNotificationSendingModule(NotificationSendingModule module) throws MessageRemovedException { ModuleConfiguration moduleConfiguration; if (StringUtils.isEmpty(module.getModuleName())) { if (log.isDebugEnabled()) { log.debug("Cannot register module without a valid module name"); } return; } if (log.isDebugEnabled()) { log.debug("Registering a message sending module " + module.getModuleName()); } if (configBuilder != null) { moduleConfiguration = configBuilder.getModuleConfigurations(module.getModuleName()); } else { moduleConfiguration = new ModuleConfiguration(); } try { module.init(moduleConfiguration); notificationSendingModules.add(module); } catch (NotificationManagementException e) { log.error("Error while initializing Notification sending module " + module.getModuleName(), e); } }
/** * This method is called from all service consumers of this bundle, whenever messageSendingModules need to be * fired. This method will check whether the registered message sending modules can handle the event type and if * can, it will invoke sendMessage * * @param event Publisher event * @throws NotificationManagementException */ public void invoke(PublisherEvent event) throws NotificationManagementException { if (event == null) { throw new NotificationManagementException("No publisher event found to send notification"); } if (log.isDebugEnabled()) { log.debug("Adding event to the event queue " + event.getEventName()); } eventDistributionTask.addEventToQueue(event); }
PublisherEvent event = new PublisherEvent(eventName); event.addEventProperty(NotificationConstants.TARGET_ID_PROPERTY_LABEL, statusHolder.getKey()); event.addEventProperty(NotificationConstants.USERNAME_PROPERTY_LABEL, statusHolder.getUser()); event.addEventProperty(NotificationConstants.TARGET_PROPERTY_LABEL, statusHolder.getTarget()); event.addEventProperty(NotificationConstants.ACTION_PROPERTY_LABEL, action); if (log.isDebugEnabled()) { log.debug("Invoking notification sender");
moduleConfiguration = configBuilder.getModuleConfigurations(module.getModuleName()); } else { moduleConfiguration = new ModuleConfiguration();
/** * This method is called from all service consumers of this bundle, whenever messageSendingModules need to be * fired. This method will check whether the registered message sending modules can handle the event type and if * can, it will invoke sendMessage * * @param event Publisher event * @throws NotificationManagementException */ public void invoke(PublisherEvent event) throws NotificationManagementException { if (event == null) { throw new NotificationManagementException("No publisher event found to send notification"); } if (log.isDebugEnabled()) { log.debug("Adding event to the event queue " + event.getEventName()); } eventDistributionTask.addEventToQueue(event); }
moduleConfiguration = configBuilder.getModuleConfigurations(module.getModuleName()); } else { moduleConfiguration = new ModuleConfiguration();
/** * This method is called from all service consumers of this bundle, whenever messageSendingModules need to be * fired. This method will check whether the registered message sending modules can handle the event type and if * can, it will invoke sendMessage * * @param event Publisher event * @throws NotificationManagementException */ public void invoke(PublisherEvent event) throws NotificationManagementException { if (event == null) { throw new NotificationManagementException("No publisher event found to send notification"); } if (log.isDebugEnabled()) { log.debug("Adding event to the event queue " + event.getEventName()); } eventDistributionTask.addEventToQueue(event); }