Class DiskUsage

java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.DiskUsage
All Implemented Interfaces:
AccessControlled, Identifiable

public class DiskUsage
extends BasicItem
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: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
  • Field Details

  • Constructor Details

    • DiskUsage

      DiskUsage​(DiskUsageData data)
      Create a new DiskUsage item.
      Parameters:
      data - The data class for this item.
  • Method Details

    • 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)
    • getData

      DiskUsageData getData()
      Description copied from class: BasicItem
      Get the BasicData object that holds all data for this item.
      Specified by:
      getData in class BasicItem
    • 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
      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
      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.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
      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

      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