コード例 #1
0
ファイル: GroupManager.java プロジェクト: Eising/opennms
  /**
   * When this method is called group name is changed, so also is the group name belonging to the
   * view. Also overwrites the "groups.xml" file
   *
   * @param oldName a {@link java.lang.String} object.
   * @param newName a {@link java.lang.String} object.
   * @throws java.lang.Exception if any.
   */
  public synchronized void renameUser(String oldName, String newName) throws Exception {
    // Get the old data
    if (oldName == null || newName == null || oldName == "" || newName == "") {
      throw new Exception("Group Factory: Rename user.. no value ");
    } else {
      Map<String, Group> map = new LinkedHashMap<String, Group>();

      for (Group group : m_groups.values()) {
        for (ListIterator<String> userList = group.getUserCollection().listIterator();
            userList.hasNext(); ) {
          String name = userList.next();

          if (name.equals(oldName)) {
            userList.set(newName);
          }
        }
        map.put(group.getName(), group);
      }

      m_groups.clear();
      m_groups.putAll(map);

      for (Role role : m_roles.values()) {
        for (Schedule sched : role.getScheduleCollection()) {
          if (oldName.equals(sched.getName())) {
            sched.setName(newName);
          }
        }
      }

      saveGroups();
    }
  }
コード例 #2
0
ファイル: GroupManager.java プロジェクト: Eising/opennms
  /**
   * deleteRole
   *
   * @param name a {@link java.lang.String} object.
   * @throws java.lang.Exception if any.
   */
  public void deleteRole(String name) throws Exception {
    if (name != null && !name.equals("")) {
      if (m_roles.containsKey(name)) {
        m_roles.remove(name);
      } else throw new Exception("GroupFacotry:deleteRole Role doesn't exist: " + name);
    } else throw new Exception("GroupFactory:deleteRole Invalid role name: " + name);

    saveGroups();
  }
コード例 #3
0
ファイル: GroupManager.java プロジェクト: Eising/opennms
  /**
   * Adds a new user and overwrites the "groups.xml"
   *
   * @param name a {@link java.lang.String} object.
   * @param details a {@link org.opennms.netmgt.config.groups.Group} object.
   * @throws java.lang.Exception if any.
   */
  public synchronized void saveGroup(String name, Group details) throws Exception {
    if (name == null || details == null) {
      throw new Exception("GroupFactory:saveGroup  null");
    } else {
      m_groups.put(name, details);
    }

    saveGroups();
  }
コード例 #4
0
ファイル: GroupManager.java プロジェクト: Eising/opennms
 /**
  * Renames the group from the list of groups. Then overwrites to the "groups.xml"
  *
  * @param oldName a {@link java.lang.String} object.
  * @param newName a {@link java.lang.String} object.
  * @throws java.lang.Exception if any.
  */
 public synchronized void renameGroup(String oldName, String newName) throws Exception {
   if (oldName != null && !oldName.equals("")) {
     if (m_groups.containsKey(oldName)) {
       Group grp = m_groups.remove(oldName);
       grp.setName(newName);
       m_groups.put(newName, grp);
     } else {
       throw new Exception("GroupFactory.renameGroup: Group doesn't exist: " + oldName);
     }
     // Save into groups.xml
     saveGroups();
   }
 }
コード例 #5
0
ファイル: GroupManager.java プロジェクト: Eising/opennms
 /**
  * Removes the group from the list of groups. Then overwrites to the "groups.xml"
  *
  * @param name a {@link java.lang.String} object.
  * @throws java.lang.Exception if any.
  */
 public synchronized void deleteGroup(String name) throws Exception {
   // Check if the group exists
   if (name != null && !name.equals("")) {
     if (m_groups.containsKey(name)) {
       // Remove the group.
       m_groups.remove(name);
     } else throw new Exception("GroupFactory:delete Group doesnt exist:" + name);
   } else {
     throw new Exception("GroupFactory:delete Invalid user group:" + name);
   }
   // Saves into "groups.xml" file
   saveGroups();
 }
コード例 #6
0
ファイル: GroupManager.java プロジェクト: Eising/opennms
  /**
   * Removes the user from the list of groups. Then overwrites to the "groups.xml"
   *
   * @param name a {@link java.lang.String} object.
   * @throws java.lang.Exception if any.
   */
  public synchronized void deleteUser(String name) throws Exception {
    // Check if the user exists
    if (name != null && !name.equals("")) {
      // Remove the user in the group.
      for (Group group : m_groups.values()) {
        group.removeUser(name);
      }

      for (Role role : m_roles.values()) {
        Iterator<Schedule> s = role.getScheduleCollection().iterator();
        while (s.hasNext()) {
          Schedule sched = s.next();
          if (name.equals(sched.getName())) {
            s.remove();
          }
        }
      }
    } else {
      throw new Exception("GroupFactory:delete Invalid user name:" + name);
    }

    // Saves into "groups.xml" file
    saveGroups();
  }
コード例 #7
0
ファイル: GroupManager.java プロジェクト: Eising/opennms
 /**
  * saveRole
  *
  * @param role a {@link org.opennms.netmgt.config.groups.Role} object.
  * @throws java.lang.Exception if any.
  */
 public void saveRole(Role role) throws Exception {
   m_roles.put(role.getName(), role);
   saveGroups();
 }