Package net.sf.basedb.core
Class ShareableUtil
- java.lang.Object
-
- net.sf.basedb.core.ShareableUtil
-
-
Constructor Summary
Constructors Constructor Description ShareableUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
copyPermissions(DbControl dc, Shareable from, Shareable to)
Copy permissions from one item to another.static ItemKey
merge(DbControl dc, ItemKey... keys)
Merge one or more item keys into a new item key that combines all the permissions.static ProjectKey
merge(DbControl dc, ProjectKey... keys)
Merge one or more project keys into a new project key that combines all the permissions.static void
setItemKey(DbControl dc, ShareableData shareableData, ItemKey itemKey)
Set the item key of aShareableData
object.static void
setProjectKey(ShareableData shareableData, ProjectKey projectKey)
Set the project key of aShareableData
object.static int
shareRecursively(DbControl dc, Directory directory)
Share all files and sub-directories in the given directory with the same permissions.
-
-
-
Method Detail
-
setProjectKey
public static void setProjectKey(ShareableData shareableData, ProjectKey projectKey)
Set the project key of aShareableData
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 aShareableData
object. If the logged in user doesn't havePermission.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 DbControlshareableData
- The item to shareitemKey
- 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 hasPermission.SET_PERMISSION
on.- Parameters:
dc
- A DbControl for database accessdirectory
- 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 thePermission.SHARE_TO_EVERYONE
permission, the share to everyone is removed. If the 'to' item is a new item and a project is active the new item is also shared with the settings from the project.- Parameters:
from
- The item to copy permissions fromto
- The item to copy permissions to- Since:
- 2.8
-
merge
public static ItemKey merge(DbControl dc, ItemKey... keys)
Merge one or more item keys into a new item key that combines all the permissions.- Parameters:
keys
- An array with the item keys (null elements are ignored)- Returns:
- A new or existing item key
- Since:
- 2.16
-
merge
public static ProjectKey merge(DbControl dc, ProjectKey... keys)
Merge one or more project keys into a new project key that combines all the permissions.- Parameters:
keys
- An array with the project keys (null elements are ignored)- Returns:
- A new or existing project key
- Since:
- 2.16
-
-