2.10.1: 2009-03-24

net.sf.basedb.core
Class ShareableUtil

java.lang.Object
  extended by net.sf.basedb.core.ShareableUtil

public class ShareableUtil
extends Object

Utility methods that will make it easier to implement the Shareable interface, including data validation.

Version:
2.0
Author:
Nicklas
See Also:
Shareable
Last modified
$Date: 2009-01-08 11:01:27 +0100 (Thu, 08 Jan 2009) $

Constructor Summary
ShareableUtil()
           
 
Method Summary
static void copyPermissions(DbControl dc, Shareable from, Shareable to)
          Copy permissions from one item to another.
static void setItemKey(DbControl dc, ShareableData shareableData, ItemKey itemKey)
          Set the item key of a ShareableData object.
static void setItemKey(ShareableData shareableData, ItemKey itemKey)
          Deprecated. Use setItemKey(DbControl, ShareableData, ItemKey) instead
static void setProjectKey(ShareableData shareableData, ProjectKey projectKey)
          Set the project key of a ShareableData object.
static int shareRecursively(DbControl dc, Directory directory)
          Share all files and sub-directories in the given directory with the same permissions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShareableUtil

public ShareableUtil()
Method Detail

setItemKey

public static void setItemKey(ShareableData shareableData,
                              ItemKey itemKey)
Deprecated. Use setItemKey(DbControl, ShareableData, ItemKey) instead

Set the item key of a ShareableData object.

Parameters:
shareableData - The data object to set the item key on. Null is not allowed.
itemKey - Item key to be set.

setProjectKey

public static void setProjectKey(ShareableData shareableData,
                                 ProjectKey projectKey)
Set the project key of a ShareableData object.

Parameters:
shareableData - The data object to set project key to. Null is not allowed.
projectKey - Project key to be set.

setItemKey

public static void setItemKey(DbControl dc,
                              ShareableData shareableData,
                              ItemKey itemKey)
Set the item key of a ShareableData object. If the logged in user doesn't have Permission.SHARE_TO_EVERYONE permission then new item key must, if it includes sharing to the everyone group, have exactly the same permissions as there is in the existing item key.

Parameters:
dc - A DbControl
shareableData - The item to share
itemKey - The new item key
Throws:
PermissionDeniedException - If the logged in user doesn't have permission and the new item key contains a permission that is different from the existing permission
Since:
2.6

shareRecursively

public static int shareRecursively(DbControl dc,
                                   Directory directory)
Share all files and sub-directories in the given directory with the same permissions. This method will of course only change the permissions on items that the current user has Permission.SET_PERMISSION on.

Parameters:
dc - A DbControl for database access
directory - The directory
Returns:
The number of files and directories processed
Since:
2.8

copyPermissions

public static void copyPermissions(DbControl dc,
                                   Shareable from,
                                   Shareable to)
Copy permissions from one item to another. If the 'from' item is shared to the 'EVERYONE' group, but the logged in user lacks the Permission.SHARE_TO_EVERYONE permission, the share to everyone is removed. If the 'to' item is a new item, a project is active and the 'from' item isn't already shared to the project, the 'to' item will be shared to the project.

Parameters:
from - The item to copy permissions from
to - The item to copy permissions to
Since:
2.8

2.10.1: 2009-03-24