2.17.2: 2011-06-17

net.sf.basedb.core
Class PluginDefinition

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<PluginDefinitionData>
              extended by net.sf.basedb.core.PluginDefinition
All Implemented Interfaces:
AccessControlled, Annotatable, AnnotatableProxy, Identifiable, Nameable, Ownable, Registered, Removable, Shareable

public class PluginDefinition
extends SharedItem<PluginDefinitionData>
implements Nameable, Removable, AnnotatableProxy, Registered

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
static int MAX_CLASSNAME_LENGTH
          The maximum length of the class name that can be stored in the database.
static int MAX_CONTACT_LENGTH
          The maximum length of the contact information that can be stored in the database.
static int MAX_COPYRIGHT_LENGTH
          The maximum length of the copyright notice that can be stored in the database.
static int MAX_EMAIL_LENGTH
          The maximum length of the email address that can be stored in the database.
static int MAX_JARPATH_LENGTH
          The maximum length of the jar path name that can be stored in the database.
static int MAX_NAME_LENGTH
          The maximum length of the name that can be stored in the database.
static int MAX_URL_LENGTH
          The maximum length of the url that can be stored in the database.
static int MAX_VERSION_LENGTH
          The maximum length of the version 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
 
Constructor Summary
PluginDefinition(PluginDefinitionData pd)
           
 
Method Summary
static String convertToAbsolute(String path)
          Convert a relative plug-in path to an absolute path.
static String convertToRelative(String path)
          Convert a plug-in path to a path relative to the plugins.dir setting in base.config.
static Map<Plugin.MainType,Integer> countPlugins(DbControl dc, GuiContext gc)
          Count the number of plugins that can be used in a given context.
 boolean getAllowImmediateExecution()
          If immediate execution of jobs are allowed or if they always must go through the job queue.
 Set<Annotatable> getAnnotatableParents()
          Get all parents objects which are annotatable and the logged in user has read permission to.
 String getAnnotationMessage()
          Get a message explaining what the proxy does with the annotations.
 AnnotationSet getAnnotationSet()
          Get the annotation set containing the annotations for this item.
 ItemQuery<AnnotationType> getAnnotationTypes()
          Get the annotation types that can be used by this configuration.
static PluginDefinition getByClassName(DbControl dc, String className)
          Get a PluginDefinition item when you know the class name.
static PluginDefinition getById(DbControl dc, int id)
          Get a PluginDefinition item when you know the ID.
 String getClassName()
          Get the class name of the Java class that implements this plugin.
 String getContact()
          Get contact information for the plugin.
 String getCopyright()
          Get a copyright notice for the plugin.
 Set<Permission> getDenied(RoleKey roleKey)
          Get the permissions that have been denied to this plugin.
 String getDescription()
          Get a description of the plugin.
 String getEmail()
          Get an email address that can be used to get more information about the plugin.
 Date getEntryDate()
          Get the date that the item was registered in the database.
 Set<Permission> getGranted(RoleKey roleKey)
          Get the permissions that have been granted to this plugin.
 Set<GuiContext> getGuiContexts()
          Get the Item types where it makes sense to use this plugin for a client application.
 String getJarPath()
          Get the path to the JAR file that contains the plugin class file.
 Plugin.MainType getMainType()
          Get the type of plugin.
 Long getMaxMemory()
          Get the maximum amount of memory the plugins is allowed to use.
 String getName()
          Get the name of the plugin.
static PluginDefinition getNew(DbControl dc, String className, String jarPath, boolean useRequestedPermissions)
          Create a new PluginDefinition item.
 ItemQuery<PluginConfiguration> getPluginConfigurations()
          Get a query that returns the configurations for this plugin definition.
 ItemQuery<PluginType> getPluginTypes()
          Get a query that returns the plugin types for this plugin definition.
 Protocol getProtocol()
          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.
 Item getType()
          Get the type of item represented by the object.
 String getUrl()
          Get a URL with more information about the plugin.
 boolean getUseInternalJobQueue()
          If this plug-in can be executed by the internal job queue or not.
 boolean getUsePermissions()
          Check if this plugin should execute with or without permissions.
 Set<ItemProxy> getUsingItems()
          Get all: PluginConfiguration:s created from this plugin Job:s using this plugin
 String getVersionString()
          Get the version of the plugin.
 boolean isAnnotated()
          Check if this item has an annotation set.
 boolean isInContext(GuiContext context)
          Check if it makes sense to use this plugin in the context of the specified item.
 boolean isInteractive()
          Check if the plugin is interactive or not.
 boolean isRemoved()
          Check if the removed flag is set for this item.
 boolean isTrusted()
          If this plugin is trusted or not.
 boolean isUsed()
          Check if a PluginConfiguration is using this definition.
 void loadPluginInformation(String jarPath, String className, boolean useRequstedPermissions)
          Load a plugin and copy all information, ie. plugin.about(), to the internal data structure.
 Plugin newInstance()
          Get an unitialized instance of the plugin.
<P extends Plugin>
P
newInstance(Class<P> clazz, String jarPath)
          Get an unitialized instance of the plugin implementation.
<P extends Plugin>
P
newInstance(Class<P> clazz, String jarPath, SessionControl sc, PluginConfiguration configuration, Job job)
          Get an initialized instance of the plugin implementation.
(package private)  Plugin newInstance(String jarPath)
           
private  Plugin newInstance(String jarPath, String className, boolean unloadBefore)
          Create a new object instance of the given class.
 PluginConfiguration newPluginConfiguration()
          Create a new PluginConfiguration for this plugin.
 void removeAnnotations()
          Remove all annotations from this item, by deleting the annotation set.
 boolean requiresConfiguration()
          Check if the plugin requires a configuration to execute a job.
 void setAllowImmediateExecution(boolean allow)
           
private  void setClassName(String className)
          The class name cannot be changed.
private  void setContact(String contact)
          The contact information cannot be changed.
private  void setCopyright(String copyright)
          The copyright notice cannot be changed.
 void setDescription(String description)
          The description cannot be changed.
protected  void setDescriptionInternal(String description)
          The description cannot be changed.
private  void setEmail(String email)
          The email address cannot be changed.
private  void setGuiContexts(Set<GuiContext> pluginContexts)
          Set the contexts where this plugin can be used.
private  void setInteractive(boolean interactive)
           
private  void setJarPath(String jarPath)
          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 setName(String name)
          The name cannot be changed.
private  void setNameInternal(String name)
          The name cannot be changed.
 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.
private  void setUrl(String url)
          The URL cannot be changed.
 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)
          The version cannot be changed.
 boolean supports(PluginType pluginType)
          Check if a plugin implements the interface specified by the plugin type.
 boolean supports(String interfaceName)
          Check if a plugin implements the interface specified by the plugin type.
 boolean supportsConfigurations()
          Check if the plugin supports configurations or not when executing a job.
 
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, getVersion, hashCode, hasPermission, isDetached, isInDatabase, 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.PLUGINDEFINITION, getType()

MAX_CLASSNAME_LENGTH

public static final int MAX_CLASSNAME_LENGTH
The maximum length of the class name that can be stored in the database. Check the length against this value before calling the setClassName method to avoid exceptions.

See Also:
Constant Field Values

MAX_JARPATH_LENGTH

public static final int MAX_JARPATH_LENGTH
The maximum length of the jar path name that can be stored in the database.

See Also:
Constant Field Values

MAX_NAME_LENGTH

public static final int MAX_NAME_LENGTH
The maximum length of the name that can be stored in the database.

See Also:
Constant Field Values

MAX_VERSION_LENGTH

public static final int MAX_VERSION_LENGTH
The maximum length of the version that can be stored in the database.

See Also:
Constant Field Values

MAX_COPYRIGHT_LENGTH

public static final int MAX_COPYRIGHT_LENGTH
The maximum length of the copyright notice that can be stored in the database.

See Also:
Constant Field Values

MAX_CONTACT_LENGTH

public static final int MAX_CONTACT_LENGTH
The maximum length of the contact information that can be stored in the database.

See Also:
Constant Field Values

MAX_EMAIL_LENGTH

public static final int MAX_EMAIL_LENGTH
The maximum length of the email address that can be stored in the database.

See Also:
Constant Field Values

MAX_URL_LENGTH

public static final int MAX_URL_LENGTH
The maximum length of the url that can be stored in the database.

See Also:
Constant Field Values
Constructor Detail

PluginDefinition

PluginDefinition(PluginDefinitionData pd)
Method Detail

convertToRelative

public static String convertToRelative(String path)
Convert a plug-in path to a path relative to the plugins.dir setting in base.config. If no plug-in directory has been specified or if the path is null nothing is done. If the given path is a subpath to the plugins.dir path the common path is replaced with %plugins.dir% and all path separator characters are converted to '/'. For example:

Parameters:
path - The absolute path
Returns:
The relative path
Since:
2.6
See Also:
convertToAbsolute(String)

convertToAbsolute

public static String convertToAbsolute(String path)
Convert a relative plug-in path to an absolute path. This is the reverse of the convertToRelative(String) method.

Parameters:
path - The relative path
Returns:
The absolute path
Since:
2.6

getNew

public static PluginDefinition getNew(DbControl dc,
                                      String className,
                                      String jarPath,
                                      boolean useRequestedPermissions)
                               throws BaseException
Create a new PluginDefinition item.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
className - The name of the class that implements the plugin interface
jarPath - Optional path to the jar file which contains the plugin class, if missing the plugin must be in the classpath
useRequestedPermissions - If the permissions that are returned by the Plugin.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 a PluginDefinition 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 PluginDefinition 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.

getByClassName

public static PluginDefinition getByClassName(DbControl dc,
                                              String className)
                                       throws ItemNotFoundException,
                                              PermissionDeniedException,
                                              BaseException
Get a PluginDefinition item when you know the class name.

Parameters:
dc - The DbControl 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 have READ permission for the item.
BaseException - If there is another error.

getQuery

public static ItemQuery<PluginDefinition> getQuery()
Get a query that returns plugin definitions.

Returns:
An ItemQuery object

getQuery

public 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. Ie. The isInContext(GuiContext) returns true for the specified item, and supports(PluginType) returns true for the specified interface.

Parameters:
gc - The context the plugin should be related to, or null if this parameter is irrelevant
interfaceName - 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 object
gc - 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.

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

isRemoved

public boolean isRemoved()
Description copied from interface: Removable
Check if the removed flag is set for this item.

Specified by:
isRemoved in interface Removable
Returns:
TRUE if the item is flagged as removed, FALSE otherwise

setRemoved

public void setRemoved(boolean removed)
                throws PermissionDeniedException
Description copied from interface: Removable
Set the removed flag for this item.

Specified by:
setRemoved in interface Removable
Parameters:
removed - TRUE if the item should be flagged as removed, FALSE otherwise
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.DELETE permission for setting the flag to TRUE or Permission.WRITE permission for setting the flag to FALSE

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

isUsed

public boolean isUsed()
               throws BaseException
Check if a PluginConfiguration is using this definition.

Overrides:
isUsed in class BasicItem<PluginDefinitionData>
Returns:
TRUE if this item is used, FALSE otherwise
Throws:
BaseException - If not able to tell if item is used or not.
See Also:
BasicItem.getUsingItems()

getUsingItems

public Set<ItemProxy> getUsingItems()
Get all:

getAnnotationSet

public AnnotationSet getAnnotationSet()
                               throws PermissionDeniedException,
                                      BaseException
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 when DbControl.commit() is called. To check if an item has annotations without creating a new annotation set use the Annotatable.isAnnotated() method.

Specified by:
getAnnotationSet in interface Annotatable
Returns:
An AnnotationSet
Throws:
PermissionDeniedException - If the logged in user doesn't have enough permissions
BaseException - 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 interface Annotatable
Returns:
TRUE if an annotation set exists, FALSE otherwise
Since:
2.5

removeAnnotations

public void removeAnnotations()
                       throws PermissionDeniedException,
                              BaseException
Description copied from interface: Annotatable
Remove all annotations from this item, by deleting the annotation set.

Specified by:
removeAnnotations in interface Annotatable
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
BaseException - If there is another error
Since:
2.5

getProtocol

public Protocol 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 interface Annotatable
Returns:
Always null
Since:
2.5

getAnnotatableParents

public Set<Annotatable> 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.

Specified by:
getAnnotatableParents in interface Annotatable
Returns:
Always null
Since:
2.5

getAnnotationTypes

public ItemQuery<AnnotationType> getAnnotationTypes()
Get the annotation types that can be used by this configuration. This method requires that the plug-in implements the AnnotationSetterPlugin interface.

Specified by:
getAnnotationTypes in interface AnnotatableProxy
Returns:
A query or null if this plug-in doesn't use annotations
Since:
2.5

getAnnotationMessage

public String getAnnotationMessage()
Get a message explaining what the proxy does with the annotations.

Specified by:
getAnnotationMessage in interface AnnotatableProxy
Returns:
A message or null
Since:
2.5

getClassName

public String getClassName()
Get the class name of the Java class that implements this plugin. The specified class must implement the Plugin interface.

Returns:
The class name for this plugin

setClassName

private void setClassName(String className)
                   throws InvalidDataException
The class name cannot be changed. Used internally only.

Throws:
InvalidDataException

getJarPath

public String 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.


setJarPath

private void setJarPath(String jarPath)
                 throws InvalidDataException
The jar path cannot be changed. Used internally only.

Throws:
InvalidDataException

getName

public String getName()
Get the name of the plugin.

Specified by:
getName in interface Nameable
Returns:
A string with the name of the plugin

setName

public void setName(String name)
             throws PermissionDeniedException
The name cannot be changed.

Specified by:
setName in interface Nameable
Parameters:
name - The new name for the item
Throws:
PermissionDeniedException - Always

setNameInternal

private void setNameInternal(String name)
                      throws InvalidDataException
The name cannot be changed. Used internally only.

Throws:
InvalidDataException - If the name is null or too long
Developer info
This value is initialised upon installation to: plugin.about().getName() See: loadPluginInformation(String, String, boolean)

getDescription

public String getDescription()
Get a description of the plugin.

Specified by:
getDescription in interface Nameable
Returns:
A string with a description, or null if not known

setDescription

public void setDescription(String description)
                    throws PermissionDeniedException
The description cannot be changed.

Specified by:
setDescription in interface Nameable
Parameters:
description - The new description for the item
Throws:
PermissionDeniedException - Always

setDescriptionInternal

protected void setDescriptionInternal(String description)
                               throws InvalidDataException
The description cannot be changed. Used internally only.

Throws:
InvalidDataException - If the description is too long
Developer info
This value is initialised upon installation to: plugin.about().getDescription() See: loadPluginInformation(String, String, boolean)

getVersionString

public String getVersionString()
Get the version of the plugin.

Returns:
A string with the version of the plugin, or null if not known

setVersionString

private void setVersionString(String version)
                       throws InvalidDataException
The version cannot be changed. Used internally only.

Throws:
InvalidDataException - If the version is too long
Developer info
This value is initialised upon installation to: plugin.about().getVersion() See: loadPluginInformation(String, String, boolean)

getCopyright

public String getCopyright()
Get a copyright notice for the plugin.

Returns:
A string with a copyright notice, or null if not known

setCopyright

private void setCopyright(String copyright)
                   throws InvalidDataException
The copyright notice cannot be changed. Used internally only.

Throws:
InvalidDataException - If the copyright is too long
Developer info
This value is initialised upon installation to: plugin.about().getCopyright() See: loadPluginInformation(String, String, boolean)

getContact

public String getContact()
Get contact information for the plugin.

Returns:
A string with contact information, or null if not known

setContact

private void setContact(String contact)
                 throws InvalidDataException
The contact information cannot be changed. Used internally only.

Throws:
InvalidDataException - If the contact is too long
Developer info
This value is initialised upon installation to: plugin.about().getContact() See: loadPluginInformation(String, String, boolean)

getEmail

public String 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

private void setEmail(String email)
               throws InvalidDataException
The email address cannot be changed. Used internally only.

Throws:
InvalidDataException - If the email is too long
Developer info
This value is initialised upon installation to: plugin.about().getEmail() See: loadPluginInformation(String, String, boolean)

getUrl

public String getUrl()
Get a URL with more information about the plugin.

Returns:
A string containing the URL, or null if not known

setUrl

private void setUrl(String url)
             throws InvalidDataException
The URL cannot be changed. Used internally only.

Throws:
InvalidDataException - If the url is too long
Developer info
This value is initialised upon installation to: plugin.about().getUrl() See: loadPluginInformation(String, String, boolean)

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:
isTrusted()

getMaxMemory

public Long 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 the agent.maxMemory setting in it's configuration file.

Returns:
The maximum amount of memory to use, or null

setMaxMemory

public void setMaxMemory(Long maxMemory)
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:
getMaxMemory()

getMainType

public Plugin.MainType getMainType()
Get the type of plugin.

Returns:
A type code that is defined in the enum Plugin.MainType.

setMainType

private void setMainType(Plugin.MainType type)
                  throws InvalidDataException
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 the InteractivePlugin 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 a PluginConfiguration 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 an InvalidDataException 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:
setPermissions(RoleKey, Set, Set)

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:
ImmediateDownloadExporter

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

public boolean isInContext(GuiContext context)
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 passed Item.REPORTER.

Parameters:
context - The GuiContext type
Returns:
TRUE if the plugin handles the item, FALSE otherwise

getGuiContexts

public Set<GuiContext> getGuiContexts()
Get the Item types where it makes sense to use this plugin for a client application. For example, a plugin that imports reporters would return a set containing Item.REPORTER.

Returns:
A Set of Item:s or an empty set if the plugin is not concerned about items

setGuiContexts

private void setGuiContexts(Set<GuiContext> pluginContexts)
Set the contexts where this plugin can be used.


newPluginConfiguration

public PluginConfiguration newPluginConfiguration()
                                           throws PermissionDeniedException,
                                                  BaseException
Create a new PluginConfiguration for this plugin.

Returns:
The new PluginConfiguration item
Throws:
PermissionDeniedException - If the logged in user doesn't have use permission for this plugin definition
BaseException - If there is another error

getPluginConfigurations

public ItemQuery<PluginConfiguration> getPluginConfigurations()
Get a query that returns the configurations for this plugin definition.

Returns:
An ItemQuery object

getPluginTypes

public ItemQuery<PluginType> getPluginTypes()
Get a query that returns the plugin types for this plugin definition.

Returns:
An ItemQuery object

supports

public boolean supports(PluginType pluginType)
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

public boolean supports(String interfaceName)
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

public Plugin newInstance()
                   throws PermissionDeniedException,
                          BaseException
Get an unitialized instance of the plugin.

Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.USE permission to the items.
BaseException - If there is a problem creating an instance.

newInstance

Plugin newInstance(String jarPath)
             throws PermissionDeniedException,
                    BaseException
Throws:
PermissionDeniedException
BaseException

newInstance

public <P extends Plugin> P newInstance(Class<P> clazz,
                                        String jarPath)
                             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 of Plugin
jarPath - Overrides the default JAR path for a plugin, null to use the default JAR path
Returns:
An uninitialised plugin instance
Throws:
PermissionDeniedException
BaseException

newInstance

public <P extends Plugin> P newInstance(Class<P> clazz,
                                        String jarPath,
                                        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 of Plugin
jarPath - Overrides the default JAR path for a plugin, null to use the default JAR path
sc - The session control to initialise the plugin with
configuration - The configuration parameters to initialise the plugin with, or null if no configuration exists
job - 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,
                           boolean unloadBefore)
                    throws BaseException
Create a new object instance of the given class.

Parameters:
jarPath - The path to the JAR file
className - The class to create
unloadBefore - 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 plugin
granted - The permission to grant to the plugin
denied - The permissions to deny the plugin
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.SET_PERMISSION for this PluginDefinition or trying to grant the plugin more permission then the logged in user
InvalidUseOfNullException - If the rolekey is null

getGranted

public Set<Permission> getGranted(RoleKey roleKey)
                           throws InvalidUseOfNullException
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

public Set<Permission> getDenied(RoleKey roleKey)
                          throws InvalidUseOfNullException
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 jarPath,
                                  String className,
                                  boolean useRequstedPermissions)
                           throws PermissionDeniedException,
                                  InvalidDataException,
                                  BaseException
Load a plugin and copy all information, ie. plugin.about(), to the internal data structure.

Parameters:
jarPath - Path to the jar-file in which the plugin is located. Null is allowed if plugin is located in the web server's classpath.
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.

2.17.2: 2011-06-17