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

Author:
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)
           
 void deleteUser(String name)
          Removes the user from the list of groups.
 List<Group> findGroupsForUser(String user)
           
 Group getGroup(String name)
          Get a group using its name
 List<String> getGroupNames()
           
 Map<String,Group> getGroups()
          Get the groups
 Role getRole(String roleName)
           
 String[] getRoleNames()
           
 Collection<Role> getRoles()
           
 OwnedIntervalSequence getRoleScheduleEntries(String roleid, Date start, Date end)
           
 List<Schedule> getSchedulesForRoleAt(String roleId, Date time)
           
 List<Schedule> getUserSchedulesForRole(String userId, String roleId)
           
 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)
           
protected  void parseXml(Reader reader)
           
 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()
           
 void saveRole(Role role)
           
protected abstract  void saveXml(String data)
           
 void setGroups(Map<String,Group> grp)
          Set the groups data
protected abstract  void update()
           
 boolean userHasRole(String userId, String roleid)
           
 
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

protected void parseXml(Reader reader)
                 throws org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Parameters:
reader -
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

setGroups

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


getGroups

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

Throws:
IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

update

protected abstract void update()
                        throws IOException,
                               org.exolab.castor.xml.MarshalException,
                               org.exolab.castor.xml.ValidationException
Throws:
org.exolab.castor.xml.ValidationException
org.exolab.castor.xml.MarshalException
IOException

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

Returns:
true if the group exists in the xml file, false otherwise
Throws:
IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getGroupNames

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

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
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

saveGroups

public void saveGroups()
                throws Exception
Throws:
Exception

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
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

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
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

saveXml

protected abstract void saveXml(String data)
                         throws IOException
Parameters:
data -
Throws:
IOException

saveGroup

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

Throws:
Exception

saveRole

public void saveRole(Role role)
              throws Exception
Throws:
Exception

deleteUser

public void deleteUser(String name)
                throws Exception
Removes the user from the list of groups. Then overwrites to the "groups.xml"

Throws:
Exception

deleteGroup

public void deleteGroup(String name)
                 throws Exception
Removes the group from the list of groups. Then overwrites to the "groups.xml"

Throws:
Exception

deleteRole

public void deleteRole(String name)
                throws Exception
Throws:
Exception

renameGroup

public void renameGroup(String oldName,
                        String newName)
                 throws Exception
Renames the group from the list of groups. Then overwrites to the "groups.xml"

Throws:
Exception

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

Throws:
Exception

getRoleNames

public String[] getRoleNames()

getRoles

public Collection<Role> getRoles()

getRole

public Role getRole(String roleName)

userHasRole

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

getSchedulesForRoleAt

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

getUserSchedulesForRole

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

isUserScheduledForRole

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

getRoleScheduleEntries

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

findGroupsForUser

public List<Group> findGroupsForUser(String user)


Copyright © 2009. All Rights Reserved.