public class Group extends BasicItem implements Nameable, Removable, SystemItem, Registered
Groups are intended to represent the actual organisation of a company/organisation. For example a top-level group "The company" may contain the sub-groups "Sales", "Marketing" and "Research". Individual users should be added to the sub-groups only.
BASE comes with the predefined group Everyone
,
which cannot contain any members, except that the permission system
works as if everyone is a member.
Modifier and Type | Class and Description |
---|---|
private static class |
Group.QueryRuntimeFilterImpl
A runtime filter implementation that limits a query to only
return groups where the logged in user is a member unless the logged in user
has generic read permission.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EVERYONE
The id of the
Everyone group where all users
are (virtual) members. |
private static QueryRuntimeFilter |
RUNTIME_FILTER
This filter will limit a query to only return groups
where the logged in user is a member unless the logged in user
has generic read permission.
|
static Item |
TYPE
The type of item represented by this class.
|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
MAX_SYSTEM_ID_LENGTH
Modifier and Type | Method and Description |
---|---|
void |
addGroup(Group group)
Add a group as a member to this group.
|
void |
addUser(User user)
Add a user as a member to this group.
|
static Group |
getById(DbControl dc,
int id)
Get a
Group item when you know the ID. |
(package private) GroupData |
getData()
Get the
BasicData object that holds all data for this item. |
java.lang.String |
getDescription()
Get the description for the item.
|
long |
getDiskUsage(QuotaType quotaType,
Location location)
Get the used number of bytes for the specified quota type and location.
|
java.util.Date |
getEntryDate()
Get the date that the item was registered in the database.
|
ItemQuery<Group> |
getGroups()
Get a query that returns the groups that
are members of this group.
|
static java.util.Set<java.lang.Integer> |
getGroupsRecursive(DbControl dc,
java.util.Set<java.lang.Integer> groups)
Load all groups withing groups.
|
(package private) static java.util.Set<java.lang.Integer> |
getGroupsRecursive(Session session,
java.util.Collection<java.lang.Integer> groups) |
java.lang.String |
getName()
Get the name of the item.
|
static Group |
getNew(DbControl dc)
Create a new
Group item. |
ItemQuery<Project> |
getProjects()
Get a query that returns the projects that
this group is a member of.
|
static ItemQuery<Group> |
getQuery()
Get a query configured to retrieve groups.
|
Quota |
getQuota()
Get the
Quota that applies to the group. |
User |
getRemovedBy()
Get the user that flagged this item for removal.
|
java.lang.String |
getSystemId()
Get the system id for the item.
|
Item |
getType()
Get the type of item represented by the object.
|
ItemQuery<User> |
getUsers()
Get a query that returns the users that
are members of this group.
|
java.util.Set<ItemProxy> |
getUsingItems()
Get all:
User :s assigned to this group as a quota group
|
boolean |
hasHiddenMembers()
Does this group have hidden members?
|
(package private) void |
initPermissions(int granted,
int denied)
If the logged in user is a member of this group, read permission
is granted.
|
boolean |
isDefault()
If this group should be assigned to new users by default or not.
|
boolean |
isMember(Group group)
Checks if a group is a member of this group.
|
boolean |
isMember(User user)
Checks if a user is a member of this group.
|
boolean |
isRemoved()
Check if the removed flag is set for this item.
|
boolean |
isSystemItem()
Check if the item is a system item or not.
|
boolean |
isUsed()
Checks if:
A user has been assigned this group as a quota group
There are also other items that can reference a group:
DiscUsage
Other groups
ItemKeys
Projects
Users (as group members)
The links to all these items are automatically deleted if the
group is deleted and aren't included in this check.
|
(package private) void |
onBeforeCommit(Transactional.Action action)
Set group to null in disk usage
where this group is referenced.
|
void |
removeGroup(Group group)
Remove a group that is a member of this group.
|
void |
removeUser(User user)
Remove a user that is a member of this group.
|
void |
setDefault(boolean isDefault)
If this group should be assigned to new users by default or not.
|
void |
setDescription(java.lang.String description)
Set the description for the item.
|
void |
setEntryDate(java.util.Date entryDate)
Set the date the entry was registered in the database.
|
void |
setHiddenMembers(boolean hiddenMembers)
Set the hidden members flag for this group.
|
void |
setName(java.lang.String name)
Set the name of the item.
|
void |
setQuota(Quota quota)
Set the quota for the group.
|
void |
setRemoved(boolean removed)
Set the removed flag for this item.
|
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getVersion
checkPermission, getPermissions, hasPermission
public static final Item TYPE
Item.GROUP
,
getType()
public static final java.lang.String EVERYONE
Everyone
group where all users
are (virtual) members.private static final QueryRuntimeFilter RUNTIME_FILTER
Group(GroupData groupData)
public static Group getNew(DbControl dc) throws BaseException
Group
item.dc
- The DbControl
which will be used for
permission checking and database access.Group
itemBaseException
- If there is an errorpublic static Group getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
Group
item when you know the ID.dc
- The DbControl
which will be used for
permission checking and database access.id
- The ID of the item to loadGroup
itemItemNotFoundException
- If an item with the specified
ID is not foundPermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the itemBaseException
- If there is another errorpublic static java.util.Set<java.lang.Integer> getGroupsRecursive(DbControl dc, java.util.Set<java.lang.Integer> groups)
dc
- The DbControl to use for database accessgroups
- The groups to start withstatic java.util.Set<java.lang.Integer> getGroupsRecursive(Session session, java.util.Collection<java.lang.Integer> groups)
public static ItemQuery<Group> getQuery()
ItemQuery
objectGroupData getData()
BasicItem
BasicData
object that holds all data for this item.public Item getType()
Identifiable
Item
enumeration.getType
in interface Identifiable
public java.lang.String getName()
Nameable
public void setName(java.lang.String name) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_NAME_LENGTH
constant.setName
in interface Nameable
name
- The new name for the itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the name is null or longer
than specified by the Nameable.MAX_NAME_LENGTH
constantpublic java.lang.String getDescription()
Nameable
getDescription
in interface Nameable
String
with a description of the itempublic void setDescription(java.lang.String description) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_DESCRIPTION_LENGTH
constant.setDescription
in interface Nameable
description
- The new description for the itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the description longer
than specified by the Nameable.MAX_DESCRIPTION_LENGTH
constantpublic boolean isRemoved()
Removable
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
removed
- TRUE if the item should be flagged as removed,
FALSE otherwisePermissionDeniedException
- If the logged in user doesn't
have Permission.DELETE
permission for setting the flag
to TRUE or Permission.WRITE
permission for setting the
flag to FALSEpublic User getRemovedBy() throws PermissionDeniedException, ItemNotFoundException
Removable
getRemovedBy
in interface Removable
PermissionDeniedException
- If the logged in user doesn't have
Permission.READ
permission for the userItemNotFoundException
- If the user that removed this item
can't be foundpublic java.lang.String getSystemId()
SystemItem
getSystemId
in interface SystemItem
public boolean isSystemItem()
SystemItem
isSystemItem
in interface SystemItem
public java.util.Date getEntryDate()
Registered
getEntryDate
in interface Registered
public void setEntryDate(java.util.Date entryDate)
Registered
setEntryDate
in interface Registered
entryDate
- A date or null to use today's datevoid onBeforeCommit(Transactional.Action action)
onBeforeCommit
in class BasicItem
Transactional
,
Developer documentation: Transactions,
Developer documentation: Coding rules and guidelines for item classespublic boolean isUsed() throws BaseException
isUsed
in class BasicItem
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public java.util.Set<ItemProxy> getUsingItems()
User
:s assigned to this group as a quota group
getUsingItems
in class BasicItem
BasicItem.addUsingItems(Set, Item, org.hibernate.query.Query)
void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclassBaseException
- If the permissions couldn't be initialisedpublic Quota getQuota() throws PermissionDeniedException, BaseException
Quota
that applies to the group.Quota
item, or null if no quota has
been assigned to this groupPermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the itemBaseException
- If there is some other error.public void setQuota(Quota quota) throws PermissionDeniedException, InvalidDataException
quota
- The new Quota
, or null to
disable quota for this groupPermissionDeniedException
- If the logged in user doesn't
have Permission.WRITE
permission for the group
or Permission.USE
permission for the quotaInvalidDataException
- If the quota is nullpublic long getDiskUsage(QuotaType quotaType, Location location) throws BaseException
quotaType
- The QuotaType
. Null is not allowed.location
- The location. Null is not allowedBaseException
- If there is some kind of error.public boolean isDefault()
public void setDefault(boolean isDefault)
User.addToDefaultRolesAndGroups()
.isDefault
- The new settingPermissionDeniedException
- If the logged in user doesn't
have Permission.WRITE
permission for the group, or if
this group is the EVERYONE
grouppublic boolean hasHiddenMembers()
public void setHiddenMembers(boolean hiddenMembers)
PermissionDeniedException
- If the logged in user doesn't
have Permission.WRITE
permission for the group, or if
this group is the EVERYONE
grouppublic void addUser(User user) throws PermissionDeniedException, InvalidDataException
EVERYONE
group.user
- The user to addPermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for the group and Permission.USE
for the userInvalidDataException
- If the user is nullpublic void removeUser(User user) throws PermissionDeniedException, InvalidDataException
user
- The user to removePermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for the group and Permission.USE
for the userInvalidDataException
- If the user is nullpublic boolean isMember(User user)
addUser(User)
method or has been assigned this group as the User.getQuotaGroup()
.user
- The user to checkpublic ItemQuery<User> getUsers() throws BaseException
BaseException
- If there is an error when building the query.User.getQuery()
public void addGroup(Group group) throws PermissionDeniedException, InvalidDataException
EVERYONE
group.group
- The group to addPermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for both groupsInvalidDataException
- If the group is nullpublic void removeGroup(Group group) throws PermissionDeniedException, InvalidDataException
group
- The group to removePermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for both groupsInvalidDataException
- If the group is nullpublic boolean isMember(Group group)
group
- The group to checkpublic ItemQuery<Group> getGroups()
getQuery()
public ItemQuery<Project> getProjects()
Project.getQuery()