/** * <p>getTargetCommands</p> * * @param path a {@link org.opennms.netmgt.config.destinationPaths.Path} object. * @param index a int. * @param target a {@link java.lang.String} object. * @return a {@link java.util.Collection} object. * @throws java.io.IOException if any. */ public Collection<String> getTargetCommands(Path path, int index, String target) throws IOException { update(); Target[] targets = getTargetList(index, path); for (int i = 0; i < targets.length; i++) { if (targets[i].getName().equals(target)) return targets[i].getCommands(); } // default null value if target isn't found in Path return null; }
String interval = (targets[i].getInterval().orElse(Target.DEFAULT_INTERVAL)); String targetName = targets[i].getName(); String autoNotify = null; if (targets[i].getAutoNotify().isPresent()) { autoNotify = targets[i].getAutoNotify().get(); if(autoNotify.equalsIgnoreCase("on")) { autoNotify = "Y"; tasks = makeGroupTasks(startTime, params, noticeId, targetName, targets[i].getCommands().toArray(new String[0]), targetSiblings, autoNotify, TimeConverter.convertToMillis(interval)); } else if (getUserManager().hasOnCallRole(targetName)) { tasks = makeRoleTasks(startTime, params, noticeId, targetName, targets[i].getCommands().toArray(new String[0]), targetSiblings, autoNotify, TimeConverter.convertToMillis(interval)); } else if (getUserManager().hasUser(targetName)) { NotificationTask[] userTasks = { makeUserTask(startTime, params, noticeId, targetName, targets[i].getCommands().toArray(new String[0]), targetSiblings, autoNotify) }; tasks = userTasks; } else if (targetName.indexOf('@') > -1) {
/** * <p>pathHasTarget</p> * * @param path a {@link org.opennms.netmgt.config.destinationPaths.Path} object. * @param target a {@link java.lang.String} object. * @return a boolean. * @throws java.io.IOException if any. */ public boolean pathHasTarget(Path path, String target) throws IOException { update(); for (Target curTarget : path.getTargets()) { if (curTarget.getName().equals(target)) return true; } // default false value if target isn't found return false; }
protected long computeInterval() throws IOException { final String interval = m_destinationPathManager.getPath("Intervals").getTargets().get(0).getInterval().orElse(Target.DEFAULT_INTERVAL); return TimeConverter.convertToMillis(interval); }
/** * */ private int getUsersInTarget(Target target) throws IOException { int count = 0; String targetName = target.getName(); if (getGroupManager().hasGroup(targetName)) { count = getGroupManager().getGroup(targetName).getUsers().size(); } else if (getUserManager().hasOnCallRole(targetName)) { count = getUserManager().countUsersWithRole(targetName); } else if (getUserManager().hasUser(targetName)) { count = 1; } else if (targetName.indexOf('@') > -1) { count = 1; } return count; }