Package net.sf.basedb.core
Class UserDefaultSetting
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.Setting
net.sf.basedb.core.UserDefaultSetting
- All Implemented Interfaces:
AccessControlled
,Identifiable
This class is used to represent a setting valid for a specific user
using any client application.
- Version:
- 2.0
- Author:
- Nicklas
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final QueryRuntimeFilter
This filter will only return items if the logged in user has generic read permission to users.static final Item
The type of item represented by this class.Fields inherited from class net.sf.basedb.core.Setting
MAX_NAME_LENGTH, MAX_VALUE_LENGTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic UserDefaultSetting
Get aUserDefaultSetting
item when you know the ID.(package private) UserDefaultSettingData
getData()
Get theBasicData
object that holds all data for this item.static UserDefaultSetting
Create a newUserDefaultSetting
item.static ItemQuery<UserDefaultSetting>
Get a query configured to retrieve default settings for a user.getType()
Get the type of item represented by the object.getUser()
Get the user this setting is valid for.(package private) void
initPermissions
(int granted, int denied) READ permission is granted if the logged in user is the owner of this setting.(package private) void
Set the user this setting is valid for.Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
-
Field Details
-
TYPE
The type of item represented by this class.- See Also:
-
RUNTIME_FILTER
This filter will only return items if the logged in user has generic read permission to users.
-
-
Constructor Details
-
UserDefaultSetting
UserDefaultSetting(UserDefaultSettingData data)
-
-
Method Details
-
getNew
public static UserDefaultSetting getNew(DbControl dc, User user, String name, String value) throws BaseException Create a newUserDefaultSetting
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessuser
- TheUser
which this should be a default setting forname
- The name of the settingvalue
- The value of the setting- Returns:
- The new
UserDefaultSetting
item - Throws:
BaseException
- If there is an error- See Also:
-
getById
public static UserDefaultSetting getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aUserDefaultSetting
item when you know the ID.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.id
- The ID of the item to load- Returns:
- The
UserDefaultSetting
item - Throws:
ItemNotFoundException
- If an item with the specified ID is not foundPermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission to the itemBaseException
- If there is another error
-
getQuery
Get a query configured to retrieve default settings for a user.- Parameters:
user
- The user to retreive settings for, null is allowed if the logged in user has generic READ permission for users in which case all settings will be returned- Returns:
- An
ItemQuery
object - See Also:
-
getData
UserDefaultSettingData getData()Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item. -
getType
Description copied from interface:Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in theItem
enumeration.- Returns:
- A value indicating the type of item
-
initPermissions
READ permission is granted if the logged in user is the owner of this setting. WRITE, CREATE and DELETE permissions are granted if the logged in user is the owner and not is a multiuser account. WRITE, DELETE and CREATE permissions are granted if the logged in user have generic WRITE permission for users.- Overrides:
initPermissions
in classSetting
- Parameters:
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass- Throws:
BaseException
- If the permissions couldn't be initialised
-
getUser
Get the user this setting is valid for.- Returns:
- The
User
item - Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permissionBaseException
- If there is another error
-
setUser
Set the user this setting is valid for. Can only be set on a new item.- Throws:
InvalidDataException
- If the user is nullPermissionDeniedException
-