Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.7.1 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jivesoftware.openfire.group
Class JDBCGroupProvider

    java.lang.Object
      org.jivesoftware.openfire.group.JDBCGroupProvider

All Implemented Interfaces:
  GroupProvider

    public class JDBCGroupProvider

extends Object
implements GroupProvider

The JDBC group provider allows you to use an external database to define the make up of groups. It is best used with the JDBCAuthProvider to provide integration between your external system and Openfire. All data is treated as read-only so any set operations will result in an exception. To enable this provider, set the following in the system properties:

- `provider.group.className = org.jivesoftware.openfire.group.JDBCGroupProvider`

Then you need to set your driver, connection string and SQL statements:

- `jdbcProvider.driver = com.mysql.jdbc.Driver`
- `jdbcProvider.connectionString = jdbc:mysql://localhost/dbname?user=username&password=secret`
- `jdbcGroupProvider.groupCountSQL = SELECT count(*) FROM myGroups`
- `jdbcGroupProvider.allGroupsSQL = SELECT groupName FROM myGroups`
- `jdbcGroupProvider.userGroupsSQL = SELECT groupName FORM myGroupUsers WHERE username=?`
- `jdbcGroupProvider.descriptionSQL = SELECT groupDescription FROM myGroups WHERE groupName=?`
- `jdbcGroupProvider.loadMembersSQL = SELECT username FORM myGroupUsers WHERE groupName=? AND isAdmin='N'`
- `jdbcGroupProvider.loadAdminsSQL = SELECT username FORM myGroupUsers WHERE groupName=? AND isAdmin='Y'`

In order to use the configured JDBC connection provider do not use a JDBC connection string, set the following property

- `jdbcGroupProvider.useConnectionProvider = true`

Author:
  David Snopek

Constructor Summary
`JDBCGroupProvider()` Constructor of the JDBCGroupProvider class.

Method Summary
`void` | `addMember(String groupName, org.xmpp.packet.JID user, boolean administrator)` Always throws an UnsupportedOperationException because JDBC groups are read-only.
`Group` | `createGroup(String name)` Always throws an UnsupportedOperationException because JDBC groups are read-only.
`void` | `deleteGroup(String name)` Always throws an UnsupportedOperationException because JDBC groups are read-only.
`void` | `deleteMember(String groupName, org.xmpp.packet.JID user)` Always throws an UnsupportedOperationException because JDBC groups are read-only.
`Group` | `getGroup(String name)` Returns a group based on it's 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 start, int num)` 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>` | `getSharedGroupsNames()` Returns an unmodifiable Collection of all shared groups in the system.
`boolean` | `isReadOnly()` Always returns true because JDBC groups are read-only.
`boolean` | `isSearchSupported()` Returns true if group searching is supported by the provider.
`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.
`void` | `setDescription(String name, String description)` Always throws an UnsupportedOperationException because JDBC groups are read-only.
`void` | `setName(String oldName, String newName)` Always throws an UnsupportedOperationException because JDBC groups are read-only.
`void` | `updateMember(String groupName, org.xmpp.packet.JID user, boolean administrator)` Always throws an UnsupportedOperationException because JDBC groups are read-only.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JDBCGroupProvider

    public JDBCGroupProvider()

  Constructor of the JDBCGroupProvider class.

Method Detail

### createGroup

    public Group createGroup(String name)
                      throws UnsupportedOperationException

  Always throws an UnsupportedOperationException because JDBC groups are read-only.

  Specified by:
    `createGroup` in interface `GroupProvider`
  Parameters:
    `name` - the name of the group to create.
  Returns:
    the newly created group.
  Throws:
    `UnsupportedOperationException` - when called.

### deleteGroup

    public void deleteGroup(String name)
                     throws UnsupportedOperationException

  Always throws an UnsupportedOperationException because JDBC groups are read-only.

  Specified by:
    `deleteGroup` in interface `GroupProvider`
  Parameters:
    `name` - the name of the group to delete
  Throws:
    `UnsupportedOperationException` - when called.

### getGroup

    public Group getGroup(String name)
                   throws GroupNotFoundException

  Description copied from interface: `GroupProvider`
  Returns a group based on it's name.

  Specified by:
    `getGroup` in interface `GroupProvider`
  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

    public void setName(String oldName,
                        String newName)
                 throws UnsupportedOperationException

  Always throws an UnsupportedOperationException because JDBC groups are read-only.

  Specified by:
    `setName` in interface `GroupProvider`
  Parameters:
    `oldName` - the current name of the group.
    `newName` - the desired new name of the group.
  Throws:
    `UnsupportedOperationException` - when called.

### setDescription

    public void setDescription(String name,
                               String description)
                        throws UnsupportedOperationException

  Always throws an UnsupportedOperationException because JDBC groups are read-only.

  Specified by:
    `setDescription` in interface `GroupProvider`
  Parameters:
    `name` - the group name.
    `description` - the group description.
  Throws:
    `UnsupportedOperationException` - when called.

### getGroupCount

    public int getGroupCount()

  Description copied from interface: `GroupProvider`
  Returns the number of groups in the system.

  Specified by:
    `getGroupCount` in interface `GroupProvider`
  Returns:
    the number of groups in the system.

### getSharedGroupsNames

    public Collection<String> getSharedGroupsNames()

  Description copied from interface: `GroupProvider`
  Returns an unmodifiable Collection of all shared groups in the system.

  Specified by:
    `getSharedGroupsNames` in interface `GroupProvider`
  Returns:
    unmodifiable Collection of all shared groups in the system.

### getGroupNames

    public Collection<String> getGroupNames()

  Description copied from interface: `GroupProvider`
  Returns the Collection of all group names in the system.

  Specified by:
    `getGroupNames` in interface `GroupProvider`
  Returns:
    the Collection of all groups.

### getGroupNames

    public Collection<String> getGroupNames(int start,
                                            int num)

  Description copied from interface: `GroupProvider`
  Returns the Collection of all groups in the system.

  Specified by:
    `getGroupNames` in interface `GroupProvider`
  Parameters:
    `start` - start index in results.
    `num` - number of results to return.
  Returns:
    the Collection of all group names given the `startIndex` and `numResults`.

### getGroupNames

    public Collection<String> getGroupNames(org.xmpp.packet.JID user)

  Description copied from interface: `GroupProvider`
  Returns the Collection of group names that an entity belongs to.

  Specified by:
    `getGroupNames` in interface `GroupProvider`
  Parameters:
    `user` - the JID of the entity.
  Returns:
    the Collection of group names that the user belongs to.

### addMember

    public void addMember(String groupName,
                          org.xmpp.packet.JID user,
                          boolean administrator)
                   throws UnsupportedOperationException

  Always throws an UnsupportedOperationException because JDBC groups are read-only.

  Specified by:
    `addMember` in interface `GroupProvider`
  Parameters:
    `groupName` - name of a group.
    `user` - the JID of the user to add
    `administrator` - true if is an administrator.
  Throws:
    `UnsupportedOperationException` - when called.

### updateMember

    public void updateMember(String groupName,
                             org.xmpp.packet.JID user,
                             boolean administrator)
                      throws UnsupportedOperationException

  Always throws an UnsupportedOperationException because JDBC groups are read-only.

  Specified by:
    `updateMember` in interface `GroupProvider`
  Parameters:
    `groupName` - the naame of a group.
    `user` - the JID of the user with new privileges
    `administrator` - true if is an administrator.
  Throws:
    `UnsupportedOperationException` - when called.

### deleteMember

    public void deleteMember(String groupName,
                             org.xmpp.packet.JID user)
                      throws UnsupportedOperationException

  Always throws an UnsupportedOperationException because JDBC groups are read-only.

  Specified by:
    `deleteMember` in interface `GroupProvider`
  Parameters:
    `groupName` - the name of a group.
    `user` - the JID of the user to delete.
  Throws:
    `UnsupportedOperationException` - when called.

### isReadOnly

    public boolean isReadOnly()

  Always returns true because JDBC groups are read-only.

  Specified by:
    `isReadOnly` in interface `GroupProvider`
  Returns:
    true because all JDBC functions are read-only.

### search

    public Collection<String> search(String query)

  Description copied from interface: `GroupProvider`
  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 `GroupProvider.isSearchSupported()` method to ensure that searching is supported.

  Specified by:
    `search` in interface `GroupProvider`
  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)

  Description copied from interface: `GroupProvider`
  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 `GroupProvider.isSearchSupported()` method to ensure that searching is supported.

  Specified by:
    `search` in interface `GroupProvider`
  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.

### isSearchSupported

    public boolean isSearchSupported()

  Description copied from interface: `GroupProvider`
  Returns true if group searching is supported by the provider.

  Specified by:
    `isSearchSupported` in interface `GroupProvider`
  Returns:
    true if searching is supported.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.7.1 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2008 Jive Software.