Package org.jivesoftware.openfire.group
Class GroupManager
java.lang.Object
org.jivesoftware.openfire.group.GroupManager
Manages groups.
- Author:
- Matt Tucker
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
adminAddedPostProcess
(Group group, org.xmpp.packet.JID admin, boolean wasMember) Updates the caches maintained by this manager and dispatches events that reflect an admin user having been added to a group.void
adminRemovedPostProcess
(Group group, org.xmpp.packet.JID admin) Updates the caches maintained by this manager and dispatches events that reflect an admin user having been removed from a group.createGroup
(String name) Factory method for creating a new Group.void
createGroupPostProcess
(Group group) Updates the caches maintained by this manager and dispatches events that reflect a new group having been created.void
deleteGroup
(Group group) Deletes a group from the system.void
deleteGroupPostProcess
(Group group) Updates the caches maintained by this manager to reflect an existing group having been deleted.void
deleteGroupPreProcess
(Group group) Dispatches events that reflect an existing group having been deleted.void
deleteUser
(User user) Deletes a user from all the groups where he/she belongs.Returns a Group by name.Returns a Group by name.getGroup
(org.xmpp.packet.JID jid) Returns the corresponding group if the given JID represents a group.int
Returns the total number of groups in the system.Returns an unmodifiable Collection of all groups in the system.getGroups
(int startIndex, int numResults) Returns all groups given a start index and desired number of results.Returns an iterator for all groups that the User is a member of.getGroups
(org.xmpp.packet.JID user) Returns an iterator for all groups that the entity with the specified JID is a member of.static GroupManager
Returns a singleton instance of GroupManager.Returns the configured group provider.Returns an unmodifiable Collection of all public shared groups in the system.Returns an unmodifiable Collection of all shared groups in the system.getSharedGroups
(String userName) Returns an unmodifiable Collection of all shared groups in the system for a given userName.getVisibleGroups
(Group groupToCheck) Returns an unmodifiable Collection of all shared groups in the system for a given group name.boolean
Returns true if groups are read-only.boolean
Returns true if searching for groups is supported.void
memberAddedPostProcess
(Group group, org.xmpp.packet.JID member, boolean wasAdmin) Updates the caches maintained by this manager and dispatches events that reflect a member user having been added to a group.void
memberRemovedPostProcess
(Group group, org.xmpp.packet.JID member) Updates the caches maintained by this manager and dispatches events that reflect a member user having been removed from a group.void
propertiesDeletedPostProcess
(Group group, Map<String, String> originalProperties) Updates the caches maintained by this manager and dispatches events that reflect a group having all of its properties removed.void
propertyAddedPostProcess
(Group group, String key) Updates the caches maintained by this manager and dispatches events that reflect a group having received a new property.void
propertyDeletedPostProcess
(Group group, String key, String originalValue) Updates the caches maintained by this manager and dispatches events that reflect a group having one of its properties removed.void
propertyModifiedPostProcess
(Group group, String key, String originalValue) Updates the caches maintained by this manager and dispatches events that reflect a group having received a modification to one of its properties.void
redescribeGroupPostProcess
(Group group, String originalDescription) Updates the caches maintained by this manager and dispatches events that reflect a group having received a new description.void
renameGroupPostProcess
(Group group, String originalName) Updates the caches maintained by this manager and dispatches events that reflect a group having received a new name.Returns the groups that match the search.Returns the groups that match the search given a start index and desired number of results.Returns an unmodifiable Collection of all groups in the system that match given propValue for the specified propName.splitGroupList
(String csv) Splits a comma-separated string of group name in a set of group names.
-
Field Details
-
GROUP_PROVIDER
-
-
Method Details
-
getInstance
Returns a singleton instance of GroupManager.- Returns:
- a GroupManager instance.
-
createGroup
Factory method for creating a new Group. A unique name is the only required field.- Parameters:
name
- the new and unique name for the group.- Returns:
- a new Group.
- Throws:
GroupAlreadyExistsException
- if the group name already exists in the system.GroupNameInvalidException
-
getGroup
Returns the corresponding group if the given JID represents a group.- Parameters:
jid
- The JID for the group to retrieve- Returns:
- The group corresponding to the JID, or null if the JID does not represent a group
- Throws:
GroupNotFoundException
- if the JID represents a group that does not exist
-
getGroup
Returns a Group by name.- Parameters:
name
- The name of the group to retrieve- Returns:
- The group corresponding to that name
- Throws:
GroupNotFoundException
- if the group does not exist.
-
getGroup
Returns a Group by name.- Parameters:
name
- The name of the group to retrieveforceLookup
- Invalidate the group cache for this group- Returns:
- The group corresponding to that name
- Throws:
GroupNotFoundException
- if the group does not exist.
-
deleteGroup
Deletes a group from the system.- Parameters:
group
- the group to delete.- Throws:
GroupNotFoundException
-
deleteUser
Deletes a user from all the groups where he/she belongs. The most probable cause for this request is that the user has been deleted from the system.- Parameters:
user
- the deleted user from the system.
-
getGroupCount
public int getGroupCount()Returns the total number of groups in the system.- Returns:
- the total number of groups.
-
getGroups
Returns an unmodifiable Collection of all groups in the system. NOTE: Iterating through the resulting collection has the effect of loading every group into memory. This may be an issue for large deployments. You may call the size() method on the resulting collection to determine the best approach to take before iterating over (and thus instantiating) the groups.- Returns:
- an unmodifiable Collection of all groups.
-
getVisibleGroups
Returns an unmodifiable Collection of all shared groups in the system for a given group name.- Parameters:
groupToCheck
- The group to check- Returns:
- an unmodifiable Collection of all shared groups for the given group name.
-
search
Returns an unmodifiable Collection of all groups in the system that match given propValue for the specified propName.- Parameters:
propName
- the property name to search forpropValue
- the property value to search for- Returns:
- an unmodifiable Collection of all matching groups.
-
getGroups
Returns all groups given a start index and desired number of results. This is useful to support pagination in a GUI where you may only want to display a certain number of results per page. It is possible that the number of results returned will be less than that specified by numResults if numResults is greater than the number of records left in the system to display.- Parameters:
startIndex
- start index in results.numResults
- number of results to return.- Returns:
- an Iterator for all groups in the specified range.
-
getGroups
Returns an iterator for all groups that the User is a member of.- Parameters:
user
- the user.- Returns:
- all groups the user belongs to.
-
getGroups
Returns an iterator for all groups that the entity with the specified JID is a member of.- Parameters:
user
- the JID of the entity to get a list of groups for.- Returns:
- all groups that an entity belongs to.
-
isReadOnly
public boolean isReadOnly()Returns true if groups are read-only.- Returns:
- true if groups are read-only.
-
isSearchSupported
public boolean isSearchSupported()Returns true if searching for groups is supported.- Returns:
- true if searching for groups are supported.
-
search
Returns the groups that match the search. The search is over group names and implicitly uses wildcard matching (although the exact search semantics are left up to each provider implementation). For example, a search for "HR" should match the groups "HR", "HR Department", and "The HR People".Before searching or showing a search UI, use the
isSearchSupported()
method to ensure that searching is supported.- Parameters:
query
- the search string for group names.- Returns:
- all groups that match the search.
-
search
Returns the groups that match the search given a start index and desired number of results. The search is over group names and implicitly uses wildcard matching (although the exact search semantics are left up to each provider implementation). For example, a search for "HR" should match the groups "HR", "HR Department", and "The HR People".Before searching or showing a search UI, use the
isSearchSupported()
method to ensure that searching is supported.- Parameters:
query
- the search string for group names.startIndex
- the start index to retrieve the group list fromnumResults
- the maximum number of results to return- Returns:
- all groups that match the search.
-
getProvider
Returns the configured group provider. Note that this method has special access privileges since only a few certain classes need to access the provider directly.- Returns:
- the group provider.
-
splitGroupList
Splits a comma-separated string of group name in a set of group names.- Parameters:
csv
- The comma-separated list. Cannot be null.- Returns:
- A set of group names.
-
createGroupPostProcess
Updates the caches maintained by this manager and dispatches events that reflect a new group having been created. This method is intended to be invoked to update the internal state of GroupManager after a group has been created. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that has been created.
-
deleteGroupPreProcess
Dispatches events that reflect an existing group having been deleted. This method is intended to be invoked to update the internal state of GroupManager just before a group will be deleted. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that is about to be removed.
-
deleteGroupPostProcess
Updates the caches maintained by this manager to reflect an existing group having been deleted. This method is intended to be invoked to update the internal state of GroupManager after a group has been deleted. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that has been deleted. Care should be taken to not apply changes to this instance, as it no longer refers to a valid, existing group.
-
adminAddedPostProcess
public void adminAddedPostProcess(@Nonnull Group group, @Nonnull org.xmpp.packet.JID admin, boolean wasMember) Updates the caches maintained by this manager and dispatches events that reflect an admin user having been added to a group. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.admin
- The address of the admin that was added to the group.wasMember
- Whether the admin was a member of the group (which are mutually exclusive roles) before the update.
-
adminRemovedPostProcess
Updates the caches maintained by this manager and dispatches events that reflect an admin user having been removed from a group. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.admin
- The address of the admin that was removed from the group.
-
memberAddedPostProcess
public void memberAddedPostProcess(@Nonnull Group group, @Nonnull org.xmpp.packet.JID member, boolean wasAdmin) Updates the caches maintained by this manager and dispatches events that reflect a member user having been added to a group. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.member
- The address of the member that was added to the group.wasAdmin
- Whether the member was an admin of the group (which are mutually exclusive roles) before the update.
-
memberRemovedPostProcess
Updates the caches maintained by this manager and dispatches events that reflect a member user having been removed from a group. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.member
- The address of the member that was removed from the group.
-
renameGroupPostProcess
Updates the caches maintained by this manager and dispatches events that reflect a group having received a new name. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.originalName
- The name of the group prior to the change.
-
redescribeGroupPostProcess
Updates the caches maintained by this manager and dispatches events that reflect a group having received a new description. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.originalDescription
- The description of the group prior to the change.
-
propertyAddedPostProcess
Updates the caches maintained by this manager and dispatches events that reflect a group having received a new property. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.key
- The key of the property that was added.
-
propertyModifiedPostProcess
public void propertyModifiedPostProcess(@Nonnull Group group, @Nonnull String key, @Nonnull String originalValue) Updates the caches maintained by this manager and dispatches events that reflect a group having received a modification to one of its properties. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.key
- The key of the property that was modified.originalValue
- The value of the property prior to the modification.
-
propertyDeletedPostProcess
public void propertyDeletedPostProcess(@Nonnull Group group, @Nonnull String key, @Nonnull String originalValue) Updates the caches maintained by this manager and dispatches events that reflect a group having one of its properties removed. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.key
- The key of the property that was removed.originalValue
- The value of the property prior to the removal.
-
propertiesDeletedPostProcess
public void propertiesDeletedPostProcess(@Nonnull Group group, @Nonnull Map<String, String> originalProperties) Updates the caches maintained by this manager and dispatches events that reflect a group having all of its properties removed. This method is intended to be invoked to update the internal state of GroupManager after a group has been updated. It should rarely be invoked by code that is not part of the GroupManager implementation.- Parameters:
group
- The group that was modified.originalProperties
- The properties of the group prior to the removal.
-