org.opennms.netmgt.config
Class GroupManager

java.lang.Object
  extended by org.opennms.netmgt.config.GroupManager
Direct Known Subclasses:
GroupFactory

public abstract class GroupManager
extends Object

Abstract GroupManager class.

Version:
$Id: $
Author:
David Hustace, Matt Brozowski, Bill Ayres, DJ Gregor, David Hustace, Matt Brozowski, Bill Ayres, DJ Gregor, David Hustace, Matt Brozowski, Bill Ayres, DJ Gregor, David Hustace, Matt Brozowski, Bill Ayres, DJ Gregor

Field Summary
protected static HashMap<String,List<DutySchedule>> m_dutySchedules
          The duty schedules for each group
 
Constructor Summary
GroupManager()
           
 
Method Summary
 void deleteGroup(String name)
          Removes the group from the list of groups.
 void deleteRole(String name)
          deleteRole
 void deleteUser(String name)
          Removes the user from the list of groups.
 List<Group> findGroupsForUser(String user)
          findGroupsForUser
 Group getGroup(String name)
          Get a group using its name
 List<String> getGroupNames()
          getGroupNames
 Map<String,Group> getGroups()
          Get the groups
 Role getRole(String roleName)
          getRole
 String[] getRoleNames()
          getRoleNames
 Collection<Role> getRoles()
          getRoles
 OwnedIntervalSequence getRoleScheduleEntries(String roleid, Date start, Date end)
          getRoleScheduleEntries
 List<Schedule> getSchedulesForRoleAt(String roleId, Date time)
          getSchedulesForRoleAt
 List<Schedule> getUserSchedulesForRole(String userId, String roleId)
          getUserSchedulesForRole
 long groupNextOnDuty(String group, Calendar time)
          Determines when a group is next on duty.
 boolean hasGroup(String groupName)
          Returns a boolean indicating if the group name appears in the xml file
 boolean isGroupOnDuty(String group, Calendar time)
          Determines if a group is on duty at a given time.
 boolean isUserScheduledForRole(String userId, String roleId, Date time)
          isUserScheduledForRole
protected  void parseXml(InputStream stream)
          parseXml
protected  void parseXml(Reader reader)
          Deprecated. 
 void renameGroup(String oldName, String newName)
          Renames the group from the list of groups.
 void renameUser(String oldName, String newName)
          When this method is called group name is changed, so also is the group name belonging to the view.
 void saveGroup(String name, Group details)
          Adds a new user and overwrites the "groups.xml"
 void saveGroups()
          saveGroups
 void saveRole(Role role)
          saveRole
protected abstract  void saveXml(String data)
          saveXml
 void setGroups(Map<String,Group> grp)
          Set the groups data
abstract  void update()
          update
 boolean userHasRole(String userId, String roleid)
          userHasRole
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_dutySchedules

protected static HashMap<String,List<DutySchedule>> m_dutySchedules
The duty schedules for each group

Constructor Detail

GroupManager

public GroupManager()
Method Detail

parseXml

@Deprecated
protected void parseXml(Reader reader)
                 throws org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Deprecated. 

parseXml

Parameters:
reader - a Reader object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

parseXml

protected void parseXml(InputStream stream)
                 throws org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException

parseXml

Parameters:
stream - a InputStream object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

setGroups

public void setGroups(Map<String,Group> grp)
Set the groups data

Parameters:
grp - a Map object.

getGroups

public Map<String,Group> getGroups()
                            throws IOException,
                                   org.exolab.castor.xml.MarshalException,
                                   org.exolab.castor.xml.ValidationException
Get the groups

Returns:
a Map object.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

update

public abstract void update()
                     throws IOException,
                            org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException

update

Throws:
org.exolab.castor.xml.ValidationException - if any.
org.exolab.castor.xml.MarshalException - if any.
IOException - if any.

hasGroup

public boolean hasGroup(String groupName)
                 throws IOException,
                        org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Returns a boolean indicating if the group name appears in the xml file

Parameters:
groupName - a String object.
Returns:
true if the group exists in the xml file, false otherwise
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

getGroupNames

public List<String> getGroupNames()
                           throws IOException,
                                  org.exolab.castor.xml.MarshalException,
                                  org.exolab.castor.xml.ValidationException

getGroupNames

Returns:
a List object.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

getGroup

public Group getGroup(String name)
               throws IOException,
                      org.exolab.castor.xml.MarshalException,
                      org.exolab.castor.xml.ValidationException
Get a group using its name

Parameters:
name - the name of the group to return
Returns:
Group, the group specified by name
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

saveGroups

public void saveGroups()
                throws Exception

saveGroups

Throws:
Exception - if any.

isGroupOnDuty

public boolean isGroupOnDuty(String group,
                             Calendar time)
                      throws IOException,
                             org.exolab.castor.xml.MarshalException,
                             org.exolab.castor.xml.ValidationException
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.

Parameters:
group - the group whose duty schedule we want
time - the time to check for a duty schedule
Returns:
boolean, true if the group is on duty, false otherwise.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

groupNextOnDuty

public long groupNextOnDuty(String group,
                            Calendar time)
                     throws IOException,
                            org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException
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.

Parameters:
group - the group whose duty schedule we want
time - 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.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

saveXml

protected abstract void saveXml(String data)
                         throws IOException

saveXml

Parameters:
data - a String object.
Throws:
IOException - if any.

saveGroup

public void saveGroup(String name,
                      Group details)
               throws Exception
Adds a new user and overwrites the "groups.xml"

Parameters:
name - a String object.
details - a Group object.
Throws:
Exception - if any.

saveRole

public void saveRole(Role role)
              throws Exception

saveRole

Parameters:
role - a Role object.
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"

Parameters:
name - a String object.
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"

Parameters:
name - a String object.
Throws:
Exception - if any.

deleteRole

public void deleteRole(String name)
                throws Exception

deleteRole

Parameters:
name - a String object.
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"

Parameters:
oldName - a String object.
newName - a String object.
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

Parameters:
oldName - a String object.
newName - a String object.
Throws:
Exception - if any.

getRoleNames

public String[] getRoleNames()

getRoleNames

Returns:
an array of String objects.

getRoles

public Collection<Role> getRoles()

getRoles

Returns:
a Collection object.

getRole

public Role getRole(String roleName)

getRole

Parameters:
roleName - a String object.
Returns:
a Role object.

userHasRole

public boolean userHasRole(String userId,
                           String roleid)
                    throws org.exolab.castor.xml.MarshalException,
                           org.exolab.castor.xml.ValidationException,
                           IOException

userHasRole

Parameters:
userId - a String object.
roleid - a String object.
Returns:
a boolean.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.

getSchedulesForRoleAt

public List<Schedule> getSchedulesForRoleAt(String roleId,
                                            Date time)
                                     throws org.exolab.castor.xml.MarshalException,
                                            org.exolab.castor.xml.ValidationException,
                                            IOException

getSchedulesForRoleAt

Parameters:
roleId - a String object.
time - a Date object.
Returns:
a List object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.

getUserSchedulesForRole

public List<Schedule> getUserSchedulesForRole(String userId,
                                              String roleId)
                                       throws org.exolab.castor.xml.MarshalException,
                                              org.exolab.castor.xml.ValidationException,
                                              IOException

getUserSchedulesForRole

Parameters:
userId - a String object.
roleId - a String object.
Returns:
a List object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.

isUserScheduledForRole

public boolean isUserScheduledForRole(String userId,
                                      String roleId,
                                      Date time)
                               throws org.exolab.castor.xml.MarshalException,
                                      org.exolab.castor.xml.ValidationException,
                                      IOException

isUserScheduledForRole

Parameters:
userId - a String object.
roleId - a String object.
time - a Date object.
Returns:
a boolean.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.

getRoleScheduleEntries

public OwnedIntervalSequence getRoleScheduleEntries(String roleid,
                                                    Date start,
                                                    Date end)
                                             throws org.exolab.castor.xml.MarshalException,
                                                    org.exolab.castor.xml.ValidationException,
                                                    IOException

getRoleScheduleEntries

Parameters:
roleid - a String object.
start - a Date object.
end - a Date object.
Returns:
a OwnedIntervalSequence object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.

findGroupsForUser

public List<Group> findGroupsForUser(String user)

findGroupsForUser

Parameters:
user - a String object.
Returns:
a List object.


Copyright © 2011. All Rights Reserved.