Package org.jivesoftware.openfire.group
Interface GroupProvider
-
- All Known Implementing Classes:
AbstractGroupProvider
,CrowdGroupProvider
,DefaultGroupProvider
,JDBCGroupProvider
,LdapGroupProvider
public interface GroupProvider
Provider interface for groups. As grouped entities are thought to represent end-user entities, a group can be thought of as a collection of bare (not full) JIDs. The method of the Group class and its associated API will accept both bare and full JIDs, but are expected to 'cast down' a full JID to a bare JID prior to processing it. Developers that wish to integrate with their own group system must implement this class and then register the implementation with Openfire in theopenfire.xml
file. An entry in that file would look like the following:<provider> <group> <className>com.foo.auth.CustomGroupProvider</className> </group> </provider>
- Author:
- Matt Tucker
- See Also:
AbstractGroupProvider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addMember(String groupName, org.xmpp.packet.JID user, boolean administrator)
Adds an entity to a group (optional operation).Group
createGroup(String name)
Creates a group with the given name (optional operation).void
deleteGroup(String name)
Deletes the group (optional operation).void
deleteMember(String groupName, org.xmpp.packet.JID user)
Deletes an entity from a group (optional operation).Group
getGroup(String name)
Returns a group based on its name.int
getGroupCount()
Returns the number of groups in the system.Collection<String>
getGroupNames()
Returns the Collection of all group names in the system.Collection<String>
getGroupNames(int startIndex, int numResults)
Returns the Collection of all groups in the system.Collection<String>
getGroupNames(org.xmpp.packet.JID user)
Returns the Collection of group names that an entity belongs to.Collection<String>
getPublicSharedGroupNames()
Returns an unmodifiable Collection of all public shared groups in the system.Collection<String>
getSharedGroupNames()
Returns an unmodifiable Collection of all shared groups in the system.Collection<String>
getSharedGroupNames(org.xmpp.packet.JID user)
Returns an unmodifiable Collection of all shared groups in the system for a given user.Collection<String>
getVisibleGroupNames(String userGroup)
Returns an unmodifiable Collection of groups that are visible to the members of the given group.boolean
isReadOnly()
Returns true if this GroupProvider is read-only.boolean
isSearchSupported()
Returns true if group searching is supported by the provider.boolean
isSharingSupported()
Returns true if this GroupProvider allows group sharing.PersistableMap<String,String>
loadProperties(Group group)
Loads the group properties (if any) from the backend data store.Collection<String>
search(String query)
Returns the group names that match a search.Collection<String>
search(String query, int startIndex, int numResults)
Returns the group names that match a search given a start index and desired number of results.Collection<String>
search(String key, String value)
Returns the names of groups that have a property matching the given key/value pair.void
setDescription(String name, String description)
Updates the group's description.void
setName(String oldName, String newName)
Sets the name of a group to a new name.void
updateMember(String groupName, org.xmpp.packet.JID user, boolean administrator)
Updates the privileges of an entity in a group.
-
-
-
Method Detail
-
createGroup
Group createGroup(String name) throws GroupAlreadyExistsException, GroupNameInvalidException
Creates a group with the given name (optional operation).The provider is responsible for setting the creation date and modification date to the current date/time.
- Parameters:
name
- name of the group.- Returns:
- the newly created group.
- Throws:
GroupAlreadyExistsException
- if a group with the same name already exists.UnsupportedOperationException
- if the provider does not support the operation.GroupNameInvalidException
-
deleteGroup
void deleteGroup(String name) throws GroupNotFoundException
Deletes the group (optional operation).- Parameters:
name
- the name of the group to delete.- Throws:
UnsupportedOperationException
- if the provider does not support the operation.GroupNotFoundException
-
getGroup
Group getGroup(String name) throws GroupNotFoundException
Returns a group based on its name.- Parameters:
name
- the name of the group.- Returns:
- the group with the given name.
- Throws:
GroupNotFoundException
- If no group with that ID could be found
-
setName
void setName(String oldName, String newName) throws GroupAlreadyExistsException, GroupNameInvalidException, GroupNotFoundException
Sets the name of a group to a new name.- Parameters:
oldName
- the current name of the group.newName
- the desired new name of the group.- Throws:
GroupAlreadyExistsException
- if a group with the same name already exists.UnsupportedOperationException
- if the provider does not support the operation.GroupNameInvalidException
GroupNotFoundException
-
setDescription
void setDescription(String name, String description) throws GroupNotFoundException
Updates the group's description.- Parameters:
name
- the group name.description
- the group description.- Throws:
GroupNotFoundException
- if no existing group could be found to update.
-
getGroupCount
int getGroupCount()
Returns the number of groups in the system.- Returns:
- the number of groups in the system.
-
getGroupNames
Collection<String> getGroupNames()
Returns the Collection of all group names in the system.- Returns:
- the Collection of all groups.
-
isSharingSupported
boolean isSharingSupported()
Returns true if this GroupProvider allows group sharing. Shared groups enable roster sharing.- Returns:
- true if the group provider supports group sharing.
-
getSharedGroupNames
Collection<String> getSharedGroupNames()
Returns an unmodifiable Collection of all shared groups in the system.- Returns:
- unmodifiable Collection of all shared groups in the system.
-
getSharedGroupNames
Collection<String> getSharedGroupNames(org.xmpp.packet.JID user)
Returns an unmodifiable Collection of all shared groups in the system for a given user. Implementations should use the bare JID representation of the JID passed as an argument to this method.- Parameters:
user
- The bare JID for the user (node@domain)- Returns:
- unmodifiable Collection of all shared groups in the system for a given user.
-
getPublicSharedGroupNames
Collection<String> getPublicSharedGroupNames()
Returns an unmodifiable Collection of all public shared groups in the system.- Returns:
- unmodifiable Collection of all public shared groups in the system.
-
getVisibleGroupNames
Collection<String> getVisibleGroupNames(String userGroup)
Returns an unmodifiable Collection of groups that are visible to the members of the given group.- Parameters:
userGroup
- The given group- Returns:
- unmodifiable Collection of group names that are visible to the given group.
-
getGroupNames
Collection<String> getGroupNames(int startIndex, int numResults)
Returns the Collection of all groups in the system.- Parameters:
startIndex
- start index in results.numResults
- number of results to return.- Returns:
- the Collection of all group names given the
startIndex
andnumResults
.
-
getGroupNames
Collection<String> getGroupNames(org.xmpp.packet.JID user)
Returns the Collection of group names that an entity belongs to. Implementations should use the bare JID representation of the JID passed as an argument to this method.- Parameters:
user
- the (bare) JID of the entity.- Returns:
- the Collection of group names that the user belongs to.
-
addMember
void addMember(String groupName, org.xmpp.packet.JID user, boolean administrator) throws GroupNotFoundException
Adds an entity to a group (optional operation). Implementations should use the bare JID representation of the JID passed as an argument to this method.- Parameters:
groupName
- the group to add the member touser
- the (bare) JID of the entity to addadministrator
- True if the member is an administrator of the group- Throws:
UnsupportedOperationException
- if the provider does not support the operation.GroupNotFoundException
-
updateMember
void updateMember(String groupName, org.xmpp.packet.JID user, boolean administrator) throws GroupNotFoundException
Updates the privileges of an entity in a group. Implementations should use the bare JID representation of the JID passed as an argument to this method.- Parameters:
groupName
- the group where the change happeneduser
- the (bare) JID of the entity with new privilegesadministrator
- True if the member is an administrator of the group- Throws:
UnsupportedOperationException
- if the provider does not support the operation.GroupNotFoundException
-
deleteMember
void deleteMember(String groupName, org.xmpp.packet.JID user)
Deletes an entity from a group (optional operation). Implementations should use the bare JID representation of the JID passed as an argument to this method.- Parameters:
groupName
- the group name.user
- the (bare) JID of the entity to delete.- Throws:
UnsupportedOperationException
- if the provider does not support the operation.
-
isReadOnly
boolean isReadOnly()
Returns true if this GroupProvider is read-only. When read-only, groups can not be created, deleted, or modified.- Returns:
- true if the user provider is read-only.
-
search
Collection<String> search(String query)
Returns the group names that match a 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
Collection<String> search(String query, int startIndex, int numResults)
Returns the group names that match a 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
- start index in results.numResults
- number of results to return.- Returns:
- all groups that match the search.
-
search
Collection<String> search(String key, String value)
Returns the names of groups that have a property matching the given key/value pair. This provides a simple extensible search mechanism for providers with differing property sets and storage models. The semantics of the key/value matching (wildcard support, scoping, etc.) are unspecified by the interface and may vary for each implementation. Before searching or showing a search UI, use theisSearchSupported()
method to ensure that searching is supported.- Parameters:
key
- The name of a group property (e.g. "sharedRoster.showInRoster")value
- The value to match for the given property- Returns:
- unmodifiable Collection of group names that match the given key/value pair.
-
isSearchSupported
boolean isSearchSupported()
Returns true if group searching is supported by the provider.- Returns:
- true if searching is supported.
-
loadProperties
PersistableMap<String,String> loadProperties(Group group)
Loads the group properties (if any) from the backend data store. If the properties can be changed, the provider implementation must ensure that updates to the resultingMap
are persisted to the backend data store. Otherwise, if a mutator method is called, the implementation should throw anUnsupportedOperationException
. If there are no corresponding properties for the given group, or if the provider does not support group properties, this method should return an empty Map rather than null.- Parameters:
group
- The target group- Returns:
- The properties for the given group
-
-