2.17.2: 2011-06-17

net.sf.basedb.core
Class DiskUsage

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<DiskUsageData>
      extended by net.sf.basedb.core.DiskUsage
All Implemented Interfaces:
AccessControlled, Identifiable

public class DiskUsage
extends BasicItem<DiskUsageData>

This class is used to represent the disk usage of DiskConsumable items. The creation, updating and deletion of items of this type is handled entirely by Base using the data package. For each DiskConsuming item there is a corresponding item of this type.

Version:
2.0
Author:
Enell, Nicklas
See Also:
DiskUsageData
Last modified
$Date: 2009-06-24 08:19:59 +0200 (Wed, 24 Jun 2009) $

Field Summary
private  DiskConsumable item
          The item this diks usage information belongs to.
static Item TYPE
          The type of item represented by this class.
 
Constructor Summary
DiskUsage(DiskUsageData data)
          Create a new DiskUsage item.
 
Method Summary
 long getBytes()
          Get the number of bytes the DiskConsumable item is using.
 Group getGroup()
          Get the group that owns the DiskConsumable item or null if ther is none.
 DiskConsumable getItem()
          Get the item this disk usage holds information for
 Item getItemType()
          Get the Item type of the item this annotation set belongs to.
 Location getLocation()
          Get the location of the DiskConsumable item.
static ItemQuery<DiskUsage> getQuery(User user, Group group)
          Get a query configured to retrieve disk usage for the specified user.
 QuotaType getQuotaType()
          Get the QuotaType the DiskConsumable item is using.
static DiskUsageStatistics getStatistics(DbControl dc)
           
 Item getType()
          Get the type of item represented by the object.
 User getUser()
          Get the user that owns the DiskConsumable item.
 Set<ItemProxy> getUsingItems()
          Get the item this disk usage information belongs to.
(package private)  void initPermissions(int granted, int denied)
          READ permission is granted if the logged in user is the owner of this disk usage.
 boolean isUsed()
          Check if this item is used by some other 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
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.DISKUSAGE, getType()

item

private DiskConsumable item
The item this diks usage information belongs to.

Constructor Detail

DiskUsage

DiskUsage(DiskUsageData data)
Create a new DiskUsage item.

Parameters:
data - The data class for this item.
Method Detail

getQuery

public static ItemQuery<DiskUsage> getQuery(User user,
                                            Group group)
Get a query configured to retrieve disk usage for the specified user.

Parameters:
user - The user to retreive disk usage for, null is allowed if the logged in user has generic READ permission for disk usage in which case all items will be returned
group - The group to retrieve the disk usage for
Returns:
An ItemQuery object

getStatistics

public static DiskUsageStatistics getStatistics(DbControl dc)

getType

public Item getType()
Description copied from interface: Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.

Returns:
A value indicating the type of item

isUsed

public boolean isUsed()
Description copied from class: BasicItem
Check if this item is used by some other item. With used we mean that another item is linking to this item in way that prevents this item from beeing deleted. Ie. if we tried to delete an item that is used, we would get a foreign key violation error from the database. If the subclass overrides this method it should propagate the call to the superclass, ie. super.isUsed(), unless it has decided that the item is used by some other means.

Overrides:
isUsed in class BasicItem<DiskUsageData>
Returns:
Always return true. If the DiskUsage is created it is used.
See Also:
BasicItem.getUsingItems()

getUsingItems

public Set<ItemProxy> getUsingItems()
Get the item this disk usage information belongs to.

Overrides:
getUsingItems in class BasicItem<DiskUsageData>
Returns:
A set containing proxies for the items, or an empty set if no items are using this item
Since:
2.2, 2.13
See Also:
BasicItem.addUsingItems(Set, Item, org.hibernate.Query)

initPermissions

void initPermissions(int granted,
                     int denied)
               throws BaseException
READ permission is granted if the logged in user is the owner of this disk usage. All other permissions are denied.

Overrides:
initPermissions in class BasicItem<DiskUsageData>
Parameters:
granted - Permissions that have been granted by the subclass
denied - Permissions that have been denied by the subclass
Throws:
BaseException - If the permissions couldn't be initialised

getItem

public DiskConsumable getItem()
                       throws PermissionDeniedException,
                              BaseException
Get the item this disk usage holds information for

Returns:
The DiskConsumable item
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the item
BaseException - If there is another error
Since:
2.2

getItemType

public Item getItemType()
Get the Item type of the item this annotation set belongs to.

Since:
2.2

getQuotaType

public QuotaType getQuotaType()
                       throws BaseException
Get the QuotaType the DiskConsumable item is using.

Returns:
The @{QuotaType} associated with this DiskUsage item.
Throws:
BaseException - If there is any error

getLocation

public Location getLocation()
Get the location of the DiskConsumable item.

Returns:
The Location of this DiskUsage item.

getBytes

public long getBytes()
Get the number of bytes the DiskConsumable item is using.

Returns:
The number of bytes of this DiskUsage item.

getUser

public User getUser()
             throws BaseException
Get the user that owns the DiskConsumable item.

Returns:
The user
Throws:
BaseException - If there is any error

getGroup

public Group getGroup()
               throws BaseException
Get the group that owns the DiskConsumable item or null if ther is none.

Returns:
The group
Throws:
BaseException - If there is any error

2.17.2: 2011-06-17