Package org.jivesoftware.openfire.group
Class GroupMultiProvider
java.lang.Object
org.jivesoftware.openfire.group.GroupMultiProvider
- All Implemented Interfaces:
GroupProvider
- Direct Known Subclasses:
HybridGroupProvider,MappedGroupProvider
A
GroupProvider that delegates to one or more 'backing' GroupProvider.- Author:
- Guus der Kinderen, guus@goodbytes.nl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an entity to a group (optional operation).createGroup(String name) Creates a group with the given name in the first provider that is not read-only.voiddeleteGroup(String name) Removes a group from all non-read-only providers.voiddeleteMember(String groupName, org.xmpp.packet.JID user) Deletes an entity from a group (optional operation).Loads a group from the first provider that contains the group.intReturns the number of groups in the system, calculated as the sum of groups in each provider.Returns the Collection of all group names in each of the providers.getGroupNames(int startIndex, int numResults) Returns the Collection of all groups provided by each of the providers, ordered by provider-order.getGroupNames(org.xmpp.packet.JID user) Returns the Collection of group names that an entity belongs to.Returns an unmodifiable Collection of all public shared groups by each of the providers that support sharing.Returns an unmodifiable Collection of all shared groups from each provider that supports group sharing.getSharedGroupNames(org.xmpp.packet.JID user) Returns an unmodifiable Collection of all shared groups in the system for a given user.getVisibleGroupNames(String userGroup) Returns an unmodifiable Collection of groups that are visible to the members of the given group.static GroupProviderinstantiate(SystemProperty<Class> implementationProperty) Instantiates a GroupProvider based on Class-based system property.static GroupProviderinstantiate(SystemProperty<Class> implementationProperty, SystemProperty<String> configProperty) Instantiates a GroupProvider based on Class-based system property.booleanReturns whether all backing providers are read-only.booleanReturns true if group searching is supported by at least one of the providers.booleanReturns true if at least one provider allows group sharing.loadProperties(Group group) Loads the group properties (if any) from the backend data store.Returns the group names that match a search.Returns the group names that match a search.Returns the names of groups that have a property matching the given key/value pair.voidsetDescription(String name, String description) Updates the group's description in the provider that is used for this group.voidSets the name of a group to a new name in the provider that is used for this group.voidupdateMember(String groupName, org.xmpp.packet.JID user, boolean administrator) Updates the privileges of an entity in a group.
-
Constructor Details
-
GroupMultiProvider
public GroupMultiProvider()
-
-
Method Details
-
instantiate
Instantiates a GroupProvider based on Class-based system property. When the property is not set, this method returns null. When the property is set, but an exception occurs while instantiating the class, this method logs the error and returns null. GroupProvider classes are required to have a public, no-argument constructor.- Parameters:
implementationProperty- A property that defines the class of the instance to be returned.- Returns:
- A group provider (can be null).
-
instantiate
public static GroupProvider instantiate(@Nonnull SystemProperty<Class> implementationProperty, @Nullable SystemProperty<String> configProperty) Instantiates a GroupProvider based on Class-based system property. When the property is not set, this method returns null. When the property is set, but an exception occurs while instantiating the class, this method logs the error and returns null. GroupProvider classes are required to have a public, no-argument constructor, but can have an optional additional constructor that takes a single String argument. If such constructor is defined, then it is invoked with the value of the second argument of this method. This is typically used to (but needs not) identify a property (by name) that holds additional configuration for the to be instantiated GroupProvider. This implementation will pass on any non-empty value to the constructor. When a configuration argument is provided, but no constructor exists in the implementation that accepts a single String value, this method will log a warning and attempt to return an instance based on the no-arg constructor of the class.- Parameters:
implementationProperty- A property that defines the class of the instance to be returned.configProperty- an opaque string value passed to the constructor.- Returns:
- A group provider (can be null).
-
getGroupCount
public int getGroupCount()Returns the number of groups in the system, calculated as the sum of groups in each provider.- Specified by:
getGroupCountin interfaceGroupProvider- Returns:
- the number of groups in the system.
-
getGroupNames
Returns the Collection of all group names in each of the providers.- Specified by:
getGroupNamesin interfaceGroupProvider- Returns:
- the Collection of all groups.
-
isSharingSupported
public boolean isSharingSupported()Returns true if at least one provider allows group sharing. Shared groups enable roster sharing.- Specified by:
isSharingSupportedin interfaceGroupProvider- Returns:
- true if group sharing is supported.
-
getVisibleGroupNames
Returns an unmodifiable Collection of groups that are visible to the members of the given group.- Specified by:
getVisibleGroupNamesin interfaceGroupProvider- Parameters:
userGroup- The given group- Returns:
- unmodifiable Collection of group names that are visible to the given group.
-
getGroupNames
Returns the Collection of all groups provided by each of the providers, ordered by provider-order.- Specified by:
getGroupNamesin interfaceGroupProvider- Parameters:
startIndex- start index in results.numResults- number of results to return.- Returns:
- the Collection of all group names given the
startIndexandnumResults.
-
getGroupNames
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.- Specified by:
getGroupNamesin interfaceGroupProvider- Parameters:
user- the (bare) JID of the entity.- Returns:
- the Collection of group names that the user belongs to.
-
isReadOnly
public boolean isReadOnly()Returns whether all backing providers are read-only. When read-only, groups can not be created, deleted, or modified. If at least one provider is not read-only, this method returns false.- Specified by:
isReadOnlyin interfaceGroupProvider- Returns:
- true when all backing providers are read-only, otherwise false.
-
search
Description copied from interface:GroupProviderReturns 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
GroupProvider.isSearchSupported()method to ensure that searching is supported.- Specified by:
searchin interfaceGroupProvider- Parameters:
query- the search string for group names.- Returns:
- all groups that match the search.
-
search
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. This method throws an UnsupportedOperationException when none of the backing providers support search.- Specified by:
searchin 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.
- Throws:
UnsupportedOperationException- When none of the providers support search.
-
search
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. When a key/value combination ia provided that are not supported by a particular provider, this is ignored by that provider (but can still be used by other providers). Before searching or showing a search UI, use theisSearchSupported()method to ensure that searching is supported.- Specified by:
searchin 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.
- Throws:
UnsupportedOperationException- When none of the providers support search.
-
isSearchSupported
public boolean isSearchSupported()Returns true if group searching is supported by at least one of the providers.- Specified by:
isSearchSupportedin interfaceGroupProvider- Returns:
- true if searching is supported.
-
getGroup
Loads a group from the first provider that contains the group.- Specified by:
getGroupin interfaceGroupProvider- Parameters:
name- the name of the group (cannot be null or empty).- Returns:
- The group (never null).
- Throws:
GroupNotFoundException- When none of the providers contains the group.
-
createGroup
Creates a group with the given name in the first provider that is not read-only.- Specified by:
createGroupin interfaceGroupProvider- 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- if the provided new name is an unacceptable value.
-
deleteGroup
Removes a group from all non-read-only providers.- Specified by:
deleteGroupin interfaceGroupProvider- Parameters:
name- the name of the group to delete.- Throws:
GroupNotFoundException
-
setName
public void setName(String oldName, String newName) throws GroupAlreadyExistsException, GroupNameInvalidException, GroupNotFoundException Sets the name of a group to a new name in the provider that is used for this group.- Specified by:
setNamein interfaceGroupProvider- 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.GroupNotFoundException- if the provided old name does not refer to an existing group.GroupNameInvalidException- if the provided new name is an unacceptable value.
-
setDescription
Updates the group's description in the provider that is used for this group.- Specified by:
setDescriptionin interfaceGroupProvider- Parameters:
name- the group name.description- the group description.- Throws:
GroupNotFoundException- if no existing group could be found to update.
-
addMember
public 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.- Specified by:
addMemberin interfaceGroupProvider- 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- if the provided group name does not refer to an existing group.
-
updateMember
public 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.- Specified by:
updateMemberin interfaceGroupProvider- 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- if the provided group name does not refer to an existing group.
-
deleteMember
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.- Specified by:
deleteMemberin interfaceGroupProvider- Parameters:
groupName- the group name.user- the (bare) JID of the entity to delete.- Throws:
UnsupportedOperationException- if the provider does not support the operation.
-
loadProperties
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 resultingMapare 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.- Specified by:
loadPropertiesin interfaceGroupProvider- Parameters:
group- The target group- Returns:
- The properties for the given group
-