2.17.2: 2011-06-17

net.sf.basedb.core
Class Client

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.OwnedItem<D>
          extended by net.sf.basedb.core.SharedItem<D>
              extended by net.sf.basedb.core.CommonItem<ClientData>
                  extended by net.sf.basedb.core.Client
All Implemented Interfaces:
AccessControlled, Identifiable, Nameable, Ownable, Registered, Removable, Shareable

public class Client
extends CommonItem<ClientData>
implements Registered

This class represents a registered client application. Registering a client application has some benefits:

Version:
2.0
Author:
Nicklas
See Also:
ClientDefaultSetting, UserClientSetting

Field Summary
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
Client(ClientData clientData)
           
 
Method Summary
static Client getByExternalId(DbControl dc, String externalId)
          Get a Client item when you know the external ID.
static Client getById(DbControl dc, int id)
          Get a Client item when you know the ID.
 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 this Client 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 a Help item when you know the external ID.
static Client getNew(DbControl dc, String externalId)
          Create a new Client item.
static ItemQuery<Client> getQuery()
          Get a new query object for this class.
 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 setExternalId(String externalId)
          Set the external id for this Client item.
 
Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, isRemoved, setDescription, setName, setRemoved, toTransferable
 
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey, toTransferable
 
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership, toTransferable
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, 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
 
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 the setExternalId(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 new Client item.

Parameters:
dc - The DbControl which will be used for permission checking and database access
externalId - 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 a Client item when you know the ID.

Parameters:
dc - The DbControl 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 found
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission to the item
BaseException - If there is another error

getByExternalId

public static Client getByExternalId(DbControl dc,
                                     String externalId)
                              throws ItemNotFoundException,
                                     PermissionDeniedException,
                                     BaseException
Get a Client item when you know the external ID.

Parameters:
dc - The DbControl 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 found
PermissionDeniedException - If the logged in user doesn't have READ permission for the item
BaseException - If there is another error

getQuery

public static ItemQuery<Client> getQuery()
Get a new query object for this class.

Returns:
An ItemQuery object

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 the Item enumeration.

Specified by:
getType in interface Identifiable
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 interface Registered
Returns:
A date or null if this is not known

getExternalId

public String getExternalId()
Get the external id for this Client 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 this Client item. The value cannot be null and must not be longer than the value specified by the MAX_EXTERNAL_ID_LENGTH constant.

Parameters:
externalId - The new external id for this item
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the new value is null or longer than MAX_EXTERNAL_ID_LENGTH

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 setting
value - The value of the setting
Returns:
The new ClientDefaultSetting object
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the name or value is null or longer than what is allowed
BaseException - 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 found
InvalidDataException - If name is null
BaseException - 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 permission
InvalidDataException - If the exernal ID is null or longer than what is allowed
BaseException - 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 a Help item when you know the external ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
externalId - The external id of the item to load
create - 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 have READ permission for the item.
BaseException - If there is another error.

2.17.2: 2011-06-17