|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.BasicItem<D> net.sf.basedb.core.Key<ProjectKeyData> net.sf.basedb.core.ProjectKey
public class ProjectKey
This class is used to get information about which projects
a Shareable
item has been shared to.
A project key is immutable and the project/permission combinations cannot be changed once the key has been created. This allows the core to resuse project keys for all items with the same combination of project/permission values without fear that someone else may change the permissions.
Project keys can be used with Shareable
items
to share them with projects. If the logged in user has
set an active project (see SessionControl.setActiveProject(Project)
)
new items will automatically be shared to that project.
To create a new project key use the ProjectPermissions
object and pass
the information to the getNewOrExisting(DbControl, ProjectPermissions)
method.
Another option is to use the MultiPermissions
object which allows
you to modifiy the sharing information of a whole bunch of shareable items
in one go. The MultiPermissions
class takes care of all
the cumbersome work of creating new keys and assigning those to the items
for you.
Shareable
,
SessionControl.setActiveProject(Project)
Field Summary | |
---|---|
static Item |
TYPE
The type of item represented by this class. |
Constructor Summary | |
---|---|
ProjectKey(ProjectKeyData projectKeyData)
|
Method Summary | |
---|---|
static void |
deleteUnusedKeys()
Deprecated. Use deleteUnusedProjectKeys() instead which returns the number of
deleted keys |
static int |
deleteUnusedProjectKeys()
Delete all keys that are currently not used by any item. |
static ProjectKey |
getById(DbControl dc,
int id)
Get a ProjectKey item when you know the ID. |
static ProjectKey |
getNewOrExisting(DbControl dc,
ProjectPermissions projectPermissions)
Create a new or load an existing ProjectKey when you
have a combination of project/permission values. |
(package private) static int |
getNewOrExistingId(org.hibernate.Session session,
Map<ProjectData,Integer> projectPermissions)
Find the ID of an existing key with exactly the same project/permission combination. |
Set<Permission> |
getPermissions(Project project)
Get the permissions for a project. |
(package private) PluginPermission |
getPluginPermissions()
|
Set<Integer> |
getProjectIds(Permission permission)
Get the ID:s of all projects that are shared with this project key having the specified permission. |
Item |
getType()
Get the type of item represented by the object. |
Set<ItemProxy> |
getUsingItems()
Get all: Shareable items shared to this key
|
(package private) void |
initPermissions(int granted,
int denied)
WRITE permission is always denied. |
boolean |
isUsed()
Checks if: A Shareable item is using this key. |
Methods inherited from class net.sf.basedb.core.BasicItem |
---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Item TYPE
Item.PROJECTKEY
,
getType()
Constructor Detail |
---|
ProjectKey(ProjectKeyData projectKeyData)
Method Detail |
---|
public static ProjectKey getNewOrExisting(DbControl dc, ProjectPermissions projectPermissions) throws BaseException
ProjectKey
when you
have a combination of project/permission values. If the database
contains a project key with the same combination that project key is
loaded and returned, otherwise a new project key is created.
If no existing key is found, the new key will immediately be saved
and committed to the database using another transaction. This ensures
that no two keys contains identical permissions.
dc
- The DbControl
which will be used for
permission checking and database accessprojectPermissions
- A ProjectPermissions
object
holding the permissions
ProjectKey
item
BaseException
- If there is an errorpublic static ProjectKey getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
ProjectKey
item when you know the ID.
dc
- The DbControl
which will be used for
permission checking and database access.id
- The ID of the item to load
ProjectKey
item
ItemNotFoundException
- If an item with the specified
ID is not found
PermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the item
BaseException
- If there is another errorpublic static void deleteUnusedKeys() throws BaseException
deleteUnusedProjectKeys()
instead which returns the number of
deleted keys
BaseException
public static int deleteUnusedProjectKeys() throws BaseException
BaseException
- If there is some kind of error.public Item getType()
Identifiable
Item
enumeration.
public boolean isUsed() throws BaseException
Shareable
item is using this key.
isUsed
in class BasicItem<ProjectKeyData>
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems()
Shareable
items shared to this key
getUsingItems
in class BasicItem<ProjectKeyData>
BasicItem.addUsingItems(Set, Item, org.hibernate.Query)
void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem<ProjectKeyData>
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass
BaseException
- If the permissions couldn't be initialisedPluginPermission getPluginPermissions()
getPluginPermissions
in class BasicItem<ProjectKeyData>
public Set<Permission> getPermissions(Project project) throws InvalidDataException
project
- The Project
for which we want to get the permission
Set
containing the granted permissions, or an
empty set if no permissions have been granted
InvalidDataException
- If the project is nullPermission
public Set<Integer> getProjectIds(Permission permission)
permission
- The permission the projects must have
static int getNewOrExistingId(org.hibernate.Session session, Map<ProjectData,Integer> projectPermissions) throws BaseException
projectPermissions
- A Map
holding the project/permission combinations
BaseException
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |