/** * Get the groups * * @return a {@link java.util.Map} object. * @throws java.io.IOException if any. */ public Map<String, Group> getGroups() throws IOException { update(); return Collections.unmodifiableMap(m_groups); }
/** * 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); }
/** * 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); }
/** * <p>getGroupNames</p> * * @return a {@link java.util.List} object. * @throws java.io.IOException if any. */ public List<String> getGroupNames() throws IOException { update(); return new ArrayList<String>(m_groups.keySet()); }
/** * Determines if a group is on duty at a given time. If a group has no duty schedules * listed in the configuration file, that group is assumed to always be on duty. * * @param group the group whose duty schedule we want * @param time the time to check for a duty schedule * @return boolean, true if the group is on duty, false otherwise. * @throws java.io.IOException if any. */ public boolean isGroupOnDuty(String group, Calendar time) throws IOException { update(); //if the group has no duty schedules then it is on duty if (!m_dutySchedules.containsKey(group)) { return true; } List<DutySchedule> dutySchedules = m_dutySchedules.get(group); for (DutySchedule curSchedule : dutySchedules) { if (curSchedule.isInSchedule(time)) { return true; } } return false; }
/** * Determines when a group is next on duty. If a group has no duty schedules * listed in the configuration file, that group is assumed to always be on duty. * * @param group the group whose duty schedule we want * @param time the time to check for a duty schedule * @return long, the time in milliseconds until the group is next on duty * @throws java.io.IOException if any. */ public long groupNextOnDuty(String group, Calendar time) throws IOException { long next = -1; update(); //if the group has no duty schedules then it is on duty if (!m_dutySchedules.containsKey(group)) { return 0; } List<DutySchedule> dutySchedules = m_dutySchedules.get(group); for (int i = 0; i < dutySchedules.size(); i++) { DutySchedule curSchedule = dutySchedules.get(i); long tempnext = curSchedule.nextInSchedule(time); if( tempnext < next || next == -1 ) { LOG.debug("isGroupOnDuty: On duty in {} millisec from schedule {}", i, tempnext); next = tempnext; } } return next; }
m_groupManager.update();
/** * <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; }
/** * <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; }
m_groupManager.update();
/** * <p>getSchedulesForRoleAt</p> * * @param roleId a {@link java.lang.String} object. * @param time a {@link java.util.Date} object. * @return a {@link java.util.List} object. * @throws java.io.IOException if any. */ public List<Schedule> getSchedulesForRoleAt(String roleId, Date time) throws IOException { update(); List<Schedule> schedules = new ArrayList<Schedule>(); for (Schedule sched : getRole(roleId).getSchedules()) { if (BasicScheduleUtils.isTimeInSchedule(time, BasicScheduleUtils.getGroupSchedule(sched))) { schedules.add(sched); } } return schedules; }
/** * <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; }
try { m_userManager.update(); m_groupManager.update(); m_notificationManager.update(); m_destinationPathManager.update();