Package net.sf.basedb.core
Class PluginDefinition
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.PluginDefinition
- All Implemented Interfaces:
AccessControlled
,Annotatable
,AnnotatableProxy
,Identifiable
,Nameable
,Ownable
,Registered
,Removable
,Shareable
A plugin definition represents the executable plugin. Ie.
the class name of a class implementing the
Plugin
interface.- Version:
- 2.0
- Author:
- Nicklas, Samuel
- Last modified
- $Date$
-
Field Summary
Modifier and TypeFieldDescriptionprivate PluginInfo
static final int
The maximum length of the class name that can be stored in the database.static final int
The maximum length of the contact information that can be stored in the database.static final int
The maximum length of the copyright notice that can be stored in the database.static final int
The maximum length of the email address 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 int
The maximum length of the name that can be stored in the database.static final int
The maximum length of the url that can be stored in the database.static final int
The maximum length of the version 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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkInstallation
(DbControl dc, Collection<PluginInfo> plugins) Check the installation status of the given list of plug-ins.static Map<Plugin.MainType,
Integer> countPlugins
(DbControl dc, GuiContext gc) Count the number of plugins that can be used in a given context.boolean
If immediate execution of jobs are allowed or if they always must go through the job queue.Get all parents objects which are annotatable and the logged in user has read permission to.Get a message explaining what the proxy does with the annotations.Get the annotation set containing the annotations for this item.Get the annotation types that can be used by this configuration.static PluginDefinition
getByClassName
(DbControl dc, String className) Get aPluginDefinition
item when you know the class name.static PluginDefinition
Get aPluginDefinition
item when you know the ID.Get the class name of the Java class that implements this plugin.Get contact information for the plugin.Get a copyright notice for the plugin.(package private) PluginDefinitionData
getData()
Get theBasicData
object that holds all data for this item.Get the permissions that have been denied to this plugin.getEmail()
Get an email address that can be used to get more information about the plugin.Get the date that the item was registered in the database.getGranted
(RoleKey roleKey) Get the permissions that have been granted to this plugin.Get theItem
types where it makes sense to use this plugin for a client application.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.Get the type of plugin.Get the maximum amount of memory the plugins is allowed to use.static PluginDefinition
Create a newPluginDefinition
item.Get a query that returns the configurations for this plugin definition.Get a query that returns the plugin types for this plugin definition.A protcol used in the creation of an item that is used to attach annotations for the protocol parameters.static ItemQuery<PluginDefinition>
getQuery()
Get a query that returns plugin definitions.static ItemQuery<PluginDefinition>
getQuery
(GuiContext gc, String interfaceName) Get a query that returns all plugins related to a specified GUI context and implementing a certain interface.getType()
Get the type of item represented by the object.getUrl()
Get a URL with more information about the plugin.boolean
If this plug-in can be executed by the internal job queue or not.boolean
Check if this plugin should execute with or without permissions.Get all:PluginConfiguration
:s created from this pluginJob
:s using this pluginGet the version of the plugin.static PluginDefinition
installOrUpdate
(DbControl dc, PluginInfo info, String jarFile, ItemKey shareToEveryone) Install or update the plug-in definition with information from the info object.boolean
Check if this item has an annotation set.boolean
Checks if this plugin is disabled or not.boolean
isInContext
(GuiContext context) Check if it makes sense to use this plugin in the context of the specified item.boolean
Check if the plugin is interactive or not.boolean
Check if the removed flag is set for this item.boolean
If this plugin is trusted or not.boolean
isUsed()
Check if aPluginConfiguration
is using this definition.void
loadPluginInformation
(String jarFile, String className, boolean useRequstedPermissions) Load a plugin and copy information to the internal data structure.Get an unitialized instance of the plugin.<P extends Plugin>
PnewInstance
(Class<P> clazz) Get an unitialized instance of the plugin implementation.<P extends Plugin>
PnewInstance
(Class<P> clazz, SessionControl sc, PluginConfiguration configuration, Job job) Get an initialized instance of the plugin implementation.private Plugin
newInstance
(String jarPath, String className, ClassLoader alternateClassLoader, boolean unloadBefore) Create a new object instance of the given class.Create a newPluginConfiguration
for this plugin.(package private) void
This method is called on all items directly after Hibernate has inserted it into the database.void
Remove all annotations from this item, by deleting the annotation set.boolean
Check if the plugin requires a configuration to execute a job.void
Update the plug-in information with the information in the about object.void
setAllowImmediateExecution
(boolean allow) private void
setClassName
(String className) The class name cannot be changed.private void
setContact
(String contact) Set contact information for this plug-in.private void
setCopyright
(String copyright) Update copyright information about this plug-in.void
setDisabled
(boolean disabled) Disabled or enable this plugin.private void
Set the email address that can be used to contact the developer of the plug-in.void
setEntryDate
(Date entryDate) Set the date the entry was registered in the database.private void
setGuiContexts
(Set<GuiContext> pluginContexts) Set the contexts where this plugin can be used.private void
setInteractive
(boolean interactive) private void
setJarFile
(String jarFile) The jar path cannot be changed.private void
setMainType
(Plugin.MainType type) The type cannot be changed.void
setMaxMemory
(Long maxMemory) Set the maximum amount of memory the plugin is allowed to use.void
setPermissions
(RoleKey roleKey, Set<Permission> granted, Set<Permission> denied) Sets the permissions for this plugin.void
setRemoved
(boolean removed) Set the removed flag for this item.private void
setRequiresConfiguration
(boolean requiresConfiguration) private void
setSupportsConfigurations
(boolean supportsConfigurations) void
setTrusted
(boolean trusted) Set if this plugin should be trusted or not.void
Set the URL to a web page with more information about the plug-in.void
setUseInternalJobQueue
(boolean use) Set if the plug-in can use the internal job queue or not.void
setUsePermissions
(boolean usePermissions) private void
setVersionString
(String version) Update version information for this plug-in.boolean
Check if a plugin implements the interface specified by the plugin type.boolean
supports
(PluginType pluginType) Check if a plugin implements the interface specified by the plugin type.boolean
Check if the plugin supports configurations or not when executing a job.Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, getRemovedBy, setDescription, setName
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, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, 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 Details
-
TYPE
The type of item represented by this class.- See Also:
-
MAX_CLASSNAME_LENGTH
public static final int MAX_CLASSNAME_LENGTHThe maximum length of the class name that can be stored in the database. Check the length against this value before calling thesetClassName
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:
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHThe maximum length of the name that can be stored in the database.- See Also:
-
MAX_VERSION_LENGTH
public static final int MAX_VERSION_LENGTHThe maximum length of the version that can be stored in the database.- See Also:
-
MAX_COPYRIGHT_LENGTH
public static final int MAX_COPYRIGHT_LENGTHThe maximum length of the copyright notice that can be stored in the database.- See Also:
-
MAX_CONTACT_LENGTH
public static final int MAX_CONTACT_LENGTHThe maximum length of the contact information that can be stored in the database.- See Also:
-
MAX_EMAIL_LENGTH
public static final int MAX_EMAIL_LENGTHThe maximum length of the email address that can be stored in the database.- See Also:
-
MAX_URL_LENGTH
public static final int MAX_URL_LENGTHThe maximum length of the url that can be stored in the database.- See Also:
-
info
-
-
Constructor Details
-
PluginDefinition
PluginDefinition(PluginDefinitionData pd)
-
-
Method Details
-
getNew
public static PluginDefinition getNew(DbControl dc, String className, String jarFile, boolean useRequestedPermissions) throws BaseException Create a newPluginDefinition
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.className
- The name of the class that implements the plugin interfacejarFile
- 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 classpathuseRequestedPermissions
- If the permissions that are returned by thePlugin.getPermissions()
method should be used or not. If not used the plugin uses the permissions from the logged in user- Returns:
- The new
PluginDefinition
item - Throws:
BaseException
- If there is an error
-
getById
public static PluginDefinition getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aPluginDefinition
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
PluginDefinition
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.
-
getByClassName
public static PluginDefinition getByClassName(DbControl dc, String className) throws ItemNotFoundException, PermissionDeniedException, BaseException Get aPluginDefinition
item when you know the class name.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.className
- The class name of the item to load.- Returns:
- The
PluginDefinition
item. - Throws:
ItemNotFoundException
- If an item with the specified class name is not found.PermissionDeniedException
- If the logged in user doesn't haveREAD
permission for the item.BaseException
- If there is another error.
-
getQuery
Get a query that returns plugin definitions.- Returns:
- An
ItemQuery
object
-
getQuery
Get a query that returns all plugins related to a specified GUI context and implementing a certain interface. Ie. TheisInContext(GuiContext)
returns true for the specified item, andsupports(PluginType)
returns true for the specified interface.- Parameters:
gc
- The context the plugin should be related to, or null if this parameter is irrelevantinterfaceName
- The complete name of the interface that the plugin must implement, or null if this parameter is irrelevant
-
countPlugins
public static Map<Plugin.MainType,Integer> countPlugins(DbControl dc, GuiContext gc) throws BaseException Count the number of plugins that can be used in a given context.- Parameters:
dc
- An open DbControl objectgc
- The context to count plugins for- Returns:
- A map with the main type as the key and the number of plugins as the value
- Throws:
BaseException
- If the plugins could not be counted.
-
checkInstallation
Check the installation status of the given list of plug-ins.- Parameters:
dc
- An optional DbControl (if null a new internal connection will be used)plugins
- An array with plug-in information objects- Since:
- 3.0
-
installOrUpdate
public static PluginDefinition installOrUpdate(DbControl dc, PluginInfo info, String jarFile, ItemKey shareToEveryone) Install or update the plug-in definition with information from the info object. Existing plug-ins will be updated and the disabled flag is cleared (unless it is deprecated). New plug-ins are configured with additional options from the info object:- max-memory: Maximum memory in bytes when the plug-in is executed as an external process by a job agent
- immediate-execution: If the plug-in is allowed to bypass the job queue.
- everyone-use: If the plug-in should be shared with USE permission to everyone.
- deprecated: Disable the plug-in if it is already installed, do not install if it is missing
- Returns:
- The plugin definition or null if no plug-in was installed
- Since:
- 3.0
-
getData
PluginDefinitionData getData()Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.- Overrides:
getData
in classCommonItem
-
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
-
isRemoved
public boolean isRemoved()Description copied from interface:Removable
Check if the removed flag is set for this item.- Specified by:
isRemoved
in interfaceRemovable
- Overrides:
isRemoved
in classCommonItem
- Returns:
- TRUE if the item is flagged as removed, FALSE otherwise
-
setRemoved
Description copied from interface:Removable
Set the removed flag for this item.- Specified by:
setRemoved
in interfaceRemovable
- Overrides:
setRemoved
in classCommonItem
- 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
-
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
-
isUsed
Check if aPluginConfiguration
is using this definition.- Overrides:
isUsed
in classBasicItem
- Returns:
- TRUE if this item is used, FALSE otherwise
- Throws:
BaseException
- If not able to tell if item is used or not.- See Also:
-
onAfterInsert
Description copied from class:BasicItem
This method is called on all items directly after Hibernate has inserted it into the database. This method can be used in place of theBasicItem.onBeforeCommit(Transactional.Action)
in case the id is needed. The id has not been generated when theonBeforeCommit
is called.- Overrides:
onAfterInsert
in classBasicItem
- Throws:
BaseException
- If there is an error- See Also:
-
getUsingItems
Get all:PluginConfiguration
:s created from this pluginJob
:s using this plugin
- Overrides:
getUsingItems
in classBasicItem
- Returns:
- A set containing proxies for the items, or an empty set if no items are using this item
- Since:
- 2.2
- See Also:
-
getAnnotationSet
Description copied from interface:Annotatable
Get the annotation set containing the annotations for this item. If the item doesn't have any annotations a new annotation set is created and automatically saved to the database whenDbControl.commit()
is called. To check if an item has annotations without creating a new annotation set use theAnnotatable.isAnnotated()
method.- Specified by:
getAnnotationSet
in interfaceAnnotatable
- Returns:
- An
AnnotationSet
- Throws:
PermissionDeniedException
- If the logged in user doesn't have enough permissionsBaseException
- If there is another error- Since:
- 2.5
-
isAnnotated
public boolean isAnnotated()Description copied from interface:Annotatable
Check if this item has an annotation set. The annotation set may be empty.- Specified by:
isAnnotated
in interfaceAnnotatable
- Returns:
- TRUE if an annotation set exists, FALSE otherwise
- Since:
- 2.5
-
removeAnnotations
Description copied from interface:Annotatable
Remove all annotations from this item, by deleting the annotation set.- Specified by:
removeAnnotations
in interfaceAnnotatable
- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionBaseException
- If there is another error- Since:
- 2.5
-
getProtocol
Description copied from interface:Annotatable
A protcol used in the creation of an item that is used to attach annotations for the protocol parameters.- Specified by:
getProtocol
in interfaceAnnotatable
- Returns:
- Always null
- Since:
- 2.5
-
getAnnotatableParents
Description copied from interface:Annotatable
Get all parents objects which are annotatable and the logged in user has read permission to. If the item doesn't have any annotatable parents, it may return null or an empty set. The method should only return the immediate parent(s), not parents to parents, etc. As of BASE 3.1 this method may also return child items if the child item is aSubtypable
item that has a subtype with theItemSubtype.getPushAnnotations()
flag set.- Specified by:
getAnnotatableParents
in interfaceAnnotatable
- Returns:
- Always null
- Since:
- 2.5
-
getAnnotationTypes
Get the annotation types that can be used by this configuration. This method requires that the plug-in implements theAnnotationSetterPlugin
interface.- Specified by:
getAnnotationTypes
in interfaceAnnotatableProxy
- Returns:
- A query or null if this plug-in doesn't use annotations
- Since:
- 2.5
-
getAnnotationMessage
Get a message explaining what the proxy does with the annotations.- Specified by:
getAnnotationMessage
in interfaceAnnotatableProxy
- Returns:
- A message or null
- Since:
- 2.5
-
getClassName
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
-
setClassName
The class name cannot be changed. Used internally only.- Throws:
InvalidDataException
-
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
-
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
-
getVersionString
Get the version of the plugin.- Returns:
- A string with the version of the plugin, or null if not known
-
setVersionString
Update version information for this plug-in.- Throws:
InvalidDataException
- If the version is too long- Since:
- 3.0
-
getCopyright
Get a copyright notice for the plugin.- Returns:
- A string with a copyright notice, or null if not known
-
setCopyright
Update copyright information about this plug-in.- Throws:
InvalidDataException
- If the copyright is too long- Since:
- 3.0
-
getContact
Get contact information for the plugin.- Returns:
- A string with contact information, or null if not known
-
setContact
Set contact information for this plug-in.- Throws:
InvalidDataException
- If the contact is too long- Since:
- 3.0
-
getEmail
Get an email address that can be used to get more information about the plugin.- Returns:
- A string with the email address, or null if not known
-
setEmail
Set the email address that can be used to contact the developer of the plug-in.- Throws:
InvalidDataException
- If the email is too long- Since:
- 3.0
-
getUrl
Get a URL with more information about the plugin.- Returns:
- A string containing the URL, or null if not known
-
setUrl
Set the URL to a web page with more information about the plug-in.- Throws:
InvalidDataException
- If the url is too long- Since:
- 3.0
-
setAbout
Update the plug-in information with the information in the about object.- Parameters:
about
- An About objectforce
- If TRUE all values are updated, if FALSE only non-null values- Since:
- 3.0
-
isDisabled
public boolean isDisabled()Checks if this plugin is disabled or not. A disabled plugin can't be used.- Since:
- 3.0
-
setDisabled
public void setDisabled(boolean disabled) Disabled or enable this plugin.- Since:
- 3.0
-
isTrusted
public boolean isTrusted()If this plugin is trusted or not. A trusted plugin is executed without any restrictions, an untrusted have restrictions similar to an applet in a web browser. NOTE!!! CURRENTLY NOT IMPLEMENTED.- Returns:
- TRUE if the plugin is trusted, FALSE otherwise
-
setTrusted
public void setTrusted(boolean trusted) Set if this plugin should be trusted or not. NOTE!!! CURRENTLY NOT IMPLEMENTED.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission- See Also:
-
getMaxMemory
Get the maximum amount of memory the plugins is allowed to use. The returned value is only a guideline to the job agent which may choose to use a lower setting due to the servers limitations. A null value means the job agent is free to choose any amount. Usually, it will select the default value as specified by theagent.maxMemory
setting in it's configuration file.- Returns:
- The maximum amount of memory to use, or null
-
setMaxMemory
Set the maximum amount of memory the plugin is allowed to use.- Parameters:
maxMemory
- The maximum amount, or null if the job agent should decide- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permission- See Also:
-
getMainType
Get the type of plugin.- Returns:
- A type code that is defined in the enum
Plugin.MainType
.
-
setMainType
The type cannot be changed. Used internally only.- Throws:
InvalidDataException
- If the type is null- Developer info
- This value is initialised upon installation to: plugin.getMainType()
See:
loadPluginInformation(String, String, boolean)
-
isInteractive
public boolean isInteractive()Check if the plugin is interactive or not. An interactive plugin implements theInteractivePlugin
interface and can be dynamically configured by telling the client application what configuration parameters it needs. -
setInteractive
private void setInteractive(boolean interactive) -
supportsConfigurations
public boolean supportsConfigurations()Check if the plugin supports configurations or not when executing a job. Note! A false return value doesn't mean that the core stops anyone from creating aPluginConfiguration
for this plugin. The return value should be used by client applications for better GUI. -
setSupportsConfigurations
private void setSupportsConfigurations(boolean supportsConfigurations) -
requiresConfiguration
public boolean requiresConfiguration()Check if the plugin requires a configuration to execute a job. Note! The core will check the return value of this method when creating a job and throw anInvalidDataException
if a configuration is required but isn't supplied. -
setRequiresConfiguration
private void setRequiresConfiguration(boolean requiresConfiguration) -
getUsePermissions
public boolean getUsePermissions()Check if this plugin should execute with or without permissions. Note! The plugin will use the permissions of the logged in user if this is set to FALSE which could lead to this plugin not will be able to save/create files if the user doesn't have that permission. To be sure that the plugin will execute under certain permissions this should be set to TRUE.- See Also:
-
setUsePermissions
public void setUsePermissions(boolean usePermissions) -
getAllowImmediateExecution
public boolean getAllowImmediateExecution()If immediate execution of jobs are allowed or if they always must go through the job queue. Immediate execution is needed by export plugins that want to use the immediate download feature.- Returns:
- TRUE if immediate execition is allowed, FALSE it jobs must be added to the job queue
- Since:
- 2.2
- See Also:
-
setAllowImmediateExecution
public void setAllowImmediateExecution(boolean allow) -
getUseInternalJobQueue
public boolean getUseInternalJobQueue()If this plug-in can be executed by the internal job queue or not. If not, the plug-in must be configured to be executed by a job agent. NOTE! The plug-in can always be excuted by job agents, they ignore this value.- Returns:
- TRUE if the internal job queue is used, FALSE if not
- Since:
- 2.5
-
setUseInternalJobQueue
public void setUseInternalJobQueue(boolean use) Set if the plug-in can use the internal job queue or not.- Parameters:
use
- TRUE to use the internal job queue, FALSE to only use job agents- Since:
- 2.5
-
isInContext
Check if it makes sense to use this plugin in the context of the specified item. For example, a plugin that imports reporters would return true if passedItem.REPORTER
.- Parameters:
context
- TheGuiContext
type- Returns:
- TRUE if the plugin handles the item, FALSE otherwise
-
getGuiContexts
Get theItem
types where it makes sense to use this plugin for a client application. For example, a plugin that imports reporters would return a set containingItem.REPORTER
.- Returns:
- A
Set
ofItem
:s or an empty set if the plugin is not concerned about items
-
setGuiContexts
Set the contexts where this plugin can be used. -
newPluginConfiguration
Create a newPluginConfiguration
for this plugin.- Returns:
- The new
PluginConfiguration
item - Throws:
PermissionDeniedException
- If the logged in user doesn't have use permission for this plugin definitionBaseException
- If there is another error
-
getPluginConfigurations
Get a query that returns the configurations for this plugin definition.- Returns:
- An
ItemQuery
object
-
getPluginTypes
Get a query that returns the plugin types for this plugin definition.- Returns:
- An
ItemQuery
object
-
supports
Check if a plugin implements the interface specified by the plugin type.- Parameters:
pluginType
- The pluginType to check- Returns:
- TRUE if the plugin implements the specified interface, FALSE otherwise
-
supports
Check if a plugin implements the interface specified by the plugin type.- Parameters:
interfaceName
- The pluginType to check- Returns:
- TRUE if the plugin implements the specified interface, FALSE otherwise
-
newInstance
Get an unitialized instance of the plugin.- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.USE
permission to the items.BaseException
- If there is a problem creating an instance.
-
newInstance
public <P extends Plugin> P newInstance(Class<P> clazz) throws PermissionDeniedException, BaseException Get an unitialized instance of the plugin implementation.- Type Parameters:
P
- The kind of returned object that extends Plugin.- Parameters:
clazz
- The class of the plugin which must be a subclass ofPlugin
- Returns:
- An uninitialised plugin instance
- Throws:
PermissionDeniedException
BaseException
-
newInstance
public <P extends Plugin> P newInstance(Class<P> clazz, SessionControl sc, PluginConfiguration configuration, Job job) throws PermissionDeniedException, BaseException Get an initialized instance of the plugin implementation.- Type Parameters:
P
- The kind of returned object that extends Plugin.- Parameters:
clazz
- The class of the plugin which must be a subclass ofPlugin
sc
- The session control to initialise the plugin withconfiguration
- The configuration parameters to initialise the plugin with, or null if no configuration existsjob
- The job parameters to intialise the plugin with, or null if no job exists- Returns:
- An initialised plugin instance
- Throws:
PermissionDeniedException
BaseException
-
newInstance
private Plugin newInstance(String jarPath, String className, ClassLoader alternateClassLoader, boolean unloadBefore) throws BaseException Create a new object instance of the given class.- Parameters:
jarPath
- The full path to the JAR fileclassName
- The class to createunloadBefore
- If the class definition should be unloaded before the new instance is created, unloading may not work if a client program holds a reference to an instance of the class- Returns:
- The created instance
- Throws:
BaseException
-
setPermissions
public void setPermissions(RoleKey roleKey, Set<Permission> granted, Set<Permission> denied) throws PermissionDeniedException, InvalidUseOfNullException Sets the permissions for this plugin. It is not possible to give the plugin more permissions than the logged in user have. Permissions that are neither granted nor denied are checked against the permissions for the user that is running the plugin.NOTE! The granted permissions are always granted, regardless of the logged in user's permissions. The denied permissions are always denied regardless of the logged in user's permissions. This applies even to the root user account.
If the granted permissions is null or empty and the denied permissions is null or contains the same set of permissions as defined by the item type the permissions are removed from the database, which means that only those permissions which differs from the defaults are stored in the database.
- Parameters:
roleKey
- The rolekey for this plugingranted
- The permission to grant to the plugindenied
- The permissions to deny the plugin- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.SET_PERMISSION
for thisPluginDefinition
or trying to grant the plugin more permission then the logged in userInvalidUseOfNullException
- If the rolekey is null
-
getGranted
Get the permissions that have been granted to this plugin.- Parameters:
roleKey
- The role key to get the permission for- Returns:
- A set containing the granted permissions for this plugin, the set is empty if no permissions has been granted
- Throws:
InvalidUseOfNullException
- If the role key is null
-
getDenied
Get the permissions that have been denied to this plugin.- Parameters:
roleKey
- The role key to get the permission for- Returns:
- A set containing the denied permissions for this plugin, the set is empty if no permissions has been denied
- Throws:
InvalidUseOfNullException
- If the role key is null
-
loadPluginInformation
public void loadPluginInformation(String jarFile, String className, boolean useRequstedPermissions) throws PermissionDeniedException, InvalidDataException, BaseException Load a plugin and copy information to the internal data structure.- 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).className
- Full class name of the plugin's main class.useRequstedPermissions
- TRUE if plugin should use the permissions it requests.- Throws:
PermissionDeniedException
- If logged in user doesn't have write permission to this item.InvalidDataException
- If any of the arguments is malformed or if setting the plugin's properties fails.BaseException
- If something else fails.
-