Package com.iizix.server.db
Class GroupInfo
java.lang.Object
com.iizix.server.db.GroupInfo
Class holding information about user groups for the server.
The database table is created with:
CREATE TABLE IZS.GROUPS ( gid BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, name VARCHAR(80) NOT NULL, descr VARCHAR(160) NOT NULL, disabled BOOLEAN NOT NULL DEFAULT FALSE, all_apps BOOLEAN NOT NULL DEFAULT FALSE, UNIQUE (name) );
- Author:
- Christopher Mindus
- Field SummaryFields
- Method SummaryModifier and TypeMethodDescription- booleanReturns if the group allows users to run all apps without further app checking.- static GroupInfo- createGroup- (String name, String descr, boolean isDisabled, boolean areAllAppsAllowed) Creates a new group with the specified information.- static GroupInfo- createGroup- (Connection conn, String name, String descr, boolean isDisabled, boolean areAllAppsAllowed) Creates a new group with the specified information.- booleanDeletes the group from the database.- boolean- deleteGroup- (Connection conn) Deletes the group from the database.- static GroupInfo[]- getAllGroups- (boolean reload) Gets all the groups from the database.- static GroupInfo[]- getAllGroups- (Connection conn) Gets all the groups from the database.Gets the description of the group.- static GroupInfoGets the group with the specified name.- static GroupInfo- getGroup- (Connection conn, String name) Gets the group from the database and caches the entry.- static GroupInfo[]- getGroups- (long[] groupIDs, boolean reload) Gets the groups for the group IDs.- static GroupInfo[]Gets the groups for the names.- static GroupInfo[]- getGroups- (Connection conn, String[] names) Gets the groups for the names from the database.- getName()Gets the name of the group.- booleanReturns if the group is enabled or disabled.- static GroupInfo[]- loadGroups- (Connection conn, boolean returnGroupInfoArray) Loads all the groups.- voidRefreshes the DB information for the group.- boolean- setInformation- (String name, String descr, Boolean isDisabled, Boolean areAllAppsAllowed) Updates the information of the group.- toString()Outputs a debug string.
- Field Details- DEFAULT_GROUP_NAMEThe group name of the Default normal user group: "Default".- See Also:
 
- ADMIN_GROUP_NAMEThe group name of the Administrators group: "Administrators".- See Also:
 
- gidpublic final long gidThe unique group ID.
 
- Method Details- loadGroupspublic static GroupInfo[] loadGroups- (Connection conn, boolean returnGroupInfoArray) throws SQLException Loads all the groups. Previous groups are cleared.- Parameters:
- conn- The database connection.
- returnGroupInfoArray- Flag to return the array of all groups.
- Returns:
- The array of all groups if returnGroupInfoArray is true, null otherwise.
- Throws:
- SQLException- For SQL errors.
 
- getGroupGets the group from the database and caches the entry.- Parameters:
- conn- The database connection.
- name- The group name, wildcard "*" means all groups and will fail this call.
- Throws:
- SQLException- For SQL errors.
- NotFoundException- If the name is "*" or not found.
 
- getGroupGets the group with the specified name.- Parameters:
- name- The group name, wildcard "*" means all groups and will fail this call.
- reload- Flag to reload the group informations from the database.
- Returns:
- The group found, or null if not found.
- Throws:
- SQLException- For SQL errors.
- NotFoundException- If the name is "*".
 
- getAllGroupsGets all the groups from the database.- Parameters:
- reload- Flag to reload the group informations from the database.
- Returns:
- The array of group informations.
- Throws:
- SQLException- For SQL errors.
 
- getAllGroupsGets all the groups from the database.- Parameters:
- conn- The JDBC connection.
- Returns:
- The array of group informations.
- Throws:
- SQLException- For SQL errors.
 
- getGroupspublic static GroupInfo[] getGroups- (String[] names, boolean reload) throws NotFoundException, SQLException Gets the groups for the names.- Parameters:
- names- The group names to find. The wildcard "*" group name means all groups.
- reload- Flag to reload the group informations from the database.
- Returns:
- The array of group informations.
- Throws:
- NotFoundException- If a group is not found.
- SQLException- For SQL errors.
 
- getGroupspublic static GroupInfo[] getGroups- (Connection conn, String[] names) throws NotFoundException, SQLException Gets the groups for the names from the database.- Parameters:
- names- The group names to find. The wildcard "*" group name means all groups.
- Returns:
- The array of group informations.
- Throws:
- NotFoundException- If a group is not found.
- SQLException- For SQL errors.
 
- getGroupspublic static GroupInfo[] getGroups- (long[] groupIDs, boolean reload) throws NotFoundException, SQLException Gets the groups for the group IDs.- Parameters:
- groupIDs- The groupIDs to find.
- reload- Flag to reload the group informations from the database.
- Returns:
- The array of group informations.
- Throws:
- NotFoundException- If a group is not found.
- SQLException- For SQL errors.
 
- createGrouppublic static GroupInfo createGroup- (String name, String descr, boolean isDisabled, boolean areAllAppsAllowed) throws SQLException Creates a new group with the specified information.- Note that the name AND the lower case name of the group should not exist, otherwise you will get an SQLException of a duplicate entry. - Parameters:
- name- The group name (min 3 characters, max 80 characters).
- descr- The group description (max 160 characters, cannot be null).
- isDisabled- The group is initially disabled if true, enabled if false.
- areAllAppsAllowed- Enable group to access all apps (be careful with this one, it is primarily used for Administrator groups).
- Returns:
- The GroupInfo of the new group created.
- Throws:
- IllegalArgumentException- If name or descr lengths are invalid.
- SQLException- For SQL errors.
- NullPointerException- If name or descr parameters are null.
 
- createGrouppublic static GroupInfo createGroup- (Connection conn, String name, String descr, boolean isDisabled, boolean areAllAppsAllowed) throws SQLException Creates a new group with the specified information.- Note that the name AND the lower case name of the group should not exist, otherwise you will get an SQLException of a duplicate entry. - Parameters:
- conn- The JDBC connection.
- name- The group name (min 3 characters, max 80 characters).
- descr- The group description (max 160 characters, cannot be null).
- isDisabled- The group is initially disabled if true, enabled if false.
- areAllAppsAllowed- Enable group to access all apps (be careful with this one, it is primarily used for Administrator groups).
- Returns:
- The GroupInfo of the new group created.
- Throws:
- IllegalArgumentException- If name or descr lengths are invalid.
- SQLException- For SQL errors.
- NullPointerException- If conn, name or descr parameters are null.
 
- getNameGets the name of the group.- Returns:
- The user name.
 
- getDescriptionGets the description of the group.- Returns:
- A descriptive text.
 
- isDisabledpublic boolean isDisabled()Returns if the group is enabled or disabled.- Returns:
- true if disabled, false for enabled (default).
 
- areAllAppsAllowedpublic boolean areAllAppsAllowed()Returns if the group allows users to run all apps without further app checking.- Returns:
- true to allow all apps (typically for administrators), false to perform default checking with the defined apps.
 
- toStringOutputs a debug string.
- refreshFromDBRefreshes the DB information for the group.- Throws:
- SQLException- For SQL errors.
 
- setInformationpublic boolean setInformation- (String name, String descr, Boolean isDisabled, Boolean areAllAppsAllowed) throws NotFoundException, SQLException Updates the information of the group.- Parameters:
- name- The new name (min 3 characters, max 80 characters), null for same name.
- descr- The new description (max 160 characters), null for same description.
- isDisabled- Flag for group disabled, null for no change.
- areAllAppsAllowed- Flag for all apps are allowed, null for no change.
- Throws:
- IllegalArgumentException- If name or descr lengths are invalid.
- NotFoundException- If the group is not found (has been removed).
- SQLException- For SQL errors.
 
- deleteGroupDeletes the group from the database. No commit operation is done on the connection if you wish to perform multiple operations as a unit of operation.- Parameters:
- conn- The SQL connection.
- Returns:
- true if successfully deleted, false if already deleted.
- Throws:
- SQLException- For SQL errors.
 
- deleteGroupDeletes the group from the database. If you wish to delete multiple groups, use the- deleteGroup(Connection)call instead and grab a connection from the pool.- Returns:
- true if successfully deleted, false if already deleted.
- Throws:
- SQLException- For SQL errors.