2.17.2: 2011-06-17

net.sf.basedb.core
Class OwnedItem<D extends OwnedData>

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.OwnedItem<D>
All Implemented Interfaces:
AccessControlled, Identifiable, Ownable
Direct Known Subclasses:
Job, Project, SharedItem

public abstract class OwnedItem<D extends OwnedData>
extends BasicItem<D>
implements Ownable

This class inherits from the BasicItem class and implements the Ownable interface. An Ownable item is an item that has a User as its owner.

Version:
2.0
Author:
Nicklas
See Also:
Ownable
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Constructor Summary
OwnedItem(D ownedData)
           
 
Method Summary
 User getOwner()
          Get the User that is the owner of the item.
(package private)  void initPermissions(int granted, int denied)
          If the logged in user is the owner of this item, DELETE, SET_OWNER and SET_PERMISSION permission is granted.
 boolean isOwner()
          Check if the logged in user is the owner of this item or not.
(package private)  void onBeforeCommit(Transactional.Action action)
          Overrides the BasicItem.onBeforeCommit(Transactional.Action) method.
 void setOwner(User owner)
          Change the owner of the item.
 void takeOwnership()
          Take ownership of the item.
(package private)  OwnedItemInfo toTransferable(OwnedItemInfo info)
           
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, 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, getType, getVersion
 
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
 

Constructor Detail

OwnedItem

OwnedItem(D ownedData)
Method Detail

getOwner

public User getOwner()
              throws PermissionDeniedException,
                     BaseException
Description copied from interface: Ownable
Get the User that is the owner of the item.

Specified by:
getOwner in interface Ownable
Returns:
The owner of the item
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the owner
BaseException - If there is another error

setOwner

public void setOwner(User owner)
              throws PermissionDeniedException,
                     InvalidDataException
Description copied from interface: Ownable
Change the owner of the item.

Specified by:
setOwner in interface Ownable
Parameters:
owner - The new owner of the item
Throws:
PermissionDeniedException - If the logged in user doesn't have permission to change the owner on the item
InvalidDataException - If the owner is null
See Also:
Ownable.takeOwnership()

takeOwnership

public void takeOwnership()
                   throws PermissionDeniedException
Description copied from interface: Ownable
Take ownership of the item.

Specified by:
takeOwnership in interface Ownable
Throws:
PermissionDeniedException - If the logged in user doesn't have permission to take ownership

isOwner

public boolean isOwner()
Description copied from interface: Ownable
Check if the logged in user is the owner of this item or not.

Specified by:
isOwner in interface Ownable
Returns:
TRUE if the logged in user is the owner, FALSE otherwise

onBeforeCommit

void onBeforeCommit(Transactional.Action action)
              throws NotLoggedInException,
                     BaseException
Overrides the BasicItem.onBeforeCommit(Transactional.Action) method. It sets the owner of the new item to the logged in user, unless it has already been specified.

Overrides:
onBeforeCommit in class BasicItem<D extends OwnedData>
Throws:
NotLoggedInException - If no user is logged in
BaseException - If there is another error
See Also:
Transactional, Core API overview - Transaction handling, Coding rules and guidelines for item classes

initPermissions

void initPermissions(int granted,
                     int denied)
               throws BaseException
If the logged in user is the owner of this item, DELETE, SET_OWNER and SET_PERMISSION permission is granted.

Overrides:
initPermissions in class BasicItem<D extends OwnedData>
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

toTransferable

OwnedItemInfo toTransferable(OwnedItemInfo info)
Since:
2.5

2.17.2: 2011-06-17