public class SessionControl
extends java.lang.Object
DbControl
objects which are needed to access the
database.Application.newSessionControl(String, String, String)
,
Application.getSessionControl(String, String)
Modifier and Type | Class and Description |
---|---|
private static class |
SessionControl.LoginInfo
Internal class to hold information about the logged in user.
|
private static class |
SessionControl.SettingInfo
Internal class to hold information about a setting
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.Boolean> |
allowedClients |
private java.util.Map<java.lang.String,SessionControl.SettingInfo> |
clientDefaultSettings
Stores name and value from
ClientDefaultSettingData . |
private int |
clientId
The id of the
ClientData . 0 = no client |
private boolean |
closed
If the session control has been closed it can no longer be used.
|
private java.util.Map<ContextKey,ItemContext> |
currentContexts
Map for storing current contexts.
|
private java.util.Map<DbControl,java.lang.String> |
dbControlCache
Holds all created
DbControl object, so we can close
them if the user logs out. |
private java.lang.String |
externalClientId
The external id of the
ClientData . null = no client |
private java.lang.String |
id
The id of the object.
|
private int |
jobId |
private long |
lastAccess
The time of the last access to this object.
|
private static org.slf4j.Logger |
log
Log core events.
|
private SessionControl.LoginInfo |
loginInfo
Login information for the logged in user.
|
private int |
pluginId |
private java.lang.String |
remoteId
The remote IP.
|
Constructor and Description |
---|
SessionControl(java.lang.String id,
SessionControl parent,
PluginDefinition plugin,
Job job)
Create a new session control object using another one as the template.
|
SessionControl(java.lang.String id,
java.lang.String externalClientId,
boolean failIfNoClient,
java.lang.String remoteId)
Creates a new
SessionControl object. |
Modifier and Type | Method and Description |
---|---|
protected void |
cleanUp() |
protected void |
clearDbControlCache() |
void |
close()
Close this session control so it can't be used again.
|
private SessionControl.LoginInfo |
createLoginInfo(Session session,
UserData userData,
java.lang.String comment,
boolean impersonated,
AuthenticationMethod authenticationMethod)
Create a LoginInfo object and load all information that it needs.
|
void |
deleteContext(int contextId)
Delete a context.
|
int |
deleteCurrentContexts(Item itemType,
boolean inMemory,
boolean inDatabase)
Delete all default contexts for the logged in user.
|
protected void |
finalize()
Clean up if a bad client application forgets to logout.
|
int |
getActiveProjectId()
Get the id of the active project, or 0 if no project is active.
|
java.util.Set<Permission> |
getActiveProjectPermissions()
Get the permissions that the logged in user has in the currently active project.
|
java.util.Set<java.lang.Integer> |
getActiveRoles()
Get the id of all active roles where the logged in user is a member.
|
java.util.List<ItemContext> |
getAllCurrentContexts(boolean inMemory,
boolean inDatabase)
Get a list with the current default contexts.
|
(package private) int |
getAllPermissions(Item itemType,
UserData owner,
ItemKeyData itemKey,
ProjectKeyData projectKey)
Get the combined permissions for an item of the specified type, owned by the specified
user and shared with the specified item and project keys.
|
(package private) int |
getAllPermissions(SharedData sharedData)
|
java.util.Set<java.lang.Integer> |
getAllRoles()
Get the id of all roles where the logged in user is a member.
|
AuthenticationMethod |
getAuthenticationMethod()
Get the method that was used to authenticate the currently
logged in user.
|
java.lang.String |
getClientDefaultSetting(java.lang.String name)
Get the value of the
ClientDefaultSetting with the
specified name. |
int |
getClientId()
Get the id of the
Client application in use. |
private ClientData |
getClientWithExternalId(java.lang.String externalId) |
ItemContext |
getContext(int contextId)
Load a context without making it the current context.
|
Enumeration<java.lang.Integer,java.lang.String> |
getContextNames(Item item)
Same as:
getContextNames(item, "") |
Enumeration<java.lang.Integer,java.lang.String> |
getContextNames(Item item,
java.lang.String subContext)
Get a list with the names of all named contexts for a given item and
subcontext.
|
ItemContext |
getCurrentContext(Item item)
Same as:
getCurrentContext(item, "", null) . |
ItemContext |
getCurrentContext(Item item,
ItemContext defaultContext)
Same as:
getCurrentContext(item, "", defaultContext) . |
ItemContext |
getCurrentContext(Item item,
java.lang.String subContext)
Same as:
getCurrentContext(item, subContext, null) . |
ItemContext |
getCurrentContext(Item item,
java.lang.String subContext,
ItemContext defaultContext)
Get the current context.
|
int |
getCurrentSessionId()
Get the id of the current user session, or 0 if no user is logged in.
|
java.lang.String |
getExternalClientId()
Get the external id of the
Client application in use. |
java.util.Set<java.lang.Integer> |
getFriends()
Get the id of all friends to logged in user.
|
java.util.Set<java.lang.Integer> |
getGroups()
Get the id of all groups where the logged in user is a member, directly or indirectly.
|
java.lang.String |
getId()
Get the id of this
SessionControl . |
java.util.Set<java.lang.Integer> |
getInactiveRoles()
Get the id of all inactive roles where the logged in user is a member.
|
int |
getItemKeyId()
Get the id of the
ItemKey that new items should be shared to
according to the settings in the currently active project. |
java.util.Set<java.lang.Integer> |
getItemKeys()
Get the id of all item keys where the logged in user has read permission.
|
java.util.Set<java.lang.Integer> |
getItemKeys(Permission permission)
Get the id of all item keys where the logged in user has the
requested permission.
|
int |
getJobId()
Get the id of the job that is currently running with this
session control.
|
PluginSessionControl |
getJobSessionControl(Job job)
Create a new session control for executing a job.
|
long |
getLastAccess()
Get the time this object last was accessed.
|
java.util.Locale |
getLocale()
Get the locale that is curently assigned to this session control.
|
int |
getLoggedInUserId()
Get the id of the logged in user, or 0 if no user is logged in.
|
int |
getPluginId()
Get the id of the plug-in that is currently running with this
session control.
|
(package private) PluginPermission |
getPluginPermissions(Item itemType)
Get all plugin-specific permissions for the specified item type.
|
PluginSessionControl |
getPluginSessionControl(PluginDefinition plugin,
Job job)
Create a new session control for executing a plugin.
|
int |
getProjectKeyId()
Get the id of the
ProjectKey that can be used to share an item to
the active project with full permission, or 0 if no project is active or
the logged in user only has read permission to the active project. |
java.util.Set<java.lang.Integer> |
getProjectKeys()
Get the id of all project keys where the logged in user has read permission.
|
java.util.Set<java.lang.Integer> |
getProjectKeys(Permission permission)
Get the id of all project keys where the logged in user has the
requested permission.
|
(package private) int |
getProjectPermission(Project project) |
java.util.Set<java.lang.Integer> |
getProjects()
Get the id of all projects where the logged in user is a member, directly or indirectly.
|
(package private) java.lang.String |
getRemoteId()
Get the remote id that was passed to the
Application.newSessionControl(String,String,String) method when creating this
object. |
(package private) int |
getRolePermissions(Item itemType)
Get all role-based permissions for the specified type of items.
|
java.util.Set<java.lang.Integer> |
getRoles()
Deprecated.
In 3.11, use
getAllRoles() or getActiveRoles() instead |
java.lang.Object |
getSessionSetting(java.lang.String name)
Get the value of a session setting with the specified name.
|
(package private) int |
getSharedPermissions(ShareableData shareableData)
Get the shared permissions for a
ShareableData object. |
java.lang.String |
getUserClientSetting(java.lang.String name)
Get the value of the
UserClientSetting with the
specified name. |
java.lang.String |
getUserDefaultSetting(java.lang.String name)
Get the value of the
UserDefaultSetting with the
specified name. |
boolean |
hasPermission(Permission permission,
Item itemType)
Check if the logged in user has the specfied permission for
all item of the specified type.
|
boolean |
hasSystemPermission(Permission permission)
Check if the logged in user has the specified system permission.
|
SessionControl |
impersonateLogin(int userId,
java.lang.String comment)
Log in as another user or create a clone of the currently logged in user's session.
|
SessionControl |
impersonateLogin(Ownable item,
java.lang.String comment)
Log in as the owner of the specified item.
|
boolean |
isAllowedToUseClient(java.lang.String externalClientId)
Checks if this session control can be used by the given client application.
|
boolean |
isClosed()
If this session control has been closed or not.
|
boolean |
isDenied(Permission permission,
Item itemType)
Check if the logged in user has been denied the specified permission
for items of the specified type.
|
boolean |
isFriendOf(User user)
Check if the logged in user is a friend of of the specified user.
|
boolean |
isImpersonated()
Check if the logged in user was impersonated by another user.
|
boolean |
isLoggedIn()
Checks if a user is logged in or not.
|
boolean |
isMemberOf(Group group)
Check if the logged in user is a member, directly or indirectly, of the specified group.
|
boolean |
isMemberOf(Project project)
Check if the logged in user is a member, directly or indirectly, of the specified project.
|
boolean |
isMemberOf(Role role)
Check if the logged in user is a member of the specified role.
|
boolean |
isRoleInactive(int roleId)
Is the given role inactive or not?
|
private java.util.Map<java.lang.String,SessionControl.SettingInfo> |
listToMap(java.util.List<? extends SettingData> settings)
Copy settings from a List to a Map.
|
private java.util.Map<java.lang.String,SessionControl.SettingInfo> |
loadClientDefaultSettings(Session session,
int clientId)
Load client applications default settings.
|
ItemContext |
loadContext(int contextId)
Load a context and make it the current context.
|
ItemContext |
loadContext(int contextId,
boolean copyTemporaryObjects)
Load a context and make it the current context, optionally copying
temporary filters and objects from the current context to the loaded context.
|
private ItemContext |
loadContextInternal(int contextId)
Load a context with the specified ID.
|
private ItemContext |
loadContextInternal(Item item,
java.lang.String subContext,
java.lang.String name)
Load a named context.
|
private java.util.Map<java.lang.String,SessionControl.SettingInfo> |
loadUserClientSettings(Session session,
int userId,
int clientId)
Load users client-specific settings.
|
private java.util.Map<java.lang.String,SessionControl.SettingInfo> |
loadUserDefaultSettings(Session session,
int userId)
Load users default settings.
|
(package private) void |
login(Keyring keyring) |
void |
login(LoginRequest loginRequest)
Log in to BASE.
|
void |
login(java.lang.String login,
java.lang.String password,
java.lang.String comment)
Deprecated.
In 3.3, use
login(LoginRequest) instead |
void |
logout()
Log out of BASE.
|
DbControl |
newDbControl()
Create a new
DbControl object for this session. |
void |
reloadPermissions()
Tell the core to reload the logged in users permission the next time
the client application needs to check the permissions.
|
void |
reloadSettings(boolean onlyClientDefaultSettings,
boolean saveCurrentUserSettings)
Reloads user- and client-specific settings.
|
private void |
saveAllCurrentContexts(Session session,
UserData userData,
ClientData clientData) |
private void |
saveAllUserSettings(Session session)
Saves all user settings.
|
int |
saveCurrentContextAs(Item item,
java.lang.String name,
boolean overwrite,
boolean isPublic)
Same as:
saveCurrentContextAs(item, "", name, overwrite, isPublic) . |
int |
saveCurrentContextAs(Item item,
java.lang.String subContext,
java.lang.String name,
boolean overwrite,
boolean isPublic)
Save the current context as a named context.
|
private <I extends SettingData> |
saveSettings(Session session,
Query query,
java.util.Map<java.lang.String,SessionControl.SettingInfo> settings,
java.lang.Class<I> dataClass,
UserData userData,
ClientData clientData)
Save settings when a user logs out.
|
void |
setActiveProject(Project project)
Set the active project.
|
boolean |
setRoleInactive(int roleId,
boolean inactive)
Set a role as active or inactive.
|
java.lang.Object |
setSessionSetting(java.lang.String name,
java.lang.Object value)
Set the value of a session setting.
|
java.lang.String |
setUserClientSetting(java.lang.String name,
java.lang.String value)
Set the value of a
UserClientSetting . |
java.lang.String |
setUserDefaultSetting(java.lang.String name,
java.lang.String value)
Set the value of a
UserDefaultSetting . |
void |
updateLastAccess()
Update the time this object last was accessed.
|
private AuthenticatedUser |
verifyUserExternal(Session session,
LoginRequest loginRequest)
Verify the user with external authentication.
|
(package private) AuthenticatedUser |
verifyUserInternal(Session session,
LoginRequest loginRequest)
Verify the user with internal authentication.
|
private static final org.slf4j.Logger log
private final java.lang.String id
Application.getSessionControl(String,String)
private final int clientId
ClientData
. 0 = no clientprivate final java.lang.String externalClientId
ClientData
. null = no clientprivate final java.lang.String remoteId
private final java.util.Map<DbControl,java.lang.String> dbControlCache
DbControl
object, so we can close
them if the user logs out. We use only the keys of the map since there
is no WeakHashSet
class.private long lastAccess
private boolean closed
private java.util.Map<java.lang.String,SessionControl.SettingInfo> clientDefaultSettings
ClientDefaultSettingData
.private SessionControl.LoginInfo loginInfo
private final java.util.Map<ContextKey,ItemContext> currentContexts
private final java.util.Map<java.lang.String,java.lang.Boolean> allowedClients
private int pluginId
private int jobId
SessionControl(java.lang.String id, SessionControl parent, PluginDefinition plugin, Job job)
id
- The ID if the new session controlparent
- The parent session controlplugin
- The plugin that is executingSessionControl(java.lang.String id, java.lang.String externalClientId, boolean failIfNoClient, java.lang.String remoteId) throws BaseException
SessionControl
object.id
- The id used in Application.newSessionControl(String,String,String)
externalClientId
- Optional external ID of the client application in usefailIfNoClient
- If TRUE, an exception is thrown if an external client id
has been specified, but not foundremoteId
- For example, the IP-addressBaseException
public long getLastAccess()
Application.cleanSessionControlCache(boolean)
public void updateLastAccess()
Application.cleanSessionControlCache(boolean)
public boolean isClosed()
public void close()
public java.lang.String getId()
SessionControl
. Use this value for
retrieving the object from the Application
cache.Application.getSessionControl(String,String)
public int getClientId()
Client
application in use. Use
Client.getById(DbControl, int)
to get the Client
object.public java.lang.String getExternalClientId()
Client
application in use.getClientId()
java.lang.String getRemoteId()
Application.newSessionControl(String,String,String)
method when creating this
object. This value is checked against the value passed to the Application.getSessionControl(String,String)
method.public DbControl newDbControl() throws BaseException
DbControl
object for this session.DbControl
objectBaseException
- If there is an errorvoid login(Keyring keyring)
@Deprecated public void login(java.lang.String login, java.lang.String password, java.lang.String comment)
login(LoginRequest)
insteadpublic void login(LoginRequest loginRequest)
loginRequest
- Request containing login/password and other informationItemNotFoundException
- If a user with the specified username is not foundInvalidPasswordException
- If the specified password is incorrectPermissionDeniedException
- If the user doesn't have
Permission.USE
permission for the current client
application or if a user is already logged inBaseException
- If there is any other errorlogout()
,
isLoggedIn()
,
getLoggedInUserId()
AuthenticatedUser verifyUserInternal(Session session, LoginRequest loginRequest)
private AuthenticatedUser verifyUserExternal(Session session, LoginRequest loginRequest)
public SessionControl impersonateLogin(int userId, java.lang.String comment) throws ItemNotFoundException, PermissionDeniedException, BaseException
SessionControl
object which
is equivalent to a SessionControl
where that user logged in by normal means.
This method requires that the logged in user has Permission.ACT_AS_ANOTHER_USER
permission or that the userId is the same as the currently logged in user.userId
- The id of the user to login ascomment
- A comment that will be placed in the Session
informationSessionControl
objectItemNotFoundException
- If no user with the specified id existsPermissionDeniedException
- If the logged in user doesn't
have Permission.ACT_AS_ANOTHER_USER
permission and the userId
is a different user from the currently logged in userBaseException
- If there is another errorpublic SessionControl impersonateLogin(Ownable item, java.lang.String comment)
item
- Login as the owner of this Item. Null is not allowedcomment
- A comment that will be placed in the Session
informationSessionControl
for the created session.impersonateLogin(int, String)
public boolean isAllowedToUseClient(java.lang.String externalClientId)
externalClientId
- The external id of the client to checkprivate ClientData getClientWithExternalId(java.lang.String externalId)
private SessionControl.LoginInfo createLoginInfo(Session session, UserData userData, java.lang.String comment, boolean impersonated, AuthenticationMethod authenticationMethod) throws BaseException
BaseException
public void logout() throws BaseException
DbControl
objects still open, they
will be closed. Changes made to items managed by those DbControl
objects will be lost unless the items are connected to a new DbControl
object.BaseException
- If there is an errorlogin(String, String, String)
,
isLoggedIn()
,
impersonateLogin(int, String)
,
isImpersonated()
public boolean isLoggedIn()
login(String, String, String)
,
logout()
,
getLoggedInUserId()
public int getLoggedInUserId()
User.getById(DbControl, int)
to get the User
object.login(String, String, String)
,
logout()
,
isLoggedIn()
public AuthenticationMethod getAuthenticationMethod()
AuthenticationMethod.INTERNAL
.public int getCurrentSessionId()
Session.getById(DbControl, int)
to the Session
object.public int getPluginId()
public int getJobId()
public boolean isImpersonated()
impersonateLogin(int, String)
public void reloadPermissions()
public void reloadSettings(boolean onlyClientDefaultSettings, boolean saveCurrentUserSettings) throws BaseException
onlyClientDefaultSettings
- Setting this to TRUE will only reload
ClientDefaultSetting
:ssaveCurrentUserSettings
- Setting this to TRUE will save the current user-specific
settings before reloading them. This parameter is ignored if onlyClientDefaultSettings
is true. The settings are never changed if the logged in user is a multi-user account.BaseException
- If the settings cannot be reloadedpublic int getActiveProjectId()
Project.getById(DbControl, int)
to get the Project
object.setActiveProject(Project)
public void setActiveProject(Project project) throws PermissionDeniedException, BaseException
Shareable
items will automatically be shared to the active project with delete permission.
The active project doesn't affect already existing items.project
- The project to make activePermissionDeniedException
- If the logged in user doesn't have
Permission.USE
permission for the projectBaseException
- If there is another errorgetActiveProjectId()
public java.util.Set<Permission> getActiveProjectPermissions()
public PluginSessionControl getPluginSessionControl(PluginDefinition plugin, Job job)
plugin
- The plugin to executejob
- The job that executes the plug-in, or nullpublic PluginSessionControl getJobSessionControl(Job job)
public int getProjectKeyId()
ProjectKey
that can be used to share an item to
the active project with full permission, or 0 if no project is active or
the logged in user only has read permission to the active project.
Use ProjectKey.getById(DbControl, int)
to get the ProjectKey
object.getActiveProjectId()
,
setActiveProject(Project)
public int getItemKeyId()
ItemKey
that new items should be shared to
according to the settings in the currently active project. If no
project is active or if the projects doesn't share to any item
key, 0 is returned.
Use ItemKey.getById(DbControl, int)
to get the ItemKey
object.getActiveProjectId()
,
setActiveProject(Project)
,
getProjectKeyId()
public boolean hasSystemPermission(Permission permission)
permission
- One of the system permission constants defined
by the Permission
enumerationpublic boolean hasPermission(Permission permission, Item itemType)
permission
- One of the permissions constants defined
by the Permission
enumerationitemType
- One of the item constants defined by the
Item
enumerationpublic boolean isDenied(Permission permission, Item itemType)
hasPermission(Permission, Item)
method. Both
methods may return false in which case the system also checks ownership
and sharing information to determine if access is granted. If this method
return TRUE the hasPermission
method always return false.permission
- One of the permissions constants defined
by the Permission
enumerationitemType
- One of the item constants defined by the
Item
enumerationint getRolePermissions(Item itemType)
PluginPermission getPluginPermissions(Item itemType)
int getSharedPermissions(ShareableData shareableData)
ShareableData
object.int getAllPermissions(Item itemType, UserData owner, ItemKeyData itemKey, ProjectKeyData projectKey)
int getAllPermissions(SharedData sharedData)
public boolean isMemberOf(Group group)
group
- The group to checkpublic boolean isMemberOf(Role role)
role
- The role to checkpublic boolean isMemberOf(Project project)
project
- The project to checkint getProjectPermission(Project project)
public boolean isFriendOf(User user)
user
- The user to check@Deprecated public java.util.Set<java.lang.Integer> getRoles()
getAllRoles()
or getActiveRoles()
insteadgetAllRoles()
.Set
containing role id:spublic java.util.Set<java.lang.Integer> getAllRoles()
Set
containing role id:s, or nullpublic java.util.Set<java.lang.Integer> getActiveRoles()
Set
containing role id:s or nullpublic java.util.Set<java.lang.Integer> getInactiveRoles()
Set
containing role id:s or nullpublic boolean isRoleInactive(int roleId)
roleId
- The id of the role to checkpublic boolean setRoleInactive(int roleId, boolean inactive)
roleId
- The id of the role to setinactive
- TRUE to set the role to inactive, FALSE to set
it to activepublic java.util.Set<java.lang.Integer> getGroups()
Set
containing group id:spublic java.util.Set<java.lang.Integer> getFriends()
Set
containing user id:spublic java.util.Set<java.lang.Integer> getProjects()
Set
containing project id:spublic java.util.Set<java.lang.Integer> getItemKeys()
Set
containing item key id:spublic java.util.Set<java.lang.Integer> getItemKeys(Permission permission)
permission
- Requested permissions.Set
containing item key id:spublic java.util.Set<java.lang.Integer> getProjectKeys()
Set
containing project key id:spublic java.util.Set<java.lang.Integer> getProjectKeys(Permission permission)
permission
- The requested permissionsSet
containing project key id:spublic ItemContext getCurrentContext(Item item)
getCurrentContext(item, "", null)
.public ItemContext getCurrentContext(Item item, java.lang.String subContext)
getCurrentContext(item, subContext, null)
.public ItemContext getCurrentContext(Item item, ItemContext defaultContext)
getCurrentContext(item, "", defaultContext)
.item
- Type of item for which current context should be returned.defaultContext
- A default context to copy values from if a new context
must be createdItemContext
object.getCurrentContext(Item, String, ItemContext)
public ItemContext getCurrentContext(Item item, java.lang.String subContext, ItemContext defaultContext)
item
- The type of item to get the context forsubContext
- Current sub context.defaultContext
- A default context to copy values from if a new context
must be created.ItemContext
object.InvalidDataException
- If the item is nullBaseException
- If there is another errorgetCurrentContext(Item)
,
loadContextInternal(Item, String, String)
,
saveCurrentContextAs(Item, String, boolean, boolean)
public ItemContext loadContext(int contextId) throws NotLoggedInException, BaseException
contextId
- The ID of the context to loadItemContext
object or nullNotLoggedInException
- If no user is logged inBaseException
- If there is another errorsaveCurrentContextAs(Item, String, boolean, boolean)
,
getContextNames(Item)
public ItemContext loadContext(int contextId, boolean copyTemporaryObjects) throws NotLoggedInException, BaseException
contextId
- The ID of the context to loadItemContext
object or nullNotLoggedInException
- If no user is logged inBaseException
- If there is another errorsaveCurrentContextAs(Item, String, boolean, boolean)
,
getContextNames(Item)
public ItemContext getContext(int contextId)
contextId
- The ID of the context to loadItemContext
object or nullNotLoggedInException
- If no user is logged inBaseException
- If there is another errorloadContext(int)
,
getContextNames(Item)
public int saveCurrentContextAs(Item item, java.lang.String name, boolean overwrite, boolean isPublic) throws PermissionDeniedException, InvalidDataException, ItemAlreadyExistsException, BaseException
saveCurrentContextAs(item, "", name, overwrite, isPublic)
.public int saveCurrentContextAs(Item item, java.lang.String subContext, java.lang.String name, boolean overwrite, boolean isPublic) throws PermissionDeniedException, InvalidDataException, ItemAlreadyExistsException, BaseException
loadContext(int)
method. If no current context
exists, this method does nothing.item
- The type of item to save the current context forsubContext
- The name of the sub-contextname
- The name of the contextoverwrite
- If TRUE, an existing context with the same name is
overwritten, otherwise an exception is thrownisPublic
- If the saved context should be visible to everyone
or not (requires Permission.SHARE_TO_EVERYONE
permission)PermissionDeniedException
- If no user is logged in,
or if the logged in user is a multi-user account or if the isPublic
parameter is true but the logged in user doesn't have SHARE_TO_EVERYONE
permissionInvalidDataException
- If the item or name parameter is nullItemAlreadyExistsException
- If another context with the
same name exists and the overwrite parameter is FALSEBaseException
- If there is another errorpublic void deleteContext(int contextId) throws PermissionDeniedException, BaseException
contextId
- The id of the contextPermissionDeniedException
- If no user is logged in,
or if he logged in user is a multi-user account or isn't the owner of the contextBaseException
- If there is another errorgetContextNames(Item, String)
public Enumeration<java.lang.Integer,java.lang.String> getContextNames(Item item) throws InvalidDataException, BaseException
getContextNames(item, "")
InvalidDataException
BaseException
getContextNames(Item, String)
public Enumeration<java.lang.Integer,java.lang.String> getContextNames(Item item, java.lang.String subContext) throws InvalidDataException, BaseException
item
- Item for which named contexts should be returnedsubContext
- Certain sub context to return contexts for.InvalidDataException
- If the item parameter is nullBaseException
- If there is another errorprivate ItemContext loadContextInternal(int contextId) throws BaseException
BaseException
private ItemContext loadContextInternal(Item item, java.lang.String subContext, java.lang.String name) throws BaseException
BaseException
private void saveAllCurrentContexts(Session session, UserData userData, ClientData clientData)
public java.util.List<ItemContext> getAllCurrentContexts(boolean inMemory, boolean inDatabase)
ItemContext.getContextId()
returns the same value.inMemory
- If TRUE, the in-memory contexts are included in the listinDatabase
- If TRUE, the in-database contexts are included in the listpublic int deleteCurrentContexts(Item itemType, boolean inMemory, boolean inDatabase)
itemType
- The item type to delete the contexts for, or null
to delete all contextsinMemory
- TRUE to delete in-memory contextsinDatabase
- TRUE to delete in-database contextspublic java.util.Locale getLocale()
public java.lang.Object getSessionSetting(java.lang.String name)
name
- The name of the settingpublic java.lang.Object setSessionSetting(java.lang.String name, java.lang.Object value)
name
- The name of the settingvalue
- The new value of the setting, or null to remove the
settingpublic java.lang.String getUserClientSetting(java.lang.String name)
UserClientSetting
with the
specified name. If no user is logged in null is returned.name
- The name of the settingpublic java.lang.String setUserClientSetting(java.lang.String name, java.lang.String value)
UserClientSetting
.name
- The name of the settingvalue
- The new value of the setting, or null to remove the
settingpublic java.lang.String getUserDefaultSetting(java.lang.String name)
UserDefaultSetting
with the
specified name.name
- The name of the settingpublic java.lang.String setUserDefaultSetting(java.lang.String name, java.lang.String value)
UserDefaultSetting
.name
- The name of the settingvalue
- The new value of the setting, or null to remove the
settingpublic java.lang.String getClientDefaultSetting(java.lang.String name)
ClientDefaultSetting
with the
specified name.name
- The name of the settingprivate java.util.Map<java.lang.String,SessionControl.SettingInfo> listToMap(java.util.List<? extends SettingData> settings)
SettingData.getName()
) and the value is a SessionControl.SettingInfo
object.private java.util.Map<java.lang.String,SessionControl.SettingInfo> loadClientDefaultSettings(Session session, int clientId)
private java.util.Map<java.lang.String,SessionControl.SettingInfo> loadUserDefaultSettings(Session session, int userId)
private java.util.Map<java.lang.String,SessionControl.SettingInfo> loadUserClientSettings(Session session, int userId, int clientId)
private void saveAllUserSettings(Session session)
private <I extends SettingData> void saveSettings(Session session, Query query, java.util.Map<java.lang.String,SessionControl.SettingInfo> settings, java.lang.Class<I> dataClass, UserData userData, ClientData clientData) throws BaseException
session
- The Hibernate sessionquery
- A Hibernate query to load the settings already in the databasesettings
- The settings to savedataClass
- The Class
of the settings, should be one of
UserDefaultSettingData
or UserClientSettingData
userData
- The UserData
object for the logged in userclientData
- The ClientData
object for the client applicationBaseException
protected void clearDbControlCache()
protected void cleanUp()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable