private Group getBackingGroup(String groupName) { try { return m_groupManager.getGroup(groupName); } catch (IOException e) { throw new WebRolesException("Error reading groups.xml config file", e); } }
/** {@inheritDoc} */ @Override public long groupNextOnDuty(String group, Calendar time) { try { return m_groupManager.groupNextOnDuty(group, time); } catch (Throwable e) { throw CONFIG_OBJECT_EXCEPTION_TRANSLATOR.translate("getting next on duty time for group '" + group + "' after " + time, e); } }
/** {@inheritDoc} */ @Override public boolean hasGroup(String name) { try { return m_groupManager.hasGroup(name); } catch (Throwable e) { throw CONFIG_OBJECT_EXCEPTION_TRANSLATOR.translate("getting group '" + name + "'", e); } }
/** * <p>getUserSchedulesForRole</p> * * @param userId a {@link java.lang.String} object. * @param roleId a {@link java.lang.String} object. * @return a {@link java.util.List} object. * @throws java.io.IOException if any. */ public List<Schedule> getUserSchedulesForRole(String userId, String roleId) throws IOException { update(); List<Schedule> scheds = new ArrayList<Schedule>(); for (Schedule sched : getRole(roleId).getSchedules()) { if (userId.equals(sched.getName())) { scheds.add(sched); } } return scheds; }
/** * Returns a boolean indicating if the group name appears in the xml file * * @return true if the group exists in the xml file, false otherwise * @param groupName a {@link java.lang.String} object. * @throws java.io.IOException if any. */ public boolean hasGroup(String groupName) throws IOException { update(); return m_groups.containsKey(groupName); }
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); }
/** * <p>isUserScheduledForRole</p> * * @param userId a {@link java.lang.String} object. * @param roleId a {@link java.lang.String} object. * @param time a {@link java.util.Date} object. * @return a boolean. * @throws java.io.IOException if any. */ public boolean isUserScheduledForRole(String userId, String roleId, Date time) throws IOException { update(); for (Schedule sched : getUserSchedulesForRole(userId, roleId)) { if (BasicScheduleUtils.isTimeInSchedule(time, BasicScheduleUtils.getGroupSchedule(sched))) { return true; } } // if no user is scheduled then the supervisor is schedule by default Role role = getRole(roleId); if (userId.equals(role.getSupervisor())) { for (Schedule sched : role.getSchedules()) { if (BasicScheduleUtils.isTimeInSchedule(time, BasicScheduleUtils.getGroupSchedule(sched))) { // we found another scheduled user return false; } } return true; } return false; }
/** * */ 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; }
m_groupManager.update(); m_groupManager.deleteUser(name);
m_groupManager.update(); m_groupManager.renameUser(oldName, newName);
public synchronized void save(final OnmsGroup group) throws Exception { Group xmlGroup = getGroup(group.getName()); if (xmlGroup == null) { xmlGroup = new Group(); xmlGroup.setName(group.getName()); } xmlGroup.setComments(group.getComments()); xmlGroup.setUsers(group.getUsers()); saveGroup(group.getName(), xmlGroup); }
/** {@inheritDoc} */ @Override public void deleteRole(String roleName) { try { m_groupManager.deleteRole(roleName); } catch (Throwable e) { throw new WebRolesException("Error deleting role "+roleName+". "+e.getMessage(), e); } }
/** {@inheritDoc} */ @Override public List<Group> findGroupsForUser(String user) { return m_groupManager.findGroupsForUser(user); }
/** {@inheritDoc} */ @Override public void deleteGroup(String name) { try { m_groupManager.deleteGroup(name); } catch (Throwable e) { throw CONFIG_OBJECT_EXCEPTION_TRANSLATOR.translate("deleting group '" + name + "'", e); } }
/** {@inheritDoc} */ @Override public void deleteUser(String name) { try { m_groupManager.deleteUser(name); } catch (Throwable e) { throw CONFIG_OBJECT_EXCEPTION_TRANSLATOR.translate("deleting user '" + name + "'", e); } }
/** * <p>getGroupNames</p> * * @return a {@link java.util.List} object. */ @Override public List<String> getGroupNames() { try { return m_groupManager.getGroupNames(); } catch (Throwable e) { throw CONFIG_OBJECT_EXCEPTION_TRANSLATOR.translate("getting group names", e); } }
private void initializeGroupsAndRoles(Groupinfo groupinfo) { List<Group> groups = groupinfo.getGroups(); m_groups = new LinkedHashMap<String, Group>(); m_oldHeader = groupinfo.getHeader(); for (Group curGroup : groups) { m_groups.put(curGroup.getName(), curGroup); } buildDutySchedules(m_groups); if (groupinfo.getRoles().size() > 0) { m_roles = new LinkedHashMap<String, Role>(); for (final Role role : groupinfo.getRoles()) { m_roles.put(role.getName(), role); } } }
/** * <p>userHasRole</p> * * @param userId a {@link java.lang.String} object. * @param roleid a {@link java.lang.String} object. * @return a boolean. * @throws java.io.IOException if any. */ public boolean userHasRole(String userId, String roleid) throws IOException { update(); for (Schedule sched : getRole(roleid).getSchedules()) { if (userId.equals(sched.getName())) { return true; } } return false; }
/** * Get a group using its name * * @param name * the name of the group to return * @return Group, the group specified by name * @throws java.io.IOException if any. */ public Group getGroup(String name) throws IOException { update(); return m_groups.get(name); }
/** {@inheritDoc} */ @Override public void deleteRole(String name) { try { m_groupManager.deleteRole(name); } catch (Throwable e) { throw CONFIG_OBJECT_EXCEPTION_TRANSLATOR.translate("deleting role '" + name + "'", e); } }