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 java.lang.Object

Author:
david TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Field Summary
protected static java.util.HashMap<java.lang.String,java.util.List<DutySchedule>> m_dutySchedules
          The duty schedules for each group
 
Constructor Summary
GroupManager()
           
 
Method Summary
 void deleteGroup(java.lang.String name)
          Removes the group from the list of groups.
 void deleteRole(java.lang.String name)
           
 void deleteUser(java.lang.String name)
          Removes the user from the list of groups.
 java.util.List<org.opennms.netmgt.config.groups.Group> findGroupsForUser(java.lang.String user)
           
 org.opennms.netmgt.config.groups.Group getGroup(java.lang.String name)
          Get a group using its name
 java.util.List<java.lang.String> getGroupNames()
           
 java.util.Map<java.lang.String,org.opennms.netmgt.config.groups.Group> getGroups()
          Get the groups
 org.opennms.netmgt.config.groups.Role getRole(java.lang.String roleName)
           
 java.lang.String[] getRoleNames()
           
 java.util.Collection getRoles()
           
 OwnedIntervalSequence getRoleScheduleEntries(java.lang.String roleid, java.util.Date start, java.util.Date end)
           
 java.util.List<org.opennms.netmgt.config.groups.Schedule> getSchedulesForRoleAt(java.lang.String roleId, java.util.Date time)
           
 java.util.List getUserSchedulesForRole(java.lang.String userId, java.lang.String roleid)
           
 long 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 file
 boolean 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)
           
protected  void parseXml(java.io.Reader reader)
           
 void 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 groupname belonging to the view.
 void saveGroup(java.lang.String name, org.opennms.netmgt.config.groups.Group details)
          Adds a new user and overwrites the "groups.xml"
 void saveGroups()
           
 void saveRole(org.opennms.netmgt.config.groups.Role role)
           
protected abstract  void saveXml(java.lang.String data)
           
 void setGroups(java.util.Map<java.lang.String,org.opennms.netmgt.config.groups.Group> grp)
          Set the groups data
protected abstract  void update()
           
 boolean userHasRole(java.lang.String userId, java.lang.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 java.util.HashMap<java.lang.String,java.util.List<DutySchedule>> m_dutySchedules
The duty schedules for each group

Constructor Detail

GroupManager

public GroupManager()
Method Detail

parseXml

protected void parseXml(java.io.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(java.util.Map<java.lang.String,org.opennms.netmgt.config.groups.Group> grp)
Set the groups data


getGroups

public java.util.Map<java.lang.String,org.opennms.netmgt.config.groups.Group> getGroups()
                                                                                 throws java.io.IOException,
                                                                                        org.exolab.castor.xml.MarshalException,
                                                                                        org.exolab.castor.xml.ValidationException
Get the groups

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

update

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

hasGroup

public boolean hasGroup(java.lang.String groupName)
                 throws java.io.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:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getGroupNames

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

getGroup

public org.opennms.netmgt.config.groups.Group getGroup(java.lang.String name)
                                                throws java.io.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:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

saveGroups

public void saveGroups()
                throws java.lang.Exception
Throws:
java.lang.Exception

isGroupOnDuty

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

groupNextOnDuty

public long groupNextOnDuty(java.lang.String group,
                            java.util.Calendar time)
                     throws java.io.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 config 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 millisec until the group is next on duty
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

saveXml

protected abstract void saveXml(java.lang.String data)
                         throws java.io.IOException
Parameters:
data -
Throws:
java.io.IOException

saveGroup

public void saveGroup(java.lang.String name,
                      org.opennms.netmgt.config.groups.Group details)
               throws java.lang.Exception
Adds a new user and overwrites the "groups.xml"

Throws:
java.lang.Exception

saveRole

public void saveRole(org.opennms.netmgt.config.groups.Role role)
              throws java.lang.Exception
Throws:
java.lang.Exception

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"

Throws:
java.lang.Exception

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"

Throws:
java.lang.Exception

deleteRole

public void deleteRole(java.lang.String name)
                throws java.lang.Exception
Throws:
java.lang.Exception

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"

Throws:
java.lang.Exception

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 groupname belonging to the view. Also overwrites the "groups.xml" file

Throws:
java.lang.Exception

getRoleNames

public java.lang.String[] getRoleNames()

getRoles

public java.util.Collection getRoles()

getRole

public org.opennms.netmgt.config.groups.Role getRole(java.lang.String roleName)

userHasRole

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

getSchedulesForRoleAt

public java.util.List<org.opennms.netmgt.config.groups.Schedule> getSchedulesForRoleAt(java.lang.String roleId,
                                                                                       java.util.Date time)
                                                                                throws org.exolab.castor.xml.MarshalException,
                                                                                       org.exolab.castor.xml.ValidationException,
                                                                                       java.io.IOException
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
java.io.IOException

getUserSchedulesForRole

public java.util.List getUserSchedulesForRole(java.lang.String userId,
                                              java.lang.String roleid)
                                       throws org.exolab.castor.xml.MarshalException,
                                              org.exolab.castor.xml.ValidationException,
                                              java.io.IOException
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
java.io.IOException

isUserScheduledForRole

public boolean isUserScheduledForRole(java.lang.String userId,
                                      java.lang.String roleid,
                                      java.util.Date time)
                               throws org.exolab.castor.xml.MarshalException,
                                      org.exolab.castor.xml.ValidationException,
                                      java.io.IOException
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
java.io.IOException

getRoleScheduleEntries

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

findGroupsForUser

public java.util.List<org.opennms.netmgt.config.groups.Group> findGroupsForUser(java.lang.String user)


Copyright © 2007. All Rights Reserved.