public abstract class OwnedItem<D extends OwnedData> extends BasicItem<D> implements Ownable
BasicItem
class and implements the Ownable
interface.
An Ownable
item is an item that has a
User
as its owner.
Ownable
Modifier and Type | Method and Description |
---|---|
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)
Deprecated.
In 3.3, no replacement
|
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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getType, getVersion
checkPermission, getPermissions, hasPermission
OwnedItem(D ownedData)
public User getOwner() throws PermissionDeniedException, BaseException
Ownable
User
that is the owner of the item.getOwner
in interface Ownable
PermissionDeniedException
- If the logged in user doesn't
have read permission to the ownerBaseException
- If there is another errorpublic void setOwner(User owner) throws PermissionDeniedException, InvalidDataException
Ownable
setOwner
in interface Ownable
owner
- The new owner of the itemPermissionDeniedException
- If the logged in user doesn't
have permission to change the owner on the itemInvalidDataException
- If the owner is nullOwnable.takeOwnership()
public void takeOwnership() throws PermissionDeniedException
Ownable
takeOwnership
in interface Ownable
PermissionDeniedException
- If the logged in user doesn't have
permission to take ownershippublic boolean isOwner()
Ownable
void onBeforeCommit(Transactional.Action action) throws NotLoggedInException, BaseException
BasicItem.onBeforeCommit(Transactional.Action)
method. It sets the owner of the new item to the logged in user, unless
it has already been specified.onBeforeCommit
in class BasicItem<D extends OwnedData>
NotLoggedInException
- If no user is logged inBaseException
- If there is another errorTransactional
,
Developer documentation: Transactions,
Developer documentation: Coding rules and guidelines for item classesvoid initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem<D extends OwnedData>
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclassBaseException
- If the permissions couldn't be initialised@Deprecated OwnedItemInfo toTransferable(OwnedItemInfo info)