Example #1
0
 ManagedRole(Role role) {
   super(role.getName());
   m_role = role;
   super.setDescription(role.getDescription());
   super.setDefaultUser(getWebUser(role.getSupervisor()));
   super.setMembershipGroup(getWebGroup(role.getMembershipGroup()));
 }
Example #2
0
  /**
   * isUserScheduledForRole
   *
   * @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 org.exolab.castor.xml.MarshalException if any.
   * @throws org.exolab.castor.xml.ValidationException if any.
   * @throws java.io.IOException if any.
   */
  public boolean isUserScheduledForRole(String userId, String roleId, Date time)
      throws MarshalException, ValidationException, 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.getScheduleCollection()) {
        if (BasicScheduleUtils.isTimeInSchedule(time, BasicScheduleUtils.getGroupSchedule(sched))) {
          // we found another scheduled user
          return false;
        }
      }
      return true;
    }
    return false;
  }
Example #3
0
  /**
   * getRoleScheduleEntries
   *
   * @param roleid a {@link java.lang.String} object.
   * @param start a {@link java.util.Date} object.
   * @param end a {@link java.util.Date} object.
   * @return a {@link org.opennms.core.utils.OwnedIntervalSequence} object.
   * @throws org.exolab.castor.xml.MarshalException if any.
   * @throws org.exolab.castor.xml.ValidationException if any.
   * @throws java.io.IOException if any.
   */
  public OwnedIntervalSequence getRoleScheduleEntries(String roleid, Date start, Date end)
      throws MarshalException, ValidationException, IOException {
    update();

    OwnedIntervalSequence schedEntries = new OwnedIntervalSequence();
    Role role = getRole(roleid);
    for (int i = 0; i < role.getScheduleCount(); i++) {
      Schedule sched = (Schedule) role.getSchedule(i);
      Owner owner = new Owner(roleid, sched.getName(), i);
      schedEntries.addAll(
          BasicScheduleUtils.getIntervalsCovering(
              start, end, BasicScheduleUtils.getGroupSchedule(sched), owner));
    }

    OwnedIntervalSequence defaultEntries = new OwnedIntervalSequence(new OwnedInterval(start, end));
    defaultEntries.removeAll(schedEntries);
    Owner supervisor = new Owner(roleid, role.getSupervisor());
    for (Iterator<OwnedInterval> it = defaultEntries.iterator(); it.hasNext(); ) {
      OwnedInterval interval = it.next();
      interval.addOwner(supervisor);
    }
    schedEntries.addAll(defaultEntries);
    return schedEntries;
  }