Package org.jivesoftware.openfire.group
Class AbstractGroupProvider
- java.lang.Object
-
- org.jivesoftware.openfire.group.AbstractGroupProvider
-
- All Implemented Interfaces:
GroupProvider
- Direct Known Subclasses:
CrowdGroupProvider
,DefaultGroupProvider
,JDBCGroupProvider
,LdapGroupProvider
public abstract class AbstractGroupProvider extends Object implements GroupProvider
Shared base class for Openfire GroupProvider implementations. By default all mutator methods throwUnsupportedOperationException
. In addition, group search operations are disabled. Subclasses may optionally implement these capabilities, and must also at minimum implement theGroupProvider.getGroup(String)
method.- Author:
- Tom Evans
-
-
Constructor Summary
Constructors Constructor Description AbstractGroupProvider()
-
Method Summary
All Methods Instance Methods Concrete 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).Collection<String>
getPublicSharedGroupNames()
Returns an unmodifiable Collection of all public shared groups in the system.Collection<String>
getSharedGroupNames()
Returns the name of the groups that are shared groups.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()
Always true for a read-only providerboolean
isSearchSupported()
Returns true if the provider supports group search capability.boolean
isSharingSupported()
Returns true if this GroupProvider allows group sharing.PersistableMap<String,String>
loadProperties(Group group)
Returns a customMap
that updates the database whenever a property value is added, changed, or deleted.Collection<String>
search(String query)
Returns a collection of group search results.Collection<String>
search(String query, int startIndex, int numResults)
Returns a collection of group search 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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jivesoftware.openfire.group.GroupProvider
getGroup, getGroupCount, getGroupNames, getGroupNames, getGroupNames
-
-
-
-
Method Detail
-
addMember
public void addMember(String groupName, org.xmpp.packet.JID user, boolean administrator)
Description copied from interface:GroupProvider
Adds an entity to a group (optional operation).- Specified by:
addMember
in interfaceGroupProvider
- Parameters:
groupName
- the group to add the member touser
- the JID of the entity to addadministrator
- True if the member is an administrator of the group- Throws:
UnsupportedOperationException
- if the provider is read only
-
updateMember
public void updateMember(String groupName, org.xmpp.packet.JID user, boolean administrator)
Description copied from interface:GroupProvider
Updates the privileges of an entity in a group.- Specified by:
updateMember
in interfaceGroupProvider
- Parameters:
groupName
- the group where the change happeneduser
- the JID of the entity with new privilegesadministrator
- True if the member is an administrator of the group- Throws:
UnsupportedOperationException
- if the provider is read only
-
deleteMember
public void deleteMember(String groupName, org.xmpp.packet.JID user)
Description copied from interface:GroupProvider
Deletes an entity from a group (optional operation).- Specified by:
deleteMember
in interfaceGroupProvider
- Parameters:
groupName
- the group name.user
- the JID of the entity to delete.- Throws:
UnsupportedOperationException
- if the provider is read only
-
isReadOnly
public boolean isReadOnly()
Always true for a read-only provider- Specified by:
isReadOnly
in interfaceGroupProvider
- Returns:
- true if the user provider is read-only.
-
createGroup
public Group createGroup(String name) throws GroupAlreadyExistsException
Description copied from interface:GroupProvider
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.
- Specified by:
createGroup
in interfaceGroupProvider
- Parameters:
name
- name of the group.- Returns:
- the newly created group.
- Throws:
UnsupportedOperationException
- if the provider is read onlyGroupAlreadyExistsException
- if a group with the same name already exists.
-
deleteGroup
public void deleteGroup(String name)
Description copied from interface:GroupProvider
Deletes the group (optional operation).- Specified by:
deleteGroup
in interfaceGroupProvider
- Parameters:
name
- the name of the group to delete.- Throws:
UnsupportedOperationException
- if the provider is read only
-
setName
public void setName(String oldName, String newName) throws GroupAlreadyExistsException
Description copied from interface:GroupProvider
Sets the name of a group to a new name.- Specified by:
setName
in interfaceGroupProvider
- Parameters:
oldName
- the current name of the group.newName
- the desired new name of the group.- Throws:
GroupAlreadyExistsException
- if the group alrady existsUnsupportedOperationException
- if the provider is read only
-
setDescription
public void setDescription(String name, String description) throws GroupNotFoundException
Description copied from interface:GroupProvider
Updates the group's description.- Specified by:
setDescription
in interfaceGroupProvider
- Parameters:
name
- the group name.description
- the group description.- Throws:
GroupNotFoundException
- if the group could not be foundUnsupportedOperationException
- if the provider is read only
-
isSearchSupported
public boolean isSearchSupported()
Returns true if the provider supports group search capability. This implementation always returns false.- Specified by:
isSearchSupported
in interfaceGroupProvider
- Returns:
- true if searching is supported.
-
search
public Collection<String> search(String query)
Returns a collection of group search results. This implementation returns an empty collection.- Specified by:
search
in interfaceGroupProvider
- Parameters:
query
- the search string for group names.- Returns:
- all groups that match the search.
-
search
public Collection<String> search(String query, int startIndex, int numResults)
Returns a collection of group search results. This implementation returns an empty collection.- Specified by:
search
in interfaceGroupProvider
- 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.
-
getSharedGroupNames
public Collection<String> getSharedGroupNames()
Returns the name of the groups that are shared groups.- Specified by:
getSharedGroupNames
in interfaceGroupProvider
- Returns:
- the name of the groups that are shared groups.
-
getSharedGroupNames
public Collection<String> getSharedGroupNames(org.xmpp.packet.JID user)
Description copied from interface:GroupProvider
Returns an unmodifiable Collection of all shared groups in the system for a given user.- Specified by:
getSharedGroupNames
in interfaceGroupProvider
- Parameters:
user
- The bare JID for the user (node@domain)- Returns:
- unmodifiable Collection of all shared groups in the system for a given user.
-
getVisibleGroupNames
public Collection<String> getVisibleGroupNames(String userGroup)
Description copied from interface:GroupProvider
Returns an unmodifiable Collection of groups that are visible to the members of the given group.- Specified by:
getVisibleGroupNames
in interfaceGroupProvider
- Parameters:
userGroup
- The given group- Returns:
- unmodifiable Collection of group names that are visible to the given group.
-
search
public Collection<String> search(String key, String value)
Description copied from interface:GroupProvider
Returns the names of groups that have a property matching the given key/value pair. This provides an 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 theGroupProvider.isSearchSupported()
method to ensure that searching is supported.- Specified by:
search
in interfaceGroupProvider
- 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.
-
getPublicSharedGroupNames
public Collection<String> getPublicSharedGroupNames()
Description copied from interface:GroupProvider
Returns an unmodifiable Collection of all public shared groups in the system.- Specified by:
getPublicSharedGroupNames
in interfaceGroupProvider
- Returns:
- unmodifiable Collection of all public shared groups in the system.
-
isSharingSupported
public boolean isSharingSupported()
Description copied from interface:GroupProvider
Returns true if this GroupProvider allows group sharing. Shared groups enable roster sharing.- Specified by:
isSharingSupported
in interfaceGroupProvider
- Returns:
- true if the group provider supports group sharing.
-
loadProperties
public PersistableMap<String,String> loadProperties(Group group)
Returns a customMap
that updates the database whenever a property value is added, changed, or deleted.- Specified by:
loadProperties
in interfaceGroupProvider
- Parameters:
group
- The target group- Returns:
- The properties for the given group
-
-