/** * */ 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; }
/** * */ 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; }