Package net.sf.basedb.core
Class UserDevice
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.UserDevice
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Nameable
,Registered
A user device represents a verified device a user may
use for accessing BASE.
- Since:
- 3.12
- Author:
- Nicklas
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static class
A runtime filter implementation that limits a query to only return devices for the currently logged in user unless the logged in user has generic read permission. -
Field Summary
Modifier and TypeFieldDescriptionprivate static final QueryRuntimeFilter
This filter will limit a query to only return devices for the logged in user unless the logged in user has generic read permission.static final Item
The type of item represented by this class.Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic UserDevice
Get aUserDevice
item when you know the ID.Get the client application the user was using with this device.(package private) UserDeviceData
getData()
Get theBasicData
object that holds all data for this item.Get the description for the item.Get the date that the item was registered in the database.Get the remote ID of the host the user used for this device the last time.Get the date and time the user last used this device.Get the last known location of the device.Get the last known location latitude of the device.Get the last known location longitude of the device.getName()
Get the name of the item.static ItemQuery<UserDevice>
Get a query configured to retrieve devices for the specified user.Get a query for loading login session from this device.getType()
Get the type of item represented by the object.getUser()
Get the user that owns this device.Get the user agent string of this device.(package private) void
initPermissions
(int granted, int denied) DELETE permission is granted if the logged in user is the owner of this device.boolean
Has this device been verified or not?void
setDescription
(String description) Set the description for the item.void
setEntryDate
(Date entryDate) Set the date the entry was registered in the database.void
Set the name of the item.Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
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.- See Also:
-
RUNTIME_FILTER
This filter will limit a query to only return devices for the logged in user unless the logged in user has generic read permission.
-
-
Constructor Details
-
UserDevice
UserDevice(UserDeviceData deviceData)
-
-
Method Details
-
getById
public static UserDevice getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aUserDevice
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
UserDevice
item - Throws:
ItemNotFoundException
PermissionDeniedException
BaseException
-
getQuery
Get a query configured to retrieve devices for the specified user.- Parameters:
user
- The user to retreive devices for, null is allowed if the logged in user has generic READ permission for devices in which case all devices will be returned- Returns:
- An
ItemQuery
object
-
getData
UserDeviceData 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
-
initPermissions
DELETE permission is granted if the logged in user is the owner of this device.- 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
-
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
-
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
-
getUser
Get the user that owns this device.- Returns:
- The
User
item - Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permissionBaseException
- If there is another error
-
getClient
Get the client application the user was using with this device.- Returns:
- A
Client
item, or null if not known - Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.READ
permissionBaseException
- If there is another error
-
getLastUsed
Get the date and time the user last used this device.- Returns:
- A
Date
object with the date and time
-
getUserAgent
Get the user agent string of this device. -
getLastRemoteId
Get the remote ID of the host the user used for this device the last time. Typically it is the IP-address of the user's computer.- Returns:
- A
String
object with remote ID
-
getLocation
Get the last known location of the device.- Returns:
- A
String
object with location or null if not known
-
getLocationLatitude
Get the last known location latitude of the device.- Returns:
- A
Float
object with latitude or null if not known
-
getLocationLongitude
Get the last known location longitude of the device.- Returns:
- A
Float
object with longitude or null if not known
-
isVerified
public boolean isVerified()Has this device been verified or not? Verification is done by requesting a code via email.- Since:
- 3.17
-
getSessions
Get a query for loading login session from this device.- Since:
- 3.17
-