private List<String> getUsers(Group group) { return group.getUsers(); } }
/** * <p>findGroupsForUser</p> * * @param user a {@link java.lang.String} object. * @return a {@link java.util.List} object. */ public List<Group> findGroupsForUser(String user) { List<Group> groups = new ArrayList<Group>(); for (Group group : m_groups.values()) { if (group.getUsers().contains(user)) { groups.add(group); } } return groups; }
@Override public OnmsUser getUserForGroup(String groupName, String userName) { Group group = getGroup(groupName); if (group != null && group.getUsers().contains(userName)) { try { return m_userDao.getOnmsUser(userName); } catch (IOException e) { Log.error("could not load user", e); //ignore } } return null; // group or user name does not exist }
@Override public OnmsUser getUserForGroup(String groupName, String userName) { Group group = getGroup(groupName); if (group != null && group.getUsers().contains(userName)) { try { return m_userDao.getOnmsUser(userName); } catch (IOException e) { Log.error("could not load user", e); //ignore } } return null; // group or user name does not exist }
for(ListIterator<String> userList = group.getUsers().listIterator(); userList.hasNext();){ String name = userList.next();
protected Collection<String> getUsersInGroup(String groupName) throws Exception { Group group = m_groupManager.getGroup(groupName); String[] users = group.getUsers().toArray(new String[0]); return Arrays.asList(users); }
public OnmsGroup map(Group inputGroup) { if (inputGroup == null) return null; final OnmsGroup xmlGroup = new OnmsGroup(inputGroup.getName()); xmlGroup.setComments(inputGroup.getComments().orElse(null)); xmlGroup.setUsers(inputGroup.getUsers()); return xmlGroup; }
@Override public OnmsUserList getUsersOfGroup(String groupName) { Group group = getGroup(groupName); OnmsUserList userCollection = new OnmsUserList(); if (group != null) { for (String eachUser : group.getUsers()) { OnmsUser onmsUser; try { onmsUser = m_userDao.getOnmsUser(eachUser); if (onmsUser == null) continue; userCollection.add(onmsUser); } catch (IOException e) { Log.error("could not load user", e); //ignore } } } return userCollection; }
NotificationTask[] makeGroupTasks(long startTime, Map<String, String> params, int noticeId, String targetName, String[] command, List<NotificationTask> targetSiblings, String autoNotify, long interval) throws IOException { Group group = getGroupManager().getGroup(targetName); Calendar startCal = Calendar.getInstance(); startCal.setTimeInMillis(startTime); long next = getGroupManager().groupNextOnDuty(group.getName(), startCal); // it the group is not on duty if (next < 0) { LOG.debug("The group {} is not scheduled to come back on duty. No notification will be sent to this group.", group.getName()); return null; } LOG.debug("The group {} is on duty in {} millisec.", group.getName(), next); String[] users = group.getUsers().toArray(new String[0]); // There are no users in the group if (users == null || users.length == 0) { LOG.debug("Not sending notice, no users specified for group {}", group.getName()); return null; } return constructTasksFromUserList(users, startTime, next, params, noticeId, command, targetSiblings, autoNotify, interval); }
@Override public OnmsUserList getUsersOfGroup(String groupName) { Group group = getGroup(groupName); OnmsUserList userCollection = new OnmsUserList(); if (group != null) { for (String eachUser : group.getUsers()) { OnmsUser onmsUser; try { onmsUser = m_userDao.getOnmsUser(eachUser); if (onmsUser == null) continue; userCollection.add(onmsUser); } catch (IOException e) { Log.error("could not load user", e); //ignore } } } return userCollection; }
protected long anticipateNotificationsForGroup(String subject, String textMsg, String groupName, long startTime, long interval) throws Exception { Group group = m_groupManager.getGroup(groupName); String[] users = group.getUsers().toArray(new String[0]); return anticipateNotificationsForUsers(users, subject, textMsg, startTime, 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; }