Implementation of GroupDatabase that persists
Group objects to a JDBC DataSource, as might typically be provided by a web
container. This implementation looks up the JDBC DataSource using JNDI.
The JNDI name of the datasource, backing table and mapped columns used
by this class are configured via settings in jspwiki.properties.
Configurable properties are these:
Property
Default
Definition
jspwiki.groupdatabase.datasource
jdbc/GroupDatabase
The JNDI name of the DataSource
jspwiki.groupdatabase.table
groups
The table that stores the groups
jspwiki.groupdatabase.membertable
group_members
The table that stores the names of group members
jspwiki.groupdatabase.created
created
The column containing the group's creation timestamp
jspwiki.groupdatabase.creator
creator
The column containing the group creator's name
jspwiki.groupdatabase.name
name
The column containing the group's name
jspwiki.groupdatabase.member
member
The column containing the group member's name
jspwiki.groupdatabase.modified
modified
The column containing the group's last-modified timestamp
jspwiki.groupdatabase.modifier
modifier
The column containing the name of the user who last modified the group
This class is typically used in conjunction with a web container's JNDI resource
factory. For example, Tomcat versions 4 and higher provide a basic JNDI factory
for registering DataSources. To give JSPWiki access to the JNDI resource named
by jdbc/GroupDatabase, you would declare the datasource resource similar to this:
JDBCGroupDatabase commits changes as transactions if the back-end database supports them.
If the database supports transactions, group changes are saved
to permanent storage only when the
JDBCGroupDatabase.commit() method is called. If the database does not
support transactions, then changes are made immediately (during the
JDBCGroupDatabase.save(Group,Principal) method), and the
method no-ops. Thus, callers should always call the
method after saving a profile to guarantee that changes are applied.
Looks up and deletes a
Group from the group database. If the
group database does not contain the supplied Group. this method throws a
NoSuchPrincipalException . The method commits the results
of the delete to persistent storage.
Parameters: group - the group to remove throws: WikiSecurityException - if the database does not contain thesupplied group (thrown as NoSuchPrincipalException) or ifthe commit did not succeed
Returns all wiki groups that are stored in the GroupDatabase as an array
of Group objects. If the database does not contain any groups, this
method will return a zero-length array. This method causes back-end
storage to load the entire set of group; thus, it should be called
infrequently (e.g., at initialization time).
the wiki groups throws: WikiSecurityException - if the groups cannot be returned by the back-end
Initializes the group database based on values from a Properties object.
Parameters: engine - the wiki engine Parameters: props - the properties used to initialize the group database throws: WikiSecurityException - if the database could not be initialized successfully throws: NoRequiredPropertyException - if a required property is not present
Saves a Group to the group database. Note that this method must
fail, and throw an IllegalArgumentException, if the
proposed group is the same name as one of the built-in Roles: e.g.,
Admin, Authenticated, etc. The database is responsible for setting
create/modify timestamps, upon a successful save, to the Group.
The method commits the results of the delete to persistent storage.
Parameters: group - the Group to save Parameters: modifier - the user who saved the Group throws: WikiSecurityException - if the Group could not be saved successfully