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 java.lang.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 class
GroupManager.OnmsGroupListMapper
static class
GroupManager.OnmsGroupMapper
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,java.util.List<DutySchedule>>
m_dutySchedules
The 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 void
deleteGroup(java.lang.String name)
Removes the group from the list of groups.void
deleteRole(java.lang.String name)
deleteRolevoid
deleteUser(java.lang.String name)
Removes the user from the list of groups.java.util.List<Group>
findGroupsForUser(java.lang.String user)
findGroupsForUserGroup
getGroup(java.lang.String name)
Get a group using its namejava.util.List<java.lang.String>
getGroupNames()
getGroupNamesjava.util.Map<java.lang.String,Group>
getGroups()
Get the groupsOnmsGroup
getOnmsGroup(java.lang.String groupName)
getOnmsGroupOnmsGroupList
getOnmsGroupList()
getOnmsGroupListRole
getRole(java.lang.String roleName)
getRolejava.lang.String[]
getRoleNames()
getRoleNamesjava.util.Collection<Role>
getRoles()
getRolesOwnedIntervalSequence
getRoleScheduleEntries(java.lang.String roleid, java.util.Date start, java.util.Date end)
getRoleScheduleEntriesjava.util.List<Schedule>
getSchedulesForRoleAt(java.lang.String roleId, java.util.Date time)
getSchedulesForRoleAtjava.util.List<Schedule>
getUserSchedulesForRole(java.lang.String userId, java.lang.String roleId)
getUserSchedulesForRolelong
groupNextOnDuty(java.lang.String group, java.util.Calendar time)
Determines when a group is next on duty.boolean
hasGroup(java.lang.String groupName)
Returns a boolean indicating if the group name appears in the xml fileboolean
isGroupOnDuty(java.lang.String group, java.util.Calendar time)
Determines if a group is on duty at a given time.boolean
isUserScheduledForRole(java.lang.String userId, java.lang.String roleId, java.util.Date time)
isUserScheduledForRoleprotected void
parseXml(java.io.InputStream stream)
parseXmlvoid
renameGroup(java.lang.String oldName, java.lang.String newName)
Renames the group from the list of groups.void
renameUser(java.lang.String oldName, java.lang.String newName)
When this method is called group name is changed, so also is the group name belonging to the view.void
save(OnmsGroup group)
savevoid
saveGroup(java.lang.String name, Group details)
Adds a new user and overwrites the "groups.xml"void
saveGroups()
saveGroupsvoid
saveRole(Role role)
saveRoleprotected abstract void
saveXml(java.lang.String data)
saveXmlvoid
setGroups(java.util.Map<java.lang.String,Group> grp)
Set the groups dataabstract void
update()
updateboolean
userHasRole(java.lang.String userId, java.lang.String roleid)
userHasRole
-
-
-
Field Detail
-
m_dutySchedules
protected static java.util.Map<java.lang.String,java.util.List<DutySchedule>> m_dutySchedules
The duty schedules for each group
-
-
Method Detail
-
parseXml
protected void parseXml(java.io.InputStream stream) throws java.io.IOException
parseXml
- Parameters:
stream
- aInputStream
object.- Throws:
java.io.IOException
-
setGroups
public void setGroups(java.util.Map<java.lang.String,Group> grp)
Set the groups data- Specified by:
setGroups
in interfaceGroupConfig
- Parameters:
grp
- aMap
object.
-
getGroups
public java.util.Map<java.lang.String,Group> getGroups() throws java.io.IOException
Get the groups- Specified by:
getGroups
in interfaceGroupConfig
- Returns:
- a
Map
object. - Throws:
java.io.IOException
- if any.
-
getOnmsGroupList
public OnmsGroupList getOnmsGroupList() throws java.io.IOException
Description copied from interface:GroupConfig
getOnmsGroupList
- Specified by:
getOnmsGroupList
in interfaceGroupConfig
- Returns:
- an OnmsGroupList
- Throws:
java.io.IOException
-
getOnmsGroup
public OnmsGroup getOnmsGroup(java.lang.String groupName) throws java.io.IOException
Description copied from interface:GroupConfig
getOnmsGroup
- Specified by:
getOnmsGroup
in interfaceGroupConfig
- Returns:
- an OnmsGroup
- Throws:
java.io.IOException
-
save
public void save(OnmsGroup group) throws java.lang.Exception
Description copied from interface:GroupConfig
save
- Specified by:
save
in interfaceGroupConfig
- Throws:
java.lang.Exception
-
update
public abstract void update() throws java.io.IOException
update
- Throws:
java.io.IOException
- if any.
-
hasGroup
public boolean hasGroup(java.lang.String groupName) throws java.io.IOException
Returns a boolean indicating if the group name appears in the xml file- Specified by:
hasGroup
in interfaceGroupConfig
- Parameters:
groupName
- aString
object.- Returns:
- true if the group exists in the xml file, false otherwise
- Throws:
java.io.IOException
- if any.
-
getGroupNames
public java.util.List<java.lang.String> getGroupNames() throws java.io.IOException
getGroupNames
- Specified by:
getGroupNames
in interfaceGroupConfig
- Returns:
- a
List
object. - Throws:
java.io.IOException
- if any.
-
getGroup
public Group getGroup(java.lang.String name) throws java.io.IOException
Get a group using its name- Specified by:
getGroup
in interfaceGroupConfig
- Parameters:
name
- the name of the group to return- Returns:
- Group, the group specified by name
- Throws:
java.io.IOException
- if any.
-
saveGroups
public void saveGroups() throws java.lang.Exception
saveGroups
- Specified by:
saveGroups
in interfaceGroupConfig
- Throws:
java.lang.Exception
- if any.
-
isGroupOnDuty
public boolean isGroupOnDuty(java.lang.String group, java.util.Calendar time) throws java.io.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:
isGroupOnDuty
in 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:
java.io.IOException
- if any.
-
groupNextOnDuty
public long groupNextOnDuty(java.lang.String group, java.util.Calendar time) throws java.io.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:
groupNextOnDuty
in 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:
java.io.IOException
- if any.
-
saveXml
protected abstract void saveXml(java.lang.String data) throws java.io.IOException
saveXml
- Parameters:
data
- aString
object.- Throws:
java.io.IOException
- if any.
-
saveGroup
public void saveGroup(java.lang.String name, Group details) throws java.lang.Exception
Adds a new user and overwrites the "groups.xml"- Specified by:
saveGroup
in interfaceGroupConfig
- Parameters:
name
- aString
object.details
- aGroup
object.- Throws:
java.lang.Exception
- if any.
-
saveRole
public void saveRole(Role role) throws java.lang.Exception
saveRole
- Specified by:
saveRole
in interfaceGroupConfig
- Parameters:
role
- aRole
object.- Throws:
java.lang.Exception
- if any.
-
deleteUser
public void deleteUser(java.lang.String name) throws java.lang.Exception
Removes the user from the list of groups. Then overwrites to the "groups.xml"- Specified by:
deleteUser
in interfaceGroupConfig
- Parameters:
name
- aString
object.- Throws:
java.lang.Exception
- if any.
-
deleteGroup
public void deleteGroup(java.lang.String name) throws java.lang.Exception
Removes the group from the list of groups. Then overwrites to the "groups.xml"- Specified by:
deleteGroup
in interfaceGroupConfig
- Parameters:
name
- aString
object.- Throws:
java.lang.Exception
- if any.
-
deleteRole
public void deleteRole(java.lang.String name) throws java.lang.Exception
deleteRole
- Specified by:
deleteRole
in interfaceGroupConfig
- Parameters:
name
- aString
object.- Throws:
java.lang.Exception
- if any.
-
renameGroup
public void renameGroup(java.lang.String oldName, java.lang.String newName) throws java.lang.Exception
Renames the group from the list of groups. Then overwrites to the "groups.xml"- Specified by:
renameGroup
in interfaceGroupConfig
- Parameters:
oldName
- aString
object.newName
- aString
object.- Throws:
java.lang.Exception
- if any.
-
renameUser
public void renameUser(java.lang.String oldName, java.lang.String newName) throws java.lang.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:
renameUser
in interfaceGroupConfig
- Parameters:
oldName
- aString
object.newName
- aString
object.- Throws:
java.lang.Exception
- if any.
-
getRoleNames
public java.lang.String[] getRoleNames()
getRoleNames
- Specified by:
getRoleNames
in interfaceGroupConfig
- Returns:
- an array of
String
objects.
-
getRoles
public java.util.Collection<Role> getRoles()
getRoles
- Specified by:
getRoles
in interfaceGroupConfig
- Returns:
- a
Collection
object.
-
getRole
public Role getRole(java.lang.String roleName)
getRole
- Specified by:
getRole
in interfaceGroupConfig
- Parameters:
roleName
- aString
object.- Returns:
- a
Role
object.
-
userHasRole
public boolean userHasRole(java.lang.String userId, java.lang.String roleid) throws java.io.IOException
userHasRole
- Specified by:
userHasRole
in interfaceGroupConfig
- Parameters:
userId
- aString
object.roleid
- aString
object.- Returns:
- a boolean.
- Throws:
java.io.IOException
- if any.
-
getSchedulesForRoleAt
public java.util.List<Schedule> getSchedulesForRoleAt(java.lang.String roleId, java.util.Date time) throws java.io.IOException
getSchedulesForRoleAt
- Specified by:
getSchedulesForRoleAt
in interfaceGroupConfig
- Parameters:
roleId
- aString
object.time
- aDate
object.- Returns:
- a
List
object. - Throws:
java.io.IOException
- if any.
-
getUserSchedulesForRole
public java.util.List<Schedule> getUserSchedulesForRole(java.lang.String userId, java.lang.String roleId) throws java.io.IOException
getUserSchedulesForRole
- Specified by:
getUserSchedulesForRole
in interfaceGroupConfig
- Parameters:
userId
- aString
object.roleId
- aString
object.- Returns:
- a
List
object. - Throws:
java.io.IOException
- if any.
-
isUserScheduledForRole
public boolean isUserScheduledForRole(java.lang.String userId, java.lang.String roleId, java.util.Date time) throws java.io.IOException
isUserScheduledForRole
- Specified by:
isUserScheduledForRole
in interfaceGroupConfig
- Parameters:
userId
- aString
object.roleId
- aString
object.time
- aDate
object.- Returns:
- a boolean.
- Throws:
java.io.IOException
- if any.
-
getRoleScheduleEntries
public OwnedIntervalSequence getRoleScheduleEntries(java.lang.String roleid, java.util.Date start, java.util.Date end) throws java.io.IOException
getRoleScheduleEntries
- Specified by:
getRoleScheduleEntries
in interfaceGroupConfig
- Parameters:
roleid
- aString
object.start
- aDate
object.end
- aDate
object.- Returns:
- a
OwnedIntervalSequence
object. - Throws:
java.io.IOException
- if any.
-
findGroupsForUser
public java.util.List<Group> findGroupsForUser(java.lang.String user)
findGroupsForUser
- Specified by:
findGroupsForUser
in interfaceGroupConfig
- Parameters:
user
- aString
object.- Returns:
- a
List
object.
-
-