public class Quota extends BasicItem implements Nameable, SystemItem, Removable
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
Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.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 java.lang.String |
UNRESTRICTED
The ID for the unrestricted quota, which gives users
unlimited disk space.
|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
MAX_SYSTEM_ID_LENGTH
Constructor and Description |
---|
Quota(QuotaData data)
Create a new
Quota item. |
Modifier and Type | Method and Description |
---|---|
static Quota |
getById(DbControl dc,
int id)
Get a
Quota item when you know the ID. |
(package private) QuotaData |
getData()
Get the
BasicData object that holds all data for this item. |
java.lang.String |
getDescription()
Get the description for the item.
|
java.lang.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.
|
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.
|
java.util.Set<ItemProxy> |
getUsingItems()
|
(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()
|
void |
setDescription(java.lang.String description)
Set the description for the item.
|
void |
setName(java.lang.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.
|
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getVersion
checkPermission, getPermissions, hasPermission
public static final Item TYPE
ITEM.QUOTA
,
getType()
public static final java.lang.String DEFAULT
public static final java.lang.String UNRESTRICTED
public static final long UNLIMITED
public static final long UNDEFINED
private static final QueryRuntimeFilter RUNTIME_FILTER
Quota(QuotaData data)
Quota
item.data
- The data class for this item.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
itemPermissionDeniedException
- This exception is thrown if
the logged in user doesn't have CREATE
permission for this type of itemsBaseException
- 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 loadQuota
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 ItemQuery<Quota> getQuery()
ItemQuery
objectQuotaData 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 boolean isUsed() throws BaseException
isUsed
in class BasicItem
true
if this item is used,
false
otherwiseBaseException
- If there is another errorBasicItem.getUsingItems()
public java.util.Set<ItemProxy> getUsingItems()
getUsingItems
in class BasicItem
BasicItem.addUsingItems(Set, Item, org.hibernate.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 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
removedInvalidDataException
- If any of the parameters is wrong.PermissionDeniedException
- If the user has no write permissions.