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 classGroupManager.OnmsGroupListMapperstatic classGroupManager.OnmsGroupMapper
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,java.util.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(java.lang.String name)Removes the group from the list of groups.voiddeleteRole(java.lang.String name)deleteRolevoiddeleteUser(java.lang.String name)Removes the user from the list of groups.java.util.List<Group>findGroupsForUser(java.lang.String user)findGroupsForUserGroupgetGroup(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 groupsOnmsGroupgetOnmsGroup(java.lang.String groupName)getOnmsGroupOnmsGroupListgetOnmsGroupList()getOnmsGroupListRolegetRole(java.lang.String roleName)getRolejava.lang.String[]getRoleNames()getRoleNamesjava.util.Collection<Role>getRoles()getRolesOwnedIntervalSequencegetRoleScheduleEntries(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)getUserSchedulesForRolelonggroupNextOnDuty(java.lang.String group, java.util.Calendar time)Determines when a group is next on duty.booleanhasGroup(java.lang.String groupName)Returns a boolean indicating if the group name appears in the xml filebooleanisGroupOnDuty(java.lang.String group, java.util.Calendar time)Determines if a group is on duty at a given time.booleanisUserScheduledForRole(java.lang.String userId, java.lang.String roleId, java.util.Date time)isUserScheduledForRoleprotected voidparseXml(java.io.InputStream stream)parseXmlvoidrenameGroup(java.lang.String oldName, java.lang.String newName)Renames the group from the list of groups.voidrenameUser(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.voidsave(OnmsGroup group)savevoidsaveGroup(java.lang.String name, Group details)Adds a new user and overwrites the "groups.xml"voidsaveGroups()saveGroupsvoidsaveRole(Role role)saveRoleprotected abstract voidsaveXml(java.lang.String data)saveXmlvoidsetGroups(java.util.Map<java.lang.String,Group> grp)Set the groups dataabstract voidupdate()updatebooleanuserHasRole(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.IOExceptionparseXml
- Parameters:
stream- aInputStreamobject.- Throws:
java.io.IOException
-
setGroups
public void setGroups(java.util.Map<java.lang.String,Group> grp)
Set the groups data- Specified by:
setGroupsin interfaceGroupConfig- Parameters:
grp- aMapobject.
-
getGroups
public java.util.Map<java.lang.String,Group> getGroups() throws java.io.IOException
Get the groups- Specified by:
getGroupsin interfaceGroupConfig- Returns:
- a
Mapobject. - Throws:
java.io.IOException- if any.
-
getOnmsGroupList
public OnmsGroupList getOnmsGroupList() throws java.io.IOException
Description copied from interface:GroupConfiggetOnmsGroupList
- Specified by:
getOnmsGroupListin interfaceGroupConfig- Returns:
- an OnmsGroupList
- Throws:
java.io.IOException
-
getOnmsGroup
public OnmsGroup getOnmsGroup(java.lang.String groupName) throws java.io.IOException
Description copied from interface:GroupConfiggetOnmsGroup
- Specified by:
getOnmsGroupin interfaceGroupConfig- Returns:
- an OnmsGroup
- Throws:
java.io.IOException
-
save
public void save(OnmsGroup group) throws java.lang.Exception
Description copied from interface:GroupConfigsave
- Specified by:
savein interfaceGroupConfig- Throws:
java.lang.Exception
-
update
public abstract void update() throws java.io.IOExceptionupdate
- Throws:
java.io.IOException- if any.
-
hasGroup
public boolean hasGroup(java.lang.String groupName) throws java.io.IOExceptionReturns 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:
java.io.IOException- if any.
-
getGroupNames
public java.util.List<java.lang.String> getGroupNames() throws java.io.IOExceptiongetGroupNames
- Specified by:
getGroupNamesin interfaceGroupConfig- Returns:
- a
Listobject. - 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:
getGroupin 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.ExceptionsaveGroups
- Specified by:
saveGroupsin interfaceGroupConfig- Throws:
java.lang.Exception- if any.
-
isGroupOnDuty
public boolean isGroupOnDuty(java.lang.String group, java.util.Calendar time) throws java.io.IOExceptionDetermines 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:
java.io.IOException- if any.
-
groupNextOnDuty
public long groupNextOnDuty(java.lang.String group, java.util.Calendar time) throws java.io.IOExceptionDetermines 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:
java.io.IOException- if any.
-
saveXml
protected abstract void saveXml(java.lang.String data) throws java.io.IOExceptionsaveXml
- Parameters:
data- aStringobject.- Throws:
java.io.IOException- if any.
-
saveGroup
public void saveGroup(java.lang.String name, Group details) throws java.lang.ExceptionAdds a new user and overwrites the "groups.xml"- Specified by:
saveGroupin interfaceGroupConfig- Parameters:
name- aStringobject.details- aGroupobject.- Throws:
java.lang.Exception- if any.
-
saveRole
public void saveRole(Role role) throws java.lang.Exception
saveRole
- Specified by:
saveRolein interfaceGroupConfig- Parameters:
role- aRoleobject.- Throws:
java.lang.Exception- if any.
-
deleteUser
public void deleteUser(java.lang.String name) throws java.lang.ExceptionRemoves the user from the list of groups. Then overwrites to the "groups.xml"- Specified by:
deleteUserin interfaceGroupConfig- Parameters:
name- aStringobject.- Throws:
java.lang.Exception- if any.
-
deleteGroup
public void deleteGroup(java.lang.String name) throws java.lang.ExceptionRemoves the group from the list of groups. Then overwrites to the "groups.xml"- Specified by:
deleteGroupin interfaceGroupConfig- Parameters:
name- aStringobject.- Throws:
java.lang.Exception- if any.
-
deleteRole
public void deleteRole(java.lang.String name) throws java.lang.ExceptiondeleteRole
- Specified by:
deleteRolein interfaceGroupConfig- Parameters:
name- aStringobject.- Throws:
java.lang.Exception- if any.
-
renameGroup
public void renameGroup(java.lang.String oldName, java.lang.String newName) throws java.lang.ExceptionRenames the group from the list of groups. Then overwrites to the "groups.xml"- Specified by:
renameGroupin interfaceGroupConfig- Parameters:
oldName- aStringobject.newName- aStringobject.- Throws:
java.lang.Exception- if any.
-
renameUser
public void renameUser(java.lang.String oldName, java.lang.String newName) throws java.lang.ExceptionWhen 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:
java.lang.Exception- if any.
-
getRoleNames
public java.lang.String[] getRoleNames()
getRoleNames
- Specified by:
getRoleNamesin interfaceGroupConfig- Returns:
- an array of
Stringobjects.
-
getRoles
public java.util.Collection<Role> getRoles()
getRoles
- Specified by:
getRolesin interfaceGroupConfig- Returns:
- a
Collectionobject.
-
getRole
public Role getRole(java.lang.String roleName)
getRole
- Specified by:
getRolein interfaceGroupConfig- Parameters:
roleName- aStringobject.- Returns:
- a
Roleobject.
-
userHasRole
public boolean userHasRole(java.lang.String userId, java.lang.String roleid) throws java.io.IOExceptionuserHasRole
- Specified by:
userHasRolein interfaceGroupConfig- Parameters:
userId- aStringobject.roleid- aStringobject.- 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:
getSchedulesForRoleAtin interfaceGroupConfig- Parameters:
roleId- aStringobject.time- aDateobject.- Returns:
- a
Listobject. - 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:
getUserSchedulesForRolein interfaceGroupConfig- Parameters:
userId- aStringobject.roleId- aStringobject.- Returns:
- a
Listobject. - 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.IOExceptionisUserScheduledForRole
- Specified by:
isUserScheduledForRolein interfaceGroupConfig- Parameters:
userId- aStringobject.roleId- aStringobject.time- aDateobject.- 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:
getRoleScheduleEntriesin interfaceGroupConfig- Parameters:
roleid- aStringobject.start- aDateobject.end- aDateobject.- Returns:
- a
OwnedIntervalSequenceobject. - Throws:
java.io.IOException- if any.
-
findGroupsForUser
public java.util.List<Group> findGroupsForUser(java.lang.String user)
findGroupsForUser
- Specified by:
findGroupsForUserin interfaceGroupConfig- Parameters:
user- aStringobject.- Returns:
- a
Listobject.
-
-