Package org.opennms.netmgt.config
Class GroupManager
- java.lang.Object
-
- org.opennms.netmgt.config.GroupManager
-
- All Implemented Interfaces:
GroupConfig
- Direct Known Subclasses:
GroupFactory,MockGroupManager
public abstract class GroupManager extends Object implements GroupConfig
Abstract GroupManager class.
- Author:
- David Hustace, Matt Brozowski, Bill Ayres, DJ Gregor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGroupManager.OnmsGroupListMapperstatic classGroupManager.OnmsGroupMapper
-
Field Summary
Fields Modifier and Type Field Description protected static Map<String,List<DutySchedule>>m_dutySchedulesThe duty schedules for each group
-
Constructor Summary
Constructors Constructor Description GroupManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddeleteGroup(String name)Removes the group from the list of groups.voiddeleteRole(String name)deleteRolevoiddeleteUser(String name)Removes the user from the list of groups.List<Group>findGroupsForUser(String user)findGroupsForUserGroupgetGroup(String name)Get a group using its nameList<String>getGroupNames()getGroupNamesMap<String,Group>getGroups()Get the groupsOnmsGroupgetOnmsGroup(String groupName)getOnmsGroupOnmsGroupListgetOnmsGroupList()getOnmsGroupListRolegetRole(String roleName)getRoleString[]getRoleNames()getRoleNamesCollection<Role>getRoles()getRolesOwnedIntervalSequencegetRoleScheduleEntries(String roleid, Date start, Date end)getRoleScheduleEntriesList<Schedule>getSchedulesForRoleAt(String roleId, Date time)getSchedulesForRoleAtList<Schedule>getUserSchedulesForRole(String userId, String roleId)getUserSchedulesForRolelonggroupNextOnDuty(String group, Calendar time)Determines when a group is next on duty.booleanhasGroup(String groupName)Returns a boolean indicating if the group name appears in the xml filebooleanisGroupOnDuty(String group, Calendar time)Determines if a group is on duty at a given time.booleanisUserScheduledForRole(String userId, String roleId, Date time)isUserScheduledForRoleprotected voidparseXml(InputStream stream)parseXmlvoidrenameGroup(String oldName, String newName)Renames the group from the list of groups.voidrenameUser(String oldName, String newName)When this method is called group name is changed, so also is the group name belonging to the view.voidsave(OnmsGroup group)savevoidsaveGroup(String name, Group details)Adds a new user and overwrites the "groups.xml"voidsaveGroups()saveGroupsvoidsaveRole(Role role)saveRoleprotected abstract voidsaveXml(String data)saveXmlvoidsetGroups(Map<String,Group> grp)Set the groups dataabstract voidupdate()updatebooleanuserHasRole(String userId, String roleid)userHasRole
-
-
-
Field Detail
-
m_dutySchedules
protected static Map<String,List<DutySchedule>> m_dutySchedules
The duty schedules for each group
-
-
Method Detail
-
parseXml
protected void parseXml(InputStream stream) throws IOException
parseXml
- Parameters:
stream- aInputStreamobject.- Throws:
IOException
-
setGroups
public void setGroups(Map<String,Group> grp)
Set the groups data- Specified by:
setGroupsin interfaceGroupConfig- Parameters:
grp- aMapobject.
-
getGroups
public Map<String,Group> getGroups() throws IOException
Get the groups- Specified by:
getGroupsin interfaceGroupConfig- Returns:
- a
Mapobject. - Throws:
IOException- if any.
-
getOnmsGroupList
public OnmsGroupList getOnmsGroupList() throws IOException
Description copied from interface:GroupConfiggetOnmsGroupList
- Specified by:
getOnmsGroupListin interfaceGroupConfig- Returns:
- an OnmsGroupList
- Throws:
IOException
-
getOnmsGroup
public OnmsGroup getOnmsGroup(String groupName) throws IOException
Description copied from interface:GroupConfiggetOnmsGroup
- Specified by:
getOnmsGroupin interfaceGroupConfig- Returns:
- an OnmsGroup
- Throws:
IOException
-
save
public void save(OnmsGroup group) throws Exception
Description copied from interface:GroupConfigsave
- Specified by:
savein interfaceGroupConfig- Throws:
Exception
-
update
public abstract void update() throws IOExceptionupdate
- Throws:
IOException- if any.
-
hasGroup
public boolean hasGroup(String groupName) throws IOException
Returns a boolean indicating if the group name appears in the xml file- Specified by:
hasGroupin interfaceGroupConfig- Parameters:
groupName- aStringobject.- Returns:
- true if the group exists in the xml file, false otherwise
- Throws:
IOException- if any.
-
getGroupNames
public List<String> getGroupNames() throws IOException
getGroupNames
- Specified by:
getGroupNamesin interfaceGroupConfig- Returns:
- a
Listobject. - Throws:
IOException- if any.
-
getGroup
public Group getGroup(String name) throws IOException
Get a group using its name- Specified by:
getGroupin interfaceGroupConfig- Parameters:
name- the name of the group to return- Returns:
- Group, the group specified by name
- Throws:
IOException- if any.
-
saveGroups
public void saveGroups() throws ExceptionsaveGroups
- Specified by:
saveGroupsin interfaceGroupConfig- Throws:
Exception- if any.
-
isGroupOnDuty
public boolean isGroupOnDuty(String group, Calendar time) throws IOException
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.- Specified by:
isGroupOnDutyin interfaceGroupConfig- Parameters:
group- the group whose duty schedule we wanttime- the time to check for a duty schedule- Returns:
- boolean, true if the group is on duty, false otherwise.
- Throws:
IOException- if any.
-
groupNextOnDuty
public long groupNextOnDuty(String group, Calendar time) throws IOException
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.- Specified by:
groupNextOnDutyin interfaceGroupConfig- Parameters:
group- the group whose duty schedule we wanttime- the time to check for a duty schedule- Returns:
- long, the time in milliseconds until the group is next on duty
- Throws:
IOException- if any.
-
saveXml
protected abstract void saveXml(String data) throws IOException
saveXml
- Parameters:
data- aStringobject.- Throws:
IOException- if any.
-
saveGroup
public void saveGroup(String name, Group details) throws Exception
Adds a new user and overwrites the "groups.xml"- Specified by:
saveGroupin interfaceGroupConfig- Parameters:
name- aStringobject.details- aGroupobject.- Throws:
Exception- if any.
-
saveRole
public void saveRole(Role role) throws Exception
saveRole
- Specified by:
saveRolein interfaceGroupConfig- Parameters:
role- aRoleobject.- Throws:
Exception- if any.
-
deleteUser
public void deleteUser(String name) throws Exception
Removes the user from the list of groups. Then overwrites to the "groups.xml"- Specified by:
deleteUserin interfaceGroupConfig- Parameters:
name- aStringobject.- Throws:
Exception- if any.
-
deleteGroup
public void deleteGroup(String name) throws Exception
Removes the group from the list of groups. Then overwrites to the "groups.xml"- Specified by:
deleteGroupin interfaceGroupConfig- Parameters:
name- aStringobject.- Throws:
Exception- if any.
-
deleteRole
public void deleteRole(String name) throws Exception
deleteRole
- Specified by:
deleteRolein interfaceGroupConfig- Parameters:
name- aStringobject.- Throws:
Exception- if any.
-
renameGroup
public void renameGroup(String oldName, String newName) throws Exception
Renames the group from the list of groups. Then overwrites to the "groups.xml"- Specified by:
renameGroupin interfaceGroupConfig- Parameters:
oldName- aStringobject.newName- aStringobject.- Throws:
Exception- if any.
-
renameUser
public void renameUser(String oldName, String newName) throws Exception
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- Specified by:
renameUserin interfaceGroupConfig- Parameters:
oldName- aStringobject.newName- aStringobject.- Throws:
Exception- if any.
-
getRoleNames
public String[] getRoleNames()
getRoleNames
- Specified by:
getRoleNamesin interfaceGroupConfig- Returns:
- an array of
Stringobjects.
-
getRoles
public Collection<Role> getRoles()
getRoles
- Specified by:
getRolesin interfaceGroupConfig- Returns:
- a
Collectionobject.
-
getRole
public Role getRole(String roleName)
getRole
- Specified by:
getRolein interfaceGroupConfig- Parameters:
roleName- aStringobject.- Returns:
- a
Roleobject.
-
userHasRole
public boolean userHasRole(String userId, String roleid) throws IOException
userHasRole
- Specified by:
userHasRolein interfaceGroupConfig- Parameters:
userId- aStringobject.roleid- aStringobject.- Returns:
- a boolean.
- Throws:
IOException- if any.
-
getSchedulesForRoleAt
public List<Schedule> getSchedulesForRoleAt(String roleId, Date time) throws IOException
getSchedulesForRoleAt
- Specified by:
getSchedulesForRoleAtin interfaceGroupConfig- Parameters:
roleId- aStringobject.time- aDateobject.- Returns:
- a
Listobject. - Throws:
IOException- if any.
-
getUserSchedulesForRole
public List<Schedule> getUserSchedulesForRole(String userId, String roleId) throws IOException
getUserSchedulesForRole
- Specified by:
getUserSchedulesForRolein interfaceGroupConfig- Parameters:
userId- aStringobject.roleId- aStringobject.- Returns:
- a
Listobject. - Throws:
IOException- if any.
-
isUserScheduledForRole
public boolean isUserScheduledForRole(String userId, String roleId, Date time) throws IOException
isUserScheduledForRole
- Specified by:
isUserScheduledForRolein interfaceGroupConfig- Parameters:
userId- aStringobject.roleId- aStringobject.time- aDateobject.- Returns:
- a boolean.
- Throws:
IOException- if any.
-
getRoleScheduleEntries
public OwnedIntervalSequence getRoleScheduleEntries(String roleid, Date start, Date end) throws IOException
getRoleScheduleEntries
- Specified by:
getRoleScheduleEntriesin interfaceGroupConfig- Parameters:
roleid- aStringobject.start- aDateobject.end- aDateobject.- Returns:
- a
OwnedIntervalSequenceobject. - Throws:
IOException- if any.
-
findGroupsForUser
public List<Group> findGroupsForUser(String user)
findGroupsForUser
- Specified by:
findGroupsForUserin interfaceGroupConfig- Parameters:
user- aStringobject.- Returns:
- a
Listobject.
-
-