|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.BasicItem<GroupData> net.sf.basedb.core.Group
public class Group
This class is used to represent groups. Groups are used in the permission system to make it possible for a user to share items with other users.
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.
Role
,
Project
Nested Class Summary | |
---|---|
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. |
Field Summary | |
---|---|
static 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. |
Fields inherited from interface net.sf.basedb.core.Nameable |
---|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH |
Fields inherited from interface net.sf.basedb.core.SystemItem |
---|
MAX_SYSTEM_ID_LENGTH |
Constructor Summary | |
---|---|
Group(GroupData groupData)
|
Method Summary | |
---|---|
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. |
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. |
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 Set<Integer> |
getGroupsRecursive(DbControl dc,
Set<Integer> groups)
Load all groups withing groups. |
(package private) static Set<Integer> |
getGroupsRecursive(org.hibernate.Session session,
Collection<Integer> groups)
|
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. |
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. |
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(String description)
Set the description for the item. |
void |
setHiddenMembers(boolean hiddenMembers)
Set the hidden members flag for this group. |
void |
setName(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. |
Methods inherited from class net.sf.basedb.core.BasicItem |
---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.basedb.core.Identifiable |
---|
getId, getVersion |
Methods inherited from interface net.sf.basedb.core.AccessControlled |
---|
checkPermission, getPermissions, hasPermission |
Field Detail |
---|
public static final Item TYPE
Item.GROUP
,
getType()
public static final String EVERYONE
private static final QueryRuntimeFilter RUNTIME_FILTER
Constructor Detail |
---|
Group(GroupData groupData)
Method Detail |
---|
public static Group getNew(DbControl dc) throws BaseException
Group
item.
dc
- The DbControl
which will be used for
permission checking and database access.
Group
item
BaseException
- 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 load
Group
item
ItemNotFoundException
- If an item with the specified
ID is not found
PermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the item
BaseException
- If there is another errorpublic static Set<Integer> getGroupsRecursive(DbControl dc, Set<Integer> groups)
dc
- The DbControl to use for database accessgroups
- The groups to start with
static Set<Integer> getGroupsRecursive(org.hibernate.Session session, Collection<Integer> groups)
public static ItemQuery<Group> getQuery()
ItemQuery
objectpublic Item getType()
Identifiable
Item
enumeration.
getType
in interface Identifiable
public String getName()
Nameable
getName
in interface Nameable
String
with the name of the itempublic void setName(String name) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_NAME_LENGTH
constant.
setName
in interface Nameable
name
- The new name for the item
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the name is null or longer
than specified by the Nameable.MAX_NAME_LENGTH
constantpublic String getDescription()
Nameable
getDescription
in interface Nameable
String
with a description of the itempublic void setDescription(String description) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_DESCRIPTION_LENGTH
constant.
setDescription
in interface Nameable
description
- The new description for the item
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the description longer
than specified by the Nameable.MAX_DESCRIPTION_LENGTH
constantpublic boolean isRemoved()
Removable
isRemoved
in interface Removable
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
removed
- TRUE if the item should be flagged as removed,
FALSE otherwise
PermissionDeniedException
- 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 String getSystemId()
SystemItem
getSystemId
in interface SystemItem
public boolean isSystemItem()
SystemItem
isSystemItem
in interface SystemItem
public Date getEntryDate()
Registered
getEntryDate
in interface Registered
void onBeforeCommit(Transactional.Action action)
onBeforeCommit
in class BasicItem<GroupData>
Transactional
,
Core API overview - Transaction handling,
Coding rules and guidelines for item classespublic boolean isUsed() throws BaseException
isUsed
in class BasicItem<GroupData>
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems()
User
:s assigned to this group as a quota group
getUsingItems
in class BasicItem<GroupData>
BasicItem.addUsingItems(Set, Item, org.hibernate.Query)
void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem<GroupData>
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass
BaseException
- 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 group
PermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the item
BaseException
- 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 group
PermissionDeniedException
- If the logged in user doesn't
have Permission.WRITE
permission for the group
or Permission.USE
permission for the quota
InvalidDataException
- 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 allowed
BaseException
- If there is some kind of error.public boolean isDefault()
public void setDefault(boolean isDefault)
User.addToDefaultRolesAndGroups()
.
isDefault
- The new setting
PermissionDeniedException
- 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 add
PermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for the group and Permission.USE
for the user
InvalidDataException
- If the user is nullpublic void removeUser(User user) throws PermissionDeniedException, InvalidDataException
user
- The user to remove
PermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for the group and Permission.USE
for the user
InvalidDataException
- 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 check
public 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 add
PermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for both groups
InvalidDataException
- If the group is nullpublic void removeGroup(Group group) throws PermissionDeniedException, InvalidDataException
group
- The group to remove
PermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for both groups
InvalidDataException
- If the group is nullpublic boolean isMember(Group group)
group
- The group to check
public ItemQuery<Group> getGroups()
getQuery()
public ItemQuery<Project> getProjects()
Project.getQuery()
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |