/** * 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(); }
/** * <p>saveGroups</p> */ @Override public void saveGroups() { try { m_groupManager.saveGroups(); } catch (Throwable e) { throw CONFIG_OBJECT_EXCEPTION_TRANSLATOR.translate("saving groups", e); } }
/** * <p>saveRole</p> * * @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(); }
/** * <p>deleteRole</p> * * @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(); }
/** * 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(); }
/** * 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(); } }
m_groupManager.saveGroups(); } else { m_groupManager.saveRole(role);