2.17.2: 2011-06-17

net.sf.basedb.core
Class SharedItem<D extends SharedData>

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

public abstract class SharedItem<D extends SharedData>
extends OwnedItem<D>
implements Shareable

This class inherits from the OwnedItem class and implements the Shareable interface. An Shareable item is an item that can be shared to User:s, Group:s and Project:s

Version:
2.0
Author:
Nicklas
See Also:
Shareable
Last modified
$Date: 2010-06-22 14:51:41 +0200 (Tue, 22 Jun 2010) $

Field Summary
private  boolean itemKeySet
           
private  boolean projectKeySet
           
 
Constructor Summary
SharedItem(D sharedData)
           
 
Method Summary
 ItemKey getItemKey()
          Get the ItemKey that is used to share this item to users and groups.
 ProjectKey getProjectKey()
          Get the ProjectKey that is used to share this item to projects.
(package private)  void initPermissions(int granted, int denied)
          Grant permissions according to the item and project keys.
 boolean isShared()
          Check if this item has been shared or not.
(package private)  void onBeforeCommit(Transactional.Action action)
          If a project is active, automatically share the new item according to the settings of that project, unless a project or item key has been explicitely set (including null).
 void setItemKey(ItemKey itemKey)
          Set the ItemKey for this item.
 void setProjectKey(ProjectKey projectKey)
          Set the ProjectKey for this item.
(package private)  SharedItemInfo toTransferable(SharedItemInfo info)
           
 
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership, toTransferable
 
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.Ownable
getOwner, isOwner, setOwner, takeOwnership
 
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getType, getVersion
 
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
 

Field Detail

projectKeySet

private boolean projectKeySet

itemKeySet

private boolean itemKeySet
Constructor Detail

SharedItem

SharedItem(D sharedData)
Method Detail

getItemKey

public ItemKey getItemKey()
                   throws PermissionDeniedException,
                          BaseException
Description copied from interface: Shareable
Get the ItemKey that is used to share this item to users and groups.

Specified by:
getItemKey in interface Shareable
Returns:
The ItemKey object
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the key
BaseException - If there is another error

setItemKey

public void setItemKey(ItemKey itemKey)
                throws PermissionDeniedException
Description copied from interface: Shareable
Set the ItemKey for this item.

Specified by:
setItemKey in interface Shareable
Parameters:
itemKey - The new item key for the item, or null to stop sharing this item
Throws:
PermissionDeniedException - If the logged in user doesn't have permission to change the key on the item

getProjectKey

public ProjectKey getProjectKey()
                         throws PermissionDeniedException,
                                BaseException
Description copied from interface: Shareable
Get the ProjectKey that is used to share this item to projects.

Specified by:
getProjectKey in interface Shareable
Returns:
The ProjectKey object
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the key
BaseException - If there is another error

setProjectKey

public void setProjectKey(ProjectKey projectKey)
                   throws PermissionDeniedException
Description copied from interface: Shareable
Set the ProjectKey for this item.

Specified by:
setProjectKey in interface Shareable
Parameters:
projectKey - The new project key for the item, or null to stop sharing this item
Throws:
PermissionDeniedException - If the logged in user doesn't have permission to change the key on the item

isShared

public boolean isShared()
Description copied from interface: Shareable
Check if this item has been shared or not.

Specified by:
isShared in interface Shareable
Returns:
TRUE if this item has been shared to a user, group or project

onBeforeCommit

void onBeforeCommit(Transactional.Action action)
              throws NotLoggedInException,
                     BaseException
If a project is active, automatically share the new item according to the settings of that project, unless a project or item key has been explicitely set (including null).

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

initPermissions

void initPermissions(int granted,
                     int denied)
               throws BaseException
Grant permissions according to the item and project keys.

Overrides:
initPermissions in class OwnedItem<D extends SharedData>
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

SharedItemInfo toTransferable(SharedItemInfo info)
Since:
2.5

2.17.2: 2011-06-17