2.17.2: 2011-06-17

net.sf.basedb.core
Class UserClientSetting

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.Setting<UserClientSettingData>
          extended by net.sf.basedb.core.UserClientSetting
All Implemented Interfaces:
AccessControlled, Identifiable

public class UserClientSetting
extends Setting<UserClientSettingData>

This class is used to represent a setting valid for a specific user using a specific client application.

Version:
2.0
Author:
Nicklas

Field Summary
private static QueryRuntimeFilter CLIENT_RUNTIME_FILTER
          This filter will only return items if the logged in user has generic read permission to clients.
static Item TYPE
          The type of item represented by this class.
private static QueryRuntimeFilter USER_RUNTIME_FILTER
          This filter will only return items if the logged in user has generic read permission to users.
private static QueryRuntimeFilter USERCLIENT_RUNTIME_FILTER
          This filter will only return items if the logged in user has generic read permission to users and clients.
 
Fields inherited from class net.sf.basedb.core.Setting
MAX_NAME_LENGTH, MAX_VALUE_LENGTH
 
Constructor Summary
UserClientSetting(UserClientSettingData data)
           
 
Method Summary
static UserClientSetting getById(DbControl dc, int id)
          Get a UserClientSetting item when you know the ID.
 Client getClient()
          Get the client application this setting is valid for.
static UserClientSetting getNew(DbControl dc, User user, Client client, String name, String value)
          Create a new UserClientSetting item.
static ItemQuery<UserClientSetting> getQuery(User user, Client client)
          Get a query configured to retrieve client specific settings for a user.
 Item getType()
          Get the type of item represented by the object.
 User 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 setClient(Client client)
          Set the client application this setting is valid for.
(package private)  void setUser(User user)
          Set the user this setting is valid for.
 
Methods inherited from class net.sf.basedb.core.Setting
getName, getValue, setName, setValue
 
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, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.USERCLIENTSETTING, getType()

CLIENT_RUNTIME_FILTER

private static final QueryRuntimeFilter CLIENT_RUNTIME_FILTER
This filter will only return items if the logged in user has generic read permission to clients.


USER_RUNTIME_FILTER

private static final QueryRuntimeFilter USER_RUNTIME_FILTER
This filter will only return items if the logged in user has generic read permission to users.


USERCLIENT_RUNTIME_FILTER

private static final QueryRuntimeFilter USERCLIENT_RUNTIME_FILTER
This filter will only return items if the logged in user has generic read permission to users and clients.

Constructor Detail

UserClientSetting

UserClientSetting(UserClientSettingData data)
Method Detail

getNew

public static UserClientSetting getNew(DbControl dc,
                                       User user,
                                       Client client,
                                       String name,
                                       String value)
                                throws BaseException
Create a new UserClientSetting item.

Parameters:
dc - The DbControl which will be used for permission checking and database access
user - The User which this should be a setting for
client - The Client which this should be a setting for
name - The name of the setting
value - The value of the setting
Returns:
The new UserClientSetting item
Throws:
BaseException - If there is an error

getById

public static UserClientSetting getById(DbControl dc,
                                        int id)
                                 throws ItemNotFoundException,
                                        PermissionDeniedException,
                                        BaseException
Get a UserClientSetting item when you know the ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The ID of the item to load
Returns:
The UserClientSetting item
Throws:
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 error

getQuery

public static ItemQuery<UserClientSetting> getQuery(User user,
                                                    Client client)
Get a query configured to retrieve client specific 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 all users in which case all settings will be returned
client - The client to retreive settings for, null is allowed if the logged in user has generic READ permission for all clients in which case all settings will be returned
Returns:
An ItemQuery object

getType

public 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 the Item enumeration.

Returns:
A value indicating the type of item

initPermissions

void initPermissions(int granted,
                     int denied)
               throws BaseException
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 class Setting<UserClientSettingData>
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

getUser

public User getUser()
             throws PermissionDeniedException,
                    BaseException
Get the user this setting is valid for.

Returns:
The User item
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission
BaseException - If there is another error

setUser

void setUser(User user)
       throws PermissionDeniedException,
              InvalidDataException
Set the user this setting is valid for. Can only be set on a new item.

Throws:
InvalidDataException - If the user is null
PermissionDeniedException

getClient

public Client getClient()
                 throws PermissionDeniedException,
                        BaseException
Get the client application this setting is valid for.

Returns:
The Client item
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission
BaseException - If there is another error

setClient

void setClient(Client client)
         throws PermissionDeniedException,
                InvalidDataException
Set the client application this setting is valid for. Can only be set on a new item.

Throws:
InvalidDataException - If the client is null
PermissionDeniedException

2.17.2: 2011-06-17