Package net.sf.basedb.core
Class Client
- java.lang.Object
-
- net.sf.basedb.core.BasicItem
-
- net.sf.basedb.core.OwnedItem
-
- net.sf.basedb.core.SharedItem
-
- net.sf.basedb.core.CommonItem
-
- net.sf.basedb.core.Client
-
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Nameable
,Ownable
,Registered
,Removable
,Shareable
public class Client extends CommonItem implements Registered
This class represents a registered client application. Registering a client application has some benefits:- It is possible to create and store settings
- It is possible to set permissions for the usage of the application
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
ClientDefaultSetting
,UserClientSetting
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_EXTERNAL_ID_LENGTH
The maximum length of the external id variable that can be stored in the database.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
-
-
Constructor Summary
Constructors Constructor Description Client(ClientData clientData)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Client
getByExternalId(DbControl dc, String externalId)
Get aClient
item when you know the external ID.static Client
getById(DbControl dc, int id)
Get aClient
item when you know the ID.(package private) ClientData
getData()
Get theBasicData
object that holds all data for this item.ClientDefaultSetting
getDefaultSetting(String name)
Get the default setting with the specified name.ItemQuery<ClientDefaultSetting>
getDefaultSettings()
Get a query that will return all default settings for this client.Date
getEntryDate()
Get the date that the item was registered in the database.String
getExternalId()
Get the external id for thisClient
item.ItemQuery<Help>
getHelp()
Get a query that will return all help texts for this client.Help
getHelpByExternalId(DbControl dc, String externalId, boolean create)
Get aHelp
item when you know the external ID.static Client
getNew(DbControl dc, String externalId)
Create a newClient
item.static ItemQuery<Client>
getQuery()
Get a new query object for this class.boolean
getSupportsDeviceVerification()
This flag indicates if the registered client application supports device verification or not.Item
getType()
Get the type of item represented by the object.ClientDefaultSetting
newDefaultSetting(String name, String value)
Create a new default setting for this client.Help
newHelp(String externalId)
Create a new help text for this client.void
setEntryDate(Date entryDate)
Set the date the entry was registered in the database.void
setExternalId(String externalId)
Set the external id for thisClient
item.void
setSupportsDeviceVerification(boolean supportsDeviceVerification)
-
Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, getRemovedBy, isRemoved, setDescription, setName, setRemoved
-
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey
-
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership
-
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, 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
-
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
-
-
-
-
Field Detail
-
TYPE
public static final Item TYPE
The type of item represented by this class.- See Also:
Item.CLIENT
,getType()
-
MAX_EXTERNAL_ID_LENGTH
public static final int MAX_EXTERNAL_ID_LENGTH
The maximum length of the external id variable that can be stored in the database. Check the length against this value before calling thesetExternalId(String)
method to avoid exceptions.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Client
Client(ClientData clientData)
-
-
Method Detail
-
getNew
public static Client getNew(DbControl dc, String externalId) throws BaseException
Create a newClient
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessexternalId
- The external id of the new item- Returns:
- The new
Role
item - Throws:
BaseException
- If there is an error
-
getById
public static Client getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
Get aClient
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
Client
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
-
getByExternalId
public static Client getByExternalId(DbControl dc, String externalId) throws ItemNotFoundException, PermissionDeniedException, BaseException
Get aClient
item when you know the external ID.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.externalId
- The external id of the item to load- Returns:
- The
Client
item - Throws:
ItemNotFoundException
- If an item with the specified ID is not foundPermissionDeniedException
- If the logged in user doesn't haveREAD
permission for the itemBaseException
- If there is another error
-
getQuery
public static ItemQuery<Client> getQuery()
Get a new query object for this class.- Returns:
- An
ItemQuery
object
-
getData
ClientData getData()
Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.- Overrides:
getData
in classCommonItem
-
getType
public Item getType()
Description copied from interface:Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in theItem
enumeration.- Specified by:
getType
in interfaceIdentifiable
- Returns:
- A value indicating the type of item
-
getEntryDate
public Date 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
public void setEntryDate(Date entryDate)
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
-
getExternalId
public String getExternalId()
Get the external id for thisClient
item.- Returns:
- A string with the external id of this item
-
setExternalId
public void setExternalId(String externalId) throws PermissionDeniedException, InvalidDataException
Set the external id for thisClient
item. The value cannot be null and must not be longer than the value specified by theMAX_EXTERNAL_ID_LENGTH
constant.- Parameters:
externalId
- The new external id for this item- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is null or longer thanMAX_EXTERNAL_ID_LENGTH
-
getSupportsDeviceVerification
public boolean getSupportsDeviceVerification()
This flag indicates if the registered client application supports device verification or not.- Returns:
- TRUE if it is supported, FALSE if not
- Since:
- 3.12
-
setSupportsDeviceVerification
public void setSupportsDeviceVerification(boolean supportsDeviceVerification)
-
newDefaultSetting
public ClientDefaultSetting newDefaultSetting(String name, String value) throws PermissionDeniedException, InvalidDataException, BaseException
Create a new default setting for this client.- Parameters:
name
- The name of the settingvalue
- The value of the setting- Returns:
- The new
ClientDefaultSetting
object - Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the name or value is null or longer than what is allowedBaseException
- If there is another error
-
getDefaultSetting
public ClientDefaultSetting getDefaultSetting(String name) throws ItemNotFoundException, InvalidDataException, BaseException
Get the default setting with the specified name.- Parameters:
name
- The name of the setting- Throws:
ItemNotFoundException
- If a setting with the specified name isn't foundInvalidDataException
- If name is nullBaseException
- If there is another error
-
getDefaultSettings
public ItemQuery<ClientDefaultSetting> getDefaultSettings() throws BaseException
Get a query that will return all default settings for this client.- Returns:
- An
ItemQuery
object - Throws:
BaseException
- If getting the query fails.
-
newHelp
public Help newHelp(String externalId) throws PermissionDeniedException, InvalidDataException, BaseException
Create a new help text for this client.- Parameters:
externalId
- The external ID of the help text- Returns:
- The new
Help
object - Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the exernal ID is null or longer than what is allowedBaseException
- If there is another error
-
getHelp
public ItemQuery<Help> getHelp()
Get a query that will return all help texts for this client.- Returns:
- An
ItemQuery
object
-
getHelpByExternalId
public Help getHelpByExternalId(DbControl dc, String externalId, boolean create) throws ItemNotFoundException, PermissionDeniedException, BaseException
Get aHelp
item when you know the external ID.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.externalId
- The external id of the item to loadcreate
- TRUE if a new Help should be created if one doesn't exists, FALSE to throw an exception.- Returns:
- The
Help
item - Throws:
ItemNotFoundException
- If an item with the specified ID is not found.PermissionDeniedException
- If the logged in user doesn't haveREAD
permission for the item.BaseException
- If there is another error.
-
-