Package net.sf.basedb.core
Class PluginType
java.lang.Object
net.sf.basedb.core.BasicItem
net.sf.basedb.core.PluginType
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Nameable
,Registered
,Removable
- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum length of the interface name that can be stored in the database.static final int
The maximum length of the jar path name that can be stored in the database.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 PluginType
Get aPluginType
object when you know the ID.static PluginType
getByInterfaceName
(DbControl dc, String interfaceName) Get aPluginType
object when you know the interface name it represents.(package private) PluginTypeData
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 class name of the Java class that implements this plugin.Get the name of the JAR file that contains this plug-in.Get the path to the JAR file that contains the plugin class file.getName()
Get the name of the item.static PluginType
Create a newPluginType
item.Get a query that returns the plugin definitions which implements this type.static ItemQuery<PluginType>
getQuery()
Get a query configured to retrieve plugin types.Get the user that flagged this item for removal.getType()
Get the type of item represented by the object.(package private) void
initPermissions
(int granted, int denied) All users get READ access.boolean
Check if the removed flag is set for this item.void
loadInterfaceInformation
(String jarFile, String interfaceName) void
setDescription
(String description) Set the description for the item.void
setEntryDate
(Date entryDate) Set the date the entry was registered in the database.private void
setInterfaceName
(String interfaceName) The class name cannot be changed.private void
setJarFile
(String jarFile) The jar path cannot be changed.void
Set the name of the item.void
setRemoved
(boolean removed) Set the removed flag for this 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:
-
MAX_INTERFACENAME_LENGTH
public static final int MAX_INTERFACENAME_LENGTHThe maximum length of the interface name that can be stored in the database. Check the length against this value before calling thesetInterfaceName(String)
method to avoid exceptions.- See Also:
-
MAX_JARFILE_LENGTH
public static final int MAX_JARFILE_LENGTHThe maximum length of the jar path name that can be stored in the database.- Since:
- 3.0
- See Also:
-
-
Constructor Details
-
PluginType
PluginType(PluginTypeData data) Creates a plugin type item.- Parameters:
data
- the data
-
-
Method Details
-
getNew
public static PluginType getNew(DbControl dc, String interfaceName, String jarFile) throws BaseException Create a newPluginType
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.interfaceName
- The name of an interface that a plugin must implement to be of this typejarFile
- Optional file name of the JAR file which contains the plugin class. The JAR file must be located in the plugins.dir directory. If not specified the plugin must be in the classpath- Returns:
- The new
PluginDefinition
item - Throws:
BaseException
- If there is an error
-
getById
public static PluginType getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aPluginType
object 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
PluginType
item - Throws:
ItemNotFoundException
- If an item with the specified id is not foundPermissionDeniedException
- If the logged in user doesn't have read permission to the itemBaseException
- If there is another error
-
getByInterfaceName
public static PluginType getByInterfaceName(DbControl dc, String interfaceName) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aPluginType
object when you know the interface name it represents.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.interfaceName
- The interface name of the plugin type- Returns:
- The
PluginType
item - Throws:
ItemNotFoundException
- If an item with the specified interface name is not foundPermissionDeniedException
- If the logged in user doesn't have read permission to the itemBaseException
- If there is another error
-
getQuery
Get a query configured to retrieve plugin types.- Returns:
- An
ItemQuery
object
-
getData
PluginTypeData 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
-
initPermissions
All users get READ access.- 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
-
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
-
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
-
getInterfaceName
Get the class name of the Java class that implements this plugin. The specified class must implement thePlugin
interface.- Returns:
- The class name for this plugin
-
setInterfaceName
The class name cannot be changed. Used internally only.- Throws:
InvalidDataException
-
getJarFile
Get the name of the JAR file that contains this plug-in. If this value is null, the plug-in must be on the classpath (eg. in WEB-INF/lib).- Since:
- 3.0
-
getJarPath
Get the path to the JAR file that contains the plugin class file. If this value is null, the plugin must be on the classpath. -
setJarFile
The jar path cannot be changed. Used internally only.- Throws:
InvalidDataException
-
loadInterfaceInformation
public void loadInterfaceInformation(String jarFile, String interfaceName) throws InvalidDataException, BaseException - Parameters:
jarFile
- File name of the jar file containing the plug-in. The JAR file must be located in the directory spercified by 'plugins.dir' setting in base.config. Null is allowed if plugin is located in the classpath (eg. WEB-INF/lib).interfaceName
- The name of an interface that a plugin must implement to be of this type.- Throws:
InvalidDataException
- If the found class not really is an interface, or if the found interface doesn't extend fromPlugin
BaseException
- If there is some other error.
-
getPlugins
Get a query that returns the plugin definitions which implements this type.- See Also:
-