Package net.sf.basedb.core
Class User
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.User
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Nameable
,Registered
,Removable
,SystemItem
This class is used to represent a user in BASE.
- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2018-03-14 14:17:56 +0100 (on, 14 mar 2018) $
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static class
A runtime filter implementation that limits a query to only return users which are members of at least one group where the logged in user is also a member unless the logged in user has generic read permission. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum length of the address that can be stored in the database.static final int
The maximum length of the email address that can be stored in the database.static final int
The maximum length of the external ID that can be stored in the database.static final int
The maximum length of the fax that can be stored in the database.static final int
The maximum length of the login that can be stored in the database.static final int
The maximum length of the organisation that can be stored in the database.static final int
The maximum length of the phone that can be stored in the database.static final int
The maximum length of the url that can be stored in the database.static final String
The system id for theUser
representing the root account.private static final QueryRuntimeFilter
This filter will limit a query to only return users which are members of at least one of the groups where the logged in user is a member unless the logged in user has generic read permission.static final Item
The type of item represented by this class.private String
private String
Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
Fields inherited from interface net.sf.basedb.core.SystemItem
MAX_SYSTEM_ID_LENGTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) static void
addDefultRolesAndGroups
(Session session, UserData user) Add all groups and roles that has been marked as default to the user.void
Add this user to the groups and roles that has been marked as default for new users.(package private) int
breakCircularReferences
(Set<ItemProxy> items) If the home directory is found among the items, set it to null.(package private) static boolean
checkPassword
(String password, String cryptedPassword) Check the plain-text password against the crypted password.void
Disable device verification.void
Verify the email and enables device verification.(package private) static String
encryptPassword
(String password) Encrypt the plain-text password.static boolean
externalIdIsUsed
(DbControl dc, String externalId) Check if an external ID already exists in the databaseGet the address for the user, or null if unknown.getAllMembers
(DbControl dc, Set<Integer> groupIds) Load the ID:s of all users that are direct members of the specified groups.getAllMembers
(Session session, Collection<Integer> groupIds) static User
Get aUser
item when you know the ID.getClientSettings
(Client client) Get a query that returns the settings for the specified client.(package private) UserData
getData()
Get theBasicData
object that holds all data for this item.Get a query that returns all default settings for this user.Get the description for the item.long
getDiskUsage
(QuotaType quotaType, Location location) Get the used number of bytes for the specified quota type and location.getEmail()
Get the email address to the user.Get the date that the item was registered in the database.Get the expire date of the account.getExtended
(String name) Gets an extended property with a certain nameGet the external id for the user account.getFax()
Get the fax number to the user, or null if unknown.Get a query that returns the groups where this user is a member.Get the homeDirectory
for this user.getItems
(Set<Item> itemTypes, int firstItem, int maxItems, Permission permission, Restriction restriction) Load the items owned by this user.getItems
(Item itemType, int firstItem, int maxItems, Permission permission) getLogin()
Get the login for the user account.Get a query that returns all messages for the user.getName()
Get the name of the item.static User
Create a newUser
item.Get the organisation this user works for, or null if unknown.getPhone()
Get the phone number to the user, or null if unknown.(package private) PluginPermission
Make sure plug-ins always has at least read access to the logged in user.Get a query that returns the projects where this user is a member.getQuery()
Get a query configured to retrieve users.getQuota()
Get theQuota
that applies to the user.Get the user that flagged this item for removal.getRoles()
Get a query that returns the roles where this user is a member.boolean
If this flag has been set, messges to the user is also sent as an email.Get the system id for the item.getType()
Get the type of item represented by the object.getUrl()
Get the URL to the user's homepage.boolean
A flag indicating if device verification has been enabled for this account.Get all:Ownable
items owned by this userboolean
hasExceededQuota
(QuotaType quotaType, Location location) Check if the user has used more quota than what has been assigned.(package private) void
initPermissions
(int granted, int denied) If the logged in user is the same as this user RESTRICTED_WRITE permissions is granted, unless it is a multiuser account.boolean
Check if this account has been disabled.boolean
Check if the user account is a multiuser account or not.boolean
Check if the removed flag is set for this item.boolean
Check if the item is a system item or not.boolean
isUsed()
Checks if: anyOwnable
item is owned by this user A user can also be referenced from groups, roles, projects, item keys, sessions and settings, but those references are automatically deleted if the user is deleted and aren't inclued in this check.static boolean
loginIsUsed
(DbControl dc, String login) Check if a login name already exists in the databasenewClientSetting
(Client client, String name, String value) Create a new client application setting for this user.newDefaultSetting
(String name, String value) Create a new default setting for this user.void
sendEmailVerificationCode
(String serverUrl) Send a verification code to the currently registered email address.void
setAddress
(String address) Set the address for the user, or null if unknown.void
setDescription
(String description) Set the description for the item.void
setDisabled
(boolean disabled) Disables or enables the account.void
Set the email address to the user, or null if unknown.void
setEntryDate
(Date entryDate) Set the date the entry was registered in the database.void
setExpirationDate
(Date expirationDate) Sets the expiration date of the account.void
setExtended
(String name, Object value) Sets an extended propertyvoid
setExternalId
(String externalId) Set the external id for the user account.void
Set the fax number to the user, or null if unknown.void
setHomeDirectory
(Directory homeDirectory) Set the home directory for the user.void
Set the login for the user account.void
setMultiuserAccount
(boolean multiuserAccount) Sets if the user account is multiuser account.void
Set the name of the item.void
setOrganisation
(String organisation) Set the organisation this user works for, or null if unknown.void
setPassword
(String password) Set the password.void
Set the phone number to the user, or null if unknown.void
Set the quota for the user.void
setQuotaGroup
(Group quotaGroup) Set the group whose quota should be checked for disk consuming items.void
setRemoved
(boolean removed) Set the removed flag for this item.void
setSendMessagesAsEmail
(boolean sendMessagesAsEmail) Set a flag indicating that all messages should also be sent as email.void
Set the URL to the user's homepage, or null if unknown.void
setUseDeviceVerification
(boolean useDeviceVerification) Enable or disable device verification for this user account.Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
-
Field Details
-
TYPE
The type of item represented by this class. -
ROOT
The system id for theUser
representing the root account. The root user has full access to everything in BASE.- See Also:
-
RUNTIME_FILTER
This filter will limit a query to only return users which are members of at least one of the groups where the logged in user is a member unless the logged in user has generic read permission. -
verificationCode
-
verifiedEmail
-
MAX_EXTERNAL_ID_LENGTH
public static final int MAX_EXTERNAL_ID_LENGTHThe maximum length of the external ID that can be stored in the database.- See Also:
-
MAX_LOGIN_LENGTH
public static final int MAX_LOGIN_LENGTHThe maximum length of the login that can be stored in the database.- See Also:
-
MAX_ORGANISATION_LENGTH
public static final int MAX_ORGANISATION_LENGTHThe maximum length of the organisation that can be stored in the database.- See Also:
-
MAX_ADDRESS_LENGTH
public static final int MAX_ADDRESS_LENGTHThe maximum length of the address that can be stored in the database.- See Also:
-
MAX_PHONE_LENGTH
public static final int MAX_PHONE_LENGTHThe maximum length of the phone that can be stored in the database.- See Also:
-
MAX_FAX_LENGTH
public static final int MAX_FAX_LENGTHThe maximum length of the fax that can be stored in the database.- See Also:
-
MAX_EMAIL_LENGTH
public static final int MAX_EMAIL_LENGTHThe maximum length of the email address that can be stored in the database.- See Also:
-
MAX_URL_LENGTH
public static final int MAX_URL_LENGTHThe maximum length of the url that can be stored in the database.- See Also:
-
-
Constructor Details
-
User
User(UserData userData)
-
-
Method Details
-
getNew
Create a newUser
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accesslogin
- The login for the user (required)password
- The password for the user (required)- Returns:
- The new
User
item - Throws:
BaseException
- If there is an error
-
getById
public static User getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aUser
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
User
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
-
getAllMembers
Load the ID:s of all users that are direct members of the specified groups.- Parameters:
dc
- DbControl used to access database.groupIds
- The ID:s of the groups- Returns:
- The ID:s of all members
- See Also:
-
getAllMembers
-
addDefultRolesAndGroups
Add all groups and roles that has been marked as default to the user.- Since:
- 2.4
-
getQuery
Get a query configured to retrieve users. If the logged in user doesn't have generic permission to all users, only users that are members in at least one group where the logged in user is also a member are returned. TheEveryone
group is not considered since all users automatically are members to that group.- Returns:
- An
ItemQuery
object
-
loginIsUsed
Check if a login name already exists in the database- Parameters:
dc
- An open DbControl used to access the database.login
- The login name to look for- Returns:
- TRUE if an user has the login. FALSE if the login is not in use.
-
externalIdIsUsed
Check if an external ID already exists in the database- Parameters:
dc
- An open DbControl used to access the database.externalId
- The externalID to look for- Returns:
- TRUE if an user has the external ID. FALSE if the externalID is not in use.
-
encryptPassword
Encrypt the plain-text password. The password is ecnrypted by first calculating the MD5 of the password and then using bcrypt with a random salt on the MD5.- Parameters:
password
- The plain-text password
-
checkPassword
Check the plain-text password against the crypted password.- Parameters:
password
- The plain-text passwordcryptedPassword
- The crypted password- Returns:
- TRUE if the password is correct, FALSE if not
-
getData
UserData 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.- Specified by:
getType
in interfaceIdentifiable
- Returns:
- A value indicating the type of item
-
getName
Description copied from interface:Nameable
Get the name of the item. -
setName
Description copied from interface:Nameable
Set the name of the item. The name cannot be null and mustn't be longer than the value specified by theNameable.MAX_NAME_LENGTH
constant.- Specified by:
setName
in interfaceNameable
- Parameters:
name
- The new name for the item- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the name is null or longer than specified by theNameable.MAX_NAME_LENGTH
constant
-
getDescription
Description copied from interface:Nameable
Get the description for the item.- Specified by:
getDescription
in interfaceNameable
- Returns:
- A
String
with a description of the item
-
setDescription
public void setDescription(String description) throws PermissionDeniedException, InvalidDataException Description copied from interface:Nameable
Set the description for the item. The description can be null but mustn't be longer than the value specified by theNameable.MAX_DESCRIPTION_LENGTH
constant.- Specified by:
setDescription
in interfaceNameable
- Parameters:
description
- The new description for the item- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the description longer than specified by theNameable.MAX_DESCRIPTION_LENGTH
constant
-
isRemoved
public boolean isRemoved()Description copied from interface:Removable
Check if the removed flag is set for this item. -
setRemoved
Description copied from interface:Removable
Set the removed flag for this item.- Specified by:
setRemoved
in interfaceRemovable
- Parameters:
removed
- TRUE if the item should be flagged as removed, FALSE otherwise- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.DELETE
permission for setting the flag to TRUE orPermission.WRITE
permission for setting the flag to FALSE
-
getRemovedBy
Description copied from interface:Removable
Get the user that flagged this item for removal.- Specified by:
getRemovedBy
in interfaceRemovable
- Returns:
- A User object, or null if this item has not been flagged
- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission for the userItemNotFoundException
- If the user that removed this item can't be found
-
getSystemId
Description copied from interface:SystemItem
Get the system id for the item.- Specified by:
getSystemId
in interfaceSystemItem
- Returns:
- The id of the item or null if it is not a system item
-
isSystemItem
public boolean isSystemItem()Description copied from interface:SystemItem
Check if the item is a system item or not. A system item have a non-null value for the system id.- Specified by:
isSystemItem
in interfaceSystemItem
- Returns:
- TRUE if this item is a system item, FALSE otherwise
-
getEntryDate
Description copied from interface:Registered
Get the date that the item was registered in the database.- Specified by:
getEntryDate
in interfaceRegistered
- Returns:
- A date or null if this is not known
-
setEntryDate
Description copied from interface:Registered
Set the date the entry was registered in the database. Implementations should only allow this property to be set before the item is first stored in the database. The intention of this method is to facilitate export/import of data between server.- Specified by:
setEntryDate
in interfaceRegistered
- Parameters:
entryDate
- A date or null to use today's date
-
isUsed
Checks if:- any
Ownable
item is owned by this user
- Overrides:
isUsed
in classBasicItem
- Returns:
- TRUE if this item is used, FALSE otherwise
- Throws:
BaseException
- If not able to tell if item is used or not.- See Also:
- any
-
getUsingItems
Get all:Ownable
items owned by this user
- Overrides:
getUsingItems
in classBasicItem
- Returns:
- A set containing proxies for the items, or an empty set if no items are using this item
- Since:
- 2.2
- See Also:
-
breakCircularReferences
If the home directory is found among the items, set it to null.- Overrides:
breakCircularReferences
in classBasicItem
- Since:
- 3.8
-
initPermissions
If the logged in user is the same as this user RESTRICTED_WRITE permissions is granted, unless it is a multiuser account. If this is a system user, delete and create permissions are revoked. Finally READ permission is granted to if the user is a member of at least one group where the logged in user is also a member.- Overrides:
initPermissions
in classBasicItem
- 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
-
getPluginPermissions
PluginPermission getPluginPermissions()Make sure plug-ins always has at least read access to the logged in user.- Overrides:
getPluginPermissions
in classBasicItem
- Since:
- 2.9
-
setPassword
Set the password.- Parameters:
password
- Password to set. A null password is not allowed.- Throws:
PermissionDeniedException
- If the logged in user doesn't have restricted_write permissionInvalidDataException
- If the new password is null
-
getExpirationDate
Get the expire date of the account. When the expiration date have been passed the user can't login. A null value indicates that the account will never expire.- Returns:
- A
Date
object or null.
-
setExpirationDate
Sets the expiration date of the account. A null value indicates that the account will never expire.- Parameters:
expirationDate
- Date when the account should expire.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission
-
isDisabled
public boolean isDisabled()Check if this account has been disabled. It is not possible to login if the account is disabled.- Returns:
- TRUE if the account is disabled, FALSE otherwise
-
setDisabled
Disables or enables the account.- Parameters:
disabled
- TRUE to disabled the account, FALSE to enabled it- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission- See Also:
-
getUseDeviceVerification
public boolean getUseDeviceVerification()A flag indicating if device verification has been enabled for this account.- Since:
- 3.12
-
setUseDeviceVerification
public void setUseDeviceVerification(boolean useDeviceVerification) Enable or disable device verification for this user account. Note that WRITE permission is required to use this method which is normally only given to administrators. To let a user enable this feature by itself, the email address must first be verified.- Since:
- 3.12
- See Also:
-
sendEmailVerificationCode
Send a verification code to the currently registered email address. The client application should ask the user to enter the verification code and then callenableDeviceVerification(String)
. The verification must be done with the same User instance since the verification code is only temporarily stored inside this instance.- Parameters:
serverUrl
- URL to the server or null to use the default application title- Since:
- 3.12
-
enableDeviceVerification
Verify the email and enables device verification.- Parameters:
code
- The code that was sent by email to the user- Since:
- 3.12
- See Also:
-
disableDeviceVerification
public void disableDeviceVerification()Disable device verification.- Since:
- 3.12
-
isMultiuserAccount
public boolean isMultiuserAccount()Check if the user account is a multiuser account or not. Multiuser accounts don't have write permissions for contact information and settings.- Returns:
- TRUE if the user account is a multiuser account, FALSE otherwise
-
setMultiuserAccount
Sets if the user account is multiuser account.- Parameters:
multiuserAccount
- Set to TRUE if it is, FALSE otherwise.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission
-
getExternalId
Get the external id for the user account. The external id is intended to be used by external applications which need to synchronize data between the BASE database and some external database. It is not used by the core.- Returns:
- A String object or null if not set.
-
setExternalId
public void setExternalId(String externalId) throws PermissionDeniedException, InvalidDataException, BaseException Set the external id for the user account.- Parameters:
externalId
- External id to be set, null is allowed.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is longer thanMAX_EXTERNAL_ID_LENGTH
BaseException
- If there is another error
-
getLogin
Get the login for the user account.- Returns:
- A String object.
-
setLogin
Set the login for the user account.- Parameters:
login
- Login name to set. Null is not allowed.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is null or longer thanMAX_LOGIN_LENGTH
-
getOrganisation
Get the organisation this user works for, or null if unknown.- Returns:
- A String object or null if not set.
-
setOrganisation
public void setOrganisation(String organisation) throws PermissionDeniedException, InvalidDataException Set the organisation this user works for, or null if unknown.- Parameters:
organisation
- Some kind of name or description of the organisation to associate with the user. Not longer then 255- Throws:
PermissionDeniedException
- If the logged in user doesn't have restricted write permissionInvalidDataException
- If the new value is longer thanMAX_ORGANISATION_LENGTH
-
getAddress
Get the address for the user, or null if unknown.- Returns:
- A String object, or null if not set.
-
setAddress
Set the address for the user, or null if unknown.- Parameters:
address
- Address to be set.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is longer thanMAX_ADDRESS_LENGTH
-
getPhone
Get the phone number to the user, or null if unknown.- Returns:
- A String object or null if not set.
-
setPhone
Set the phone number to the user, or null if unknown.- Parameters:
phone
- Phone number to set.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is longer thanMAX_PHONE_LENGTH
-
getFax
Get the fax number to the user, or null if unknown.- Returns:
- A String object or null if not set.
-
setFax
Set the fax number to the user, or null if unknown.- Parameters:
fax
- Fax number to be set.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is longer thanMAX_FAX_LENGTH
-
getEmail
Get the email address to the user.- Returns:
- A java.lang.String object, or null if unknown.
-
setEmail
Set the email address to the user, or null if unknown. Note! If the email address is changed, device verification will be disabled until the email address is verified!- Parameters:
email
- Email to be set, null is allowed.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is longer thanMAX_EMAIL_LENGTH
-
getSendMessagesAsEmail
public boolean getSendMessagesAsEmail()If this flag has been set, messges to the user is also sent as an email. This requires that the server admin has configured an outgoing smtp server and that this user has specified a valid email address.- Returns:
- TRUE to send messages as email, FALSE if not
- Since:
- 2.16
-
setSendMessagesAsEmail
public void setSendMessagesAsEmail(boolean sendMessagesAsEmail) Set a flag indicating that all messages should also be sent as email. SeegetSendMessagesAsEmail()
for information about restrictions.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission- Since:
- 2.16
-
getUrl
Get the URL to the user's homepage.- Returns:
- A String object, or null if unknown.
-
setUrl
Set the URL to the user's homepage, or null if unknown.- Parameters:
url
- URL to set. The String can be at maximum 255.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is longer thanMAX_URL_LENGTH
-
getExtended
Gets an extended property with a certain name- Parameters:
name
- The name of the property- Returns:
- An Object or null if no extended property exists with the name
- Since:
- 2.4
-
setExtended
Sets an extended property- Parameters:
name
- The name to call the extended property byvalue
- The value the extended property should have- Throws:
PermissionDeniedException
- If the logged in user doesn't have @link {Permission#RESTRICTED_WRITE} permission for the user.- Since:
- 2.4
-
getQuota
Get theQuota
that applies to the user.- Returns:
- A
Quota
item - Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission to the itemBaseException
- If there is some other kind of error.
-
setQuota
Set the quota for the user.- Parameters:
quota
- The newQuota
- Throws:
InvalidDataException
- If the quota is nullPermissionDeniedException
- If the logged in user doesn't havePermission.WRITE
permission for the user orPermission.USE
permission for the quota
-
getQuotaGroup
- Returns:
- A
Group
item, or null if no group has been specified - Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission to the itemBaseException
- If there is some other kind of error.
-
setQuotaGroup
Set the group whose quota should be checked for disk consuming items.- Parameters:
quotaGroup
- The newGroup
- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.WRITE
permission for the user orPermission.USE
permission for the group
-
getDiskUsage
Get the used number of bytes for the specified quota type and location.- Parameters:
quotaType
- TheQuotaType
location
- The location- Returns:
- The number of bytes that have been used
- Throws:
BaseException
- If one of the required parameter is null or if there is some other kind of error.
-
hasExceededQuota
Check if the user has used more quota than what has been assigned. This method will check both the user's primary quota and, if it exists, the group quota. The most restrictive quota is used.- Parameters:
quotaType
- The quota type to checklocation
- The location- Returns:
- TRUE if the quota has been exceeded, FALSE otherwise
- Since:
- 2.4
-
getHomeDirectory
Get the homeDirectory
for this user.- Returns:
- A
Directory
item, or null if no home directory has been specified - Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission to the directoryBaseException
- If there is some other kind of error.
-
setHomeDirectory
public void setHomeDirectory(Directory homeDirectory) throws PermissionDeniedException, InvalidDataException Set the home directory for the user.- Parameters:
homeDirectory
- The new homeDirectory
- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.WRITE
permission for the user orPermission.USE
permission for the directoryInvalidDataException
- If the home directory is not a subdirectory to /root/home
-
addToDefaultRolesAndGroups
Add this user to the groups and roles that has been marked as default for new users.- Throws:
BaseException
- If there is a problem- Since:
- 2.4
-
getRoles
Get a query that returns the roles where this user is a member. The query excludes roles that the logged in user doesn't have permission to read.- Returns:
- a restricted
ItemQuery
. - See Also:
-
getGroups
Get a query that returns the groups where this user is a member. The query excludes groups that the logged in user doesn't have permission to read.- Returns:
- A restricted
ItemQuery
. - See Also:
-
getProjects
Get a query that returns the projects where this user is a member. The query excludes projects that the logged in user doesn't have permission to read. The query doesn't include projects where this user is the owner.- Returns:
- A restricted
ItemQuery
- See Also:
-
newDefaultSetting
public UserDefaultSetting newDefaultSetting(String name, String value) throws PermissionDeniedException, InvalidDataException, BaseException Create a new default setting for this user.- Parameters:
name
- The name of the settingvalue
- The value of the setting- Returns:
- The new
UserDefaultSetting
object - Throws:
PermissionDeniedException
- If the logged in user doesn't have restricted write permissionInvalidDataException
- If the name or value is null or longer than what is allowedBaseException
- If there is another error- See Also:
-
getDefaultSettings
Get a query that returns all default settings for this user.- Returns:
- An
ItemQuery
object - See Also:
-
newClientSetting
public UserClientSetting newClientSetting(Client client, String name, String value) throws PermissionDeniedException, InvalidDataException, BaseException Create a new client application setting for this user.- Parameters:
client
- The client applicationname
- The name of the settingvalue
- The value of the setting- Returns:
- The new
UserDefaultSetting
object - Throws:
PermissionDeniedException
- If the logged in user doesn't have restricted write permissionInvalidDataException
- If the name or value is null or longer than what is allowedBaseException
- If there is another error- See Also:
-
getClientSettings
Get a query that returns the settings for the specified client.- Parameters:
client
- The client application- Returns:
- An
ItemQuery
object - See Also:
-
getMessages
Get a query that returns all messages for the user.- Returns:
- An
ItemQuery
object - See Also:
-
getItems
public ResultList<Ownable> getItems(Item itemType, int firstItem, int maxItems, Permission permission) -
getItems
public ResultList<Ownable> getItems(Set<Item> itemTypes, int firstItem, int maxItems, Permission permission, Restriction restriction) Load the items owned by this user. If this user is not the same as the currently logged in user this method will only load items that are shared to the logged in user with the given permission.- Parameters:
itemTypes
- Limit the list to only return items of the specified types, use null or an empty set to return items of all typesfirstItem
- The index of the first item to return (0-based)maxItems
- The maximum number of items to return, or 0 to return all itemspermission
- The permission the logged in user should have on the itemsrestriction
- An optional restriction that is applied to the queries to further reduce the list- Returns:
- A list containing ownable items
- Since:
- 2.15
-