|
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<QuotaData> net.sf.basedb.core.Quota
public class Quota
This class is used to represent disk quota settings for users and groups. All users must have a quota that can be either assigned directly to the user or via a group where the user is a member.
Quota can be specified as a total for all types/locations, or with individual settings for each type/location.
Quota is handled like this:
DiskConsumable
item tells BASE
about the number of bytes, type of quota and location of the
item.
OwnedItem
creates a
DiskUsage
item to hold that information
and links it with the Quota
for the owner
of the DiskConsumable
item.
QuotaException
.
QuotaData
Nested Class Summary | |
---|---|
private static class |
Quota.QueryRuntimeFilterImpl
A runtime filter implementation that limits a query to only return the quota assigned to the logged in user unless the logged in user has generic read permission. |
Field Summary | |
---|---|
static String |
DEFAULT
The ID for the system default quota, which is assigned to new users unless another quota is specified. |
private static QueryRuntimeFilter |
RUNTIME_FILTER
This filter will only return the logged in user's quota unless the logged in user has generic read permission. |
static Item |
TYPE
The type of item represented by this class. |
static long |
UNDEFINED
Quota is is not defined. |
static long |
UNLIMITED
Quota is unlimited. |
static String |
UNRESTRICTED
The ID for the unrestricted quota, which gives users unlimited disk space. |
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 | |
---|---|
Quota(QuotaData data)
Create a new Quota item. |
Method Summary | |
---|---|
static Quota |
getById(DbControl dc,
int id)
Get a Quota item when you know the ID. |
String |
getDescription()
Get the description for the item. |
String |
getName()
Get the name of the item. |
static Quota |
getNew(DbControl dc,
long total)
Create a new Quota item. |
static ItemQuery<Quota> |
getQuery()
Get a query configured to retrieve quota. |
long |
getQuotaValue(QuotaType quotaType,
Location location)
Get the quota for the specified type and location. |
String |
getSystemId()
Get the system id for the item. |
Item |
getType()
Get the type of item represented by the object. |
Set<ItemProxy> |
getUsingItems()
Get all: User :s assigned to this quota
Group :s assigned to this quota
|
(package private) void |
initPermissions(int granted,
int denied)
The logged in user has read permission to the quota assigned to him/her, directly or through group quota. |
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 Group has been assigned this quota
a User has been assigned this quota
|
void |
setDescription(String description)
Set the description for the item. |
void |
setName(String name)
Set the name of the item. |
void |
setQuotaValue(QuotaType quotaType,
Location location,
long bytes)
Set the quota for the specified type, location and size. |
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, onBeforeCommit, 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.QUOTA
,
getType()
public static final String DEFAULT
public static final String UNRESTRICTED
public static final long UNLIMITED
public static final long UNDEFINED
private static final QueryRuntimeFilter RUNTIME_FILTER
Constructor Detail |
---|
Quota(QuotaData data)
Quota
item.
data
- The data class for this item.Method Detail |
---|
public static Quota getNew(DbControl dc, long total) throws BaseException
Quota
item.
dc
- The DbControl
which will be used for
permission checking and database access.total
- The total size inte bytes of this Quota
.
Quota
item
PermissionDeniedException
- This exception is thrown if
the logged in user doesn't have CREATE
permission for this type of items
BaseException
- This exception is thrown if there is another
errorpublic static Quota getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
Quota
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
Quota
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 ItemQuery<Quota> 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 boolean isUsed() throws BaseException
isUsed
in class BasicItem<QuotaData>
true
if this item is used,
false
otherwise
BaseException
- If there is another errorBasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems()
User
:s assigned to this quota
Group
:s assigned to this quota
getUsingItems
in class BasicItem<QuotaData>
BasicItem.addUsingItems(Set, Item, org.hibernate.Query)
void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem<QuotaData>
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass
BaseException
- If there is an errorpublic void setQuotaValue(QuotaType quotaType, Location location, long bytes) throws InvalidDataException, PermissionDeniedException
quotaType
- The QuotaType
for this Quota
location
- The location for this Quota
bytes
- The maximum number of bytes that can be used, or
UNLIMITED
if the quota should be unlimited,
or UNDEFINED
if the quota setting should be
removed
InvalidDataException
- If any of the parameters is wrong.
PermissionDeniedException
- If the user has no write permissions.public long getQuotaValue(QuotaType quotaType, Location location)
quotaType
- The @link QuotaType QuotaType}location
- The location of the quota
UNLIMITED
if the quota is unlimited or
UNDEFINED
if the quota is not defined
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |