|
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<UserData> net.sf.basedb.core.User
public class User
This class is used to represent a user in BASE.
Nested Class Summary | |
---|---|
private static class |
User.QueryRuntimeFilterImpl
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 | |
---|---|
static int |
MAX_ADDRESS_LENGTH
The maximum length of the address that can be stored in the database. |
static int |
MAX_EMAIL_LENGTH
The maximum length of the email address that can be stored in the database. |
static int |
MAX_EXTERNAL_ID_LENGTH
The maximum length of the external ID that can be stored in the database. |
static int |
MAX_FAX_LENGTH
The maximum length of the fax that can be stored in the database. |
static int |
MAX_LOGIN_LENGTH
The maximum length of the login that can be stored in the database. |
static int |
MAX_ORGANISATION_LENGTH
The maximum length of the organisation that can be stored in the database. |
static int |
MAX_PHONE_LENGTH
The maximum length of the phone that can be stored in the database. |
static int |
MAX_URL_LENGTH
The maximum length of the url that can be stored in the database. |
static String |
ROOT
The system id for the User representing the root account. |
private static QueryRuntimeFilter |
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. |
static Item |
TYPE
The type of item represented by this class. |
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 | |
---|---|
User(UserData userData)
|
Method Summary | |
---|---|
(package private) static void |
addDefultRolesAndGroups(org.hibernate.Session session,
UserData user)
Add all groups and roles that has been marked as default to the user. |
void |
addToDefaultRolesAndGroups()
Add this user to the groups and roles that has been marked as default for new users. |
static boolean |
externalIdIsUsed(DbControl dc,
String externalId)
Check if an external ID already exists in the database |
String |
getAddress()
Get the address for the user, or null if unknown. |
static Set<Integer> |
getAllMembers(DbControl dc,
Set<Integer> groupIds)
Load the ID:s of all users that are direct members of the specified groups. |
(package private) static Set<Integer> |
getAllMembers(org.hibernate.Session session,
Collection<Integer> groupIds)
|
static User |
getById(DbControl dc,
int id)
Get a User item when you know the ID. |
ItemQuery<UserClientSetting> |
getClientSettings(Client client)
Get a query that returns the settings for the specified client. |
ItemQuery<UserDefaultSetting> |
getDefaultSettings()
Get a query that returns all default settings for this user. |
String |
getDescription()
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. |
String |
getEmail()
Get the email address to the user. |
Date |
getEntryDate()
Get the date that the item was registered in the database. |
Date |
getExpirationDate()
Get the expire date of the account. |
Object |
getExtended(String name)
Gets an extended property with a certain name |
String |
getExternalId()
Get the external id for the user account. |
String |
getFax()
Get the fax number to the user, or null if unknown. |
ItemQuery<Group> |
getGroups()
Get a query that returns the groups where this user is a member. |
Directory |
getHomeDirectory()
Get the home Directory for this user. |
ResultList<Ownable> |
getItems(Item itemType,
int firstItem,
int maxItems,
Permission permission)
|
ResultList<Ownable> |
getItems(Set<Item> itemTypes,
int firstItem,
int maxItems,
Permission permission)
Deprecated. In 2.15, use getItems(Set, int, int, Permission, Restriction) instead |
ResultList<Ownable> |
getItems(Set<Item> itemTypes,
int firstItem,
int maxItems,
Permission permission,
Restriction restriction)
Load the items owned by this user. |
String |
getLogin()
Get the login for the user account. |
ItemQuery<Message> |
getMessages()
Get a query that returns all messages for the user. |
String |
getName()
Get the name of the item. |
static User |
getNew(DbControl dc,
String login,
String password)
Create a new User item. |
String |
getOrganisation()
Get the organisation this user works for, or null if unknown. |
String |
getPhone()
Get the phone number to the user, or null if unknown. |
(package private) PluginPermission |
getPluginPermissions()
Make sure plug-ins always has at least read access to the logged in user. |
ItemQuery<Project> |
getProjects()
Get a query that returns the projects where this user is a member. |
static ItemQuery<User> |
getQuery()
Get a query configured to retrieve users. |
Quota |
getQuota()
Get the Quota that applies to the user. |
Group |
getQuotaGroup()
Get the Group whose Quota also applies
to the user. |
ItemQuery<Role> |
getRoles()
Get a query that returns the roles where this user is a member. |
boolean |
getSendMessagesAsEmail()
If this flag has been set, messges to the user is also sent as an email. |
String |
getSystemId()
Get the system id for the item. |
Item |
getType()
Get the type of item represented by the object. |
String |
getUrl()
Get the URL to the user's homepage. |
Set<ItemProxy> |
getUsingItems()
Get all: Ownable items owned by this user
|
boolean |
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 |
isDisabled()
Check if this account has been disabled. |
boolean |
isMultiuserAccount()
Check if the user account is a multiuser account or not. |
boolean |
isRemoved()
Check if the removed flag is set for this item. |
boolean |
isSystemItem()
Check if the item is a system item or not. |
boolean |
isUsed()
Checks if: any Ownable 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 database |
UserClientSetting |
newClientSetting(Client client,
String name,
String value)
Create a new client application setting for this user. |
UserDefaultSetting |
newDefaultSetting(String name,
String value)
Create a new default setting for this user. |
void |
setAddress(String address)
Set the address for the user, or null if unknown. |
void |
setBase1Password(String md5Password)
Set the encrypted password from BASE 1. |
void |
setDescription(String description)
Set the description for the item. |
void |
setDisabled(boolean disabled)
Disables or enables the account. |
void |
setEmail(String email)
Set the email address to the user, or null if unknown. |
void |
setExpirationDate(Date expirationDate)
Sets the expiration date of the account. |
void |
setExtended(String name,
Object value)
Sets an extended property |
void |
setExternalId(String externalId)
Set the external id for the user account. |
void |
setFax(String fax)
Set the fax number to the user, or null if unknown. |
void |
setHomeDirectory(Directory homeDirectory)
Set the home directory for the user. |
void |
setLogin(String login)
Set the login for the user account. |
void |
setMultiuserAccount(boolean multiuserAccount)
Sets if the user account is multiuser account. |
void |
setName(String name)
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 |
setPhone(String phone)
Set the phone number to the user, or null if unknown. |
void |
setQuota(Quota quota)
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 |
setUrl(String url)
Set the URL to the user's homepage, or null if unknown. |
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 |
Methods inherited from interface net.sf.basedb.core.Identifiable |
---|
getId, getVersion |
Methods inherited from interface net.sf.basedb.core.AccessControlled |
---|
checkPermission, getPermissions, hasPermission |
Field Detail |
---|
public static final Item TYPE
Item.USER
,
getType()
public static final String ROOT
User
representing the root account.
The root user has full access to everything in BASE.
private static final QueryRuntimeFilter RUNTIME_FILTER
public static final int MAX_EXTERNAL_ID_LENGTH
setExternalId(String)
,
Constant Field Valuespublic static final int MAX_LOGIN_LENGTH
setLogin(String)
,
Constant Field Valuespublic static final int MAX_ORGANISATION_LENGTH
setOrganisation(String)
,
Constant Field Valuespublic static final int MAX_ADDRESS_LENGTH
setAddress(String)
,
Constant Field Valuespublic static final int MAX_PHONE_LENGTH
setPhone(String)
,
Constant Field Valuespublic static final int MAX_FAX_LENGTH
setFax(String)
,
Constant Field Valuespublic static final int MAX_EMAIL_LENGTH
setEmail(String)
,
Constant Field Valuespublic static final int MAX_URL_LENGTH
setUrl(String)
,
Constant Field ValuesConstructor Detail |
---|
User(UserData userData)
Method Detail |
---|
public static User getNew(DbControl dc, String login, String password) throws BaseException
User
item.
dc
- The DbControl
which will be used for
permission checking and database accesslogin
- The login for the user (required)password
- The password for the user (required)
User
item
BaseException
- If there is an errorpublic static User getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
User
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
User
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 Set<Integer> getAllMembers(DbControl dc, Set<Integer> groupIds)
dc
- DbControl used to access database.groupIds
- The ID:s of the groups
Group.getGroupsRecursive(DbControl, Set)
static Set<Integer> getAllMembers(org.hibernate.Session session, Collection<Integer> groupIds)
static void addDefultRolesAndGroups(org.hibernate.Session session, UserData user)
public static ItemQuery<User> getQuery()
Everyone
group
is not considered since all users automatically are members to that group.
ItemQuery
objectpublic static boolean loginIsUsed(DbControl dc, String login)
dc
- An open DbControl used to access the database.login
- The login name to look for
public static boolean externalIdIsUsed(DbControl dc, String externalId)
dc
- An open DbControl used to access the database.externalId
- The externalID to look for
public Item getType()
Identifiable
Item
enumeration.
getType
in interface Identifiable
public String getName()
Nameable
getName
in interface Nameable
String
with the name of the itempublic void setName(String name) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_NAME_LENGTH
constant.
setName
in interface Nameable
name
- The new name for the item
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the name is null or longer
than specified by the Nameable.MAX_NAME_LENGTH
constantpublic String getDescription()
Nameable
getDescription
in interface Nameable
String
with a description of the itempublic void setDescription(String description) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_DESCRIPTION_LENGTH
constant.
setDescription
in interface Nameable
description
- The new description for the item
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the description longer
than specified by the Nameable.MAX_DESCRIPTION_LENGTH
constantpublic boolean isRemoved()
Removable
isRemoved
in interface Removable
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
removed
- TRUE if the item should be flagged as removed,
FALSE otherwise
PermissionDeniedException
- If the logged in user doesn't
have Permission.DELETE
permission for setting the flag
to TRUE or Permission.WRITE
permission for setting the
flag to FALSEpublic String getSystemId()
SystemItem
getSystemId
in interface SystemItem
public boolean isSystemItem()
SystemItem
isSystemItem
in interface SystemItem
public Date getEntryDate()
Registered
getEntryDate
in interface Registered
public boolean isUsed() throws BaseException
Ownable
item is owned by this user
isUsed
in class BasicItem<UserData>
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems()
Ownable
items owned by this user
getUsingItems
in class BasicItem<UserData>
BasicItem.addUsingItems(Set, Item, org.hibernate.Query)
void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem<UserData>
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<UserData>
public void setPassword(String password) throws PermissionDeniedException, InvalidDataException
password
- Password to set. A null password is not allowed.
PermissionDeniedException
- If the logged in user doesn't have
restricted_write permission
InvalidDataException
- If the new password is nullpublic void setBase1Password(String md5Password) throws PermissionDeniedException, BaseException
PermissionDeniedException
unless the logged in user is the root and
the user account is a newly created account.
md5Password
- The MD5 password from a BASE 1 installation
PermissionDeniedException
- If it is not a new user or
root isn't logged in
BaseException
- If there is some other kind of error.public Date getExpirationDate()
Date
object or null.public void setExpirationDate(Date expirationDate) throws PermissionDeniedException
expirationDate
- Date when the account should expire.
PermissionDeniedException
- If the logged in user doesn't have
write permissionpublic boolean isDisabled()
public void setDisabled(boolean disabled) throws PermissionDeniedException
disabled
- TRUE to disabled the account, FALSE to enabled it
PermissionDeniedException
- If the logged in user doesn't have
write permissionisDisabled()
public boolean isMultiuserAccount()
public void setMultiuserAccount(boolean multiuserAccount) throws PermissionDeniedException
multiuserAccount
- Set to TRUE if it is, FALSE otherwise.
PermissionDeniedException
- If the logged in user doesn't have
write permissionpublic String getExternalId()
public void setExternalId(String externalId) throws PermissionDeniedException, InvalidDataException, BaseException
externalId
- External id to be set, null is allowed.
PermissionDeniedException
- If the logged in user doesn't have
write permission
InvalidDataException
- If the new value is longer than
MAX_EXTERNAL_ID_LENGTH
BaseException
- If there is another errorpublic String getLogin()
public void setLogin(String login) throws PermissionDeniedException, InvalidDataException
login
- Login name to set. Null is not allowed.
PermissionDeniedException
- If the logged in user doesn't have
write permission
InvalidDataException
- If the new value is null or longer than
MAX_LOGIN_LENGTH
public String getOrganisation()
public void setOrganisation(String organisation) throws PermissionDeniedException, InvalidDataException
organisation
- Some kind of name or description of
the organisation to associate with the user. Not longer then 255
PermissionDeniedException
- If the logged in user doesn't have
restricted write permission
InvalidDataException
- If the new value is longer than
MAX_ORGANISATION_LENGTH
public String getAddress()
public void setAddress(String address) throws PermissionDeniedException, InvalidDataException
address
- Address to be set.
PermissionDeniedException
- If the logged in user doesn't have
write permission
InvalidDataException
- If the new value is longer than
MAX_ADDRESS_LENGTH
public String getPhone()
public void setPhone(String phone) throws PermissionDeniedException, InvalidDataException
phone
- Phone number to set.
PermissionDeniedException
- If the logged in user doesn't have
write permission
InvalidDataException
- If the new value is longer than
MAX_PHONE_LENGTH
public String getFax()
public void setFax(String fax) throws PermissionDeniedException, InvalidDataException
fax
- Fax number to be set.
PermissionDeniedException
- If the logged in user doesn't have
write permission
InvalidDataException
- If the new value is longer than
MAX_FAX_LENGTH
public String getEmail()
public void setEmail(String email) throws PermissionDeniedException, InvalidDataException
email
- Email to be set, null is allowed.
PermissionDeniedException
- If the logged in user doesn't have
write permission
InvalidDataException
- If the new value is longer than
MAX_EMAIL_LENGTH
public boolean getSendMessagesAsEmail()
public void setSendMessagesAsEmail(boolean sendMessagesAsEmail)
getSendMessagesAsEmail()
for information
about restrictions.
PermissionDeniedException
- If the logged in user doesn't have
write permissionpublic String getUrl()
public void setUrl(String url) throws PermissionDeniedException, InvalidDataException
url
- URL to set. The String can be at maximum 255.
PermissionDeniedException
- If the logged in user doesn't have
write permission
InvalidDataException
- If the new value is longer than
MAX_URL_LENGTH
public Object getExtended(String name)
name
- The name of the property
public void setExtended(String name, Object value)
name
- The name to call the extended property byvalue
- The value the extended property should have
PermissionDeniedException
- If the logged in user doesn't
have @link {Permission#WRITE} permission for the user.public Quota getQuota() throws PermissionDeniedException, BaseException
Quota
that applies to the user.
Quota
item
PermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the item
BaseException
- If there is some other kind of error.public void setQuota(Quota quota) throws PermissionDeniedException, InvalidDataException
quota
- The new Quota
InvalidDataException
- If the quota is null
PermissionDeniedException
- If the logged in user doesn't
have Permission.WRITE
permission for the user
or Permission.USE
permission for the quotapublic Group getQuotaGroup() throws PermissionDeniedException, BaseException
Group
whose Quota
also applies
to the user.
Group
item, or null if no group has been specified
PermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the item
BaseException
- If there is some other kind of error.public void setQuotaGroup(Group quotaGroup) throws PermissionDeniedException
quotaGroup
- The new Group
PermissionDeniedException
- If the logged in user doesn't
have Permission.WRITE
permission for the user
or Permission.USE
permission for the grouppublic long getDiskUsage(QuotaType quotaType, Location location) throws BaseException
quotaType
- The QuotaType
location
- The location
BaseException
- If one of the required parameter is null or
if there is some other kind of error.public boolean hasExceededQuota(QuotaType quotaType, Location location)
quotaType
- The quota type to checklocation
- The location
public Directory getHomeDirectory() throws PermissionDeniedException, BaseException
Directory
for this user.
Directory
item, or null if no home directory
has been specified
PermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the directory
BaseException
- If there is some other kind of error.public void setHomeDirectory(Directory homeDirectory) throws PermissionDeniedException, InvalidDataException
homeDirectory
- The new home Directory
PermissionDeniedException
- If the logged in user doesn't
have Permission.WRITE
permission for the user
or Permission.USE
permission for the directory
InvalidDataException
- If the home directory is not a subdirectory
to /root/homepublic void addToDefaultRolesAndGroups() throws BaseException
BaseException
- If there is a problempublic ItemQuery<Role> getRoles()
ItemQuery
.Role.getQuery()
public ItemQuery<Group> getGroups()
ItemQuery
.Group.getQuery()
public ItemQuery<Project> getProjects()
ItemQuery
Project.getQuery()
public UserDefaultSetting newDefaultSetting(String name, String value) throws PermissionDeniedException, InvalidDataException, BaseException
name
- The name of the settingvalue
- The value of the setting
UserDefaultSetting
object
PermissionDeniedException
- If the logged in user doesn't have
restricted write permission
InvalidDataException
- If the name or value is null or
longer than what is allowed
BaseException
- If there is another errorUserDefaultSetting.getNew(DbControl, User, String, String)
public ItemQuery<UserDefaultSetting> getDefaultSettings()
ItemQuery
objectUserDefaultSetting.getQuery(User)
public UserClientSetting newClientSetting(Client client, String name, String value) throws PermissionDeniedException, InvalidDataException, BaseException
client
- The client applicationname
- The name of the settingvalue
- The value of the setting
UserDefaultSetting
object
PermissionDeniedException
- If the logged in user doesn't have
restricted write permission
InvalidDataException
- If the name or value is null or
longer than what is allowed
BaseException
- If there is another errorUserClientSetting.getNew(DbControl, User, Client, String, String)
public ItemQuery<UserClientSetting> getClientSettings(Client client)
client
- The client application
ItemQuery
objectUserClientSetting.getQuery(User, Client)
public ItemQuery<Message> getMessages()
ItemQuery
objectMessage.getQuery(User)
public ResultList<Ownable> getItems(Item itemType, int firstItem, int maxItems, Permission permission)
getItems(Set, int, int, Permission)
public ResultList<Ownable> getItems(Set<Item> itemTypes, int firstItem, int maxItems, Permission permission)
getItems(Set, int, int, Permission, Restriction)
instead
public ResultList<Ownable> getItems(Set<Item> itemTypes, int firstItem, int maxItems, Permission permission, Restriction restriction)
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
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |