/** * Populate the internal list of notification commands from an XML file. * * @param reader contains the XML file to be parsed * @throws IOException */ protected void parseXML(InputStream stream) throws IOException { final NotificationCommands config; try (final Reader reader = new InputStreamReader(stream)) { config = JaxbUtils.unmarshal(NotificationCommands.class, reader); } Map<String, Command> commands = new HashMap<String, Command>(); for (Command curCommand : getCommandsFromConfig(config)) { if (curCommand != null && curCommand.getName() != null) { commands.put(curCommand.getName(), curCommand); } else { LOG.warn("invalid notification command: {}", curCommand); } } m_commands = commands; }
/** * */ NotificationTask makeUserTask(long sendTime, Map<String, String> parameters, int noticeId, String targetName, String[] commandList, List<NotificationTask> siblings, String autoNotify) throws IOException { NotificationTask task = null; task = new NotificationTask(getNotificationManager(), getUserManager(), sendTime, parameters, siblings, autoNotify, m_notificationTaskExecutor); User user = getUserManager().getUser(targetName); if (user == null) { LOG.error("user {} is not a valid user, not adding this user to escalation thread", targetName); return null; } Command[] commands = new Command[commandList.length]; for (int i = 0; i < commandList.length; i++) { commands[i] = getNotificationCommandManager().getCommand(commandList[i]); if (commands[i] != null && commands[i].getContactType().isPresent()) { if (! userHasContactType(user, commands[i].getContactType().get())) { LOG.warn("User {} lacks contact of type {} which is required for notification command {} on notice #{}. Scheduling task anyway.", user.getUserId(), commands[i].getContactType().get(), commands[i].getName(), noticeId); } } } task.setUser(user); task.setCommands(commands); task.setNoticeId(noticeId); task.setAutoNotify(autoNotify); return task; }
m_notificationManager.update(); m_destinationPathManager.update(); m_notificationCommandManager.update(); ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, getName()); ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Notifd");
/** * */ NotificationTask makeEmailTask(long sendTime, Map<String, String> parameters, int noticeId, String address, String[] commandList, List<NotificationTask> siblings, String autoNotify) throws IOException { NotificationTask task = null; task = new NotificationTask(getNotificationManager(), getUserManager(), sendTime, parameters, siblings, autoNotify, m_notificationTaskExecutor); User user = new User(); user.setUserId(address); Contact contact = new Contact(); contact.setType("email"); LOG.debug("email address = {}, using contact type {}", address, contact.getType()); contact.setInfo(address); user.addContact(contact); Command[] commands = new Command[commandList.length]; for (int i = 0; i < commandList.length; i++) { commands[i] = getNotificationCommandManager().getCommand(commandList[i]); } task.setUser(user); task.setCommands(commands); task.setNoticeId(noticeId); task.setAutoNotify(autoNotify); return task; }