public abstract class AbstractFileUnpacker extends AbstractPlugin implements FileUnpacker, InteractivePlugin, SignalTarget
FileUnpacker
interface. This class takes care of all the hard work that is required by a plugin.
Ie. the creating and saving the parameters that are needed, context checking, etc.
The subclass only has to implement the remaingin methods in the FileUnpacker
interface which basically boils down to implementing the actual unpacking of the
compressed file.
The implementation in this class asks for three parameters:
Plugin.MainType
Modifier and Type | Field and Description |
---|---|
private RequestInformation |
configureJob |
private static java.util.Set<GuiContext> |
guiContexts
The context is always [ FILE, ITEM].
|
protected static java.lang.String |
OVERWRITE
The name of the parameter that asks if existing files should be
overwritten or not.
|
private static java.util.Set<Permissions> |
permissions |
private ThreadSignalHandler |
signalHandler |
protected static java.lang.String |
UNPACK_DIRECTORY
The name of the parameter that asks for the directory where the
unpacked files are stored.
|
private static PathParameterType |
unpackType
The parameter type for unpack directory.
|
protected static java.lang.String |
ZIP_FILE
The name of the parameter that asks for the file that is going to
be unpacked.
|
private static ItemParameterType<File> |
zipFileType
The parameter type for file to unpack.
|
annotationSection, configuration, COPY_ANNOTATIONS, job, OVERWRITE_ANNOTATIONS, sc
Constructor and Description |
---|
AbstractFileUnpacker() |
Modifier and Type | Method and Description |
---|---|
void |
configure(GuiContext context,
Request request,
Response response)
Configure the plugin.
|
private RequestInformation |
getConfigureJobParameters(GuiContext context) |
protected Directory |
getCurrentDirectory(DbControl dc)
Get the current directory or null there is no current or it can't be loaded.
|
protected File |
getCurrentFile(DbControl dc)
Get the current file or null there is no current or it can't be loaded.
|
protected PluginParameter<java.lang.String> |
getDirectoryParameter(java.lang.String label,
java.lang.String description)
Get a plugin parameter that asks for the directory where the
unpacked files are stored.
|
java.util.Set<GuiContext> |
getGuiContexts()
Get a set containing all items that the plugin handles.
|
Plugin.MainType |
getMainType()
Get the type of the plugin.
|
protected boolean |
getOverwrite()
If existing file should be overwritten or not.
|
protected PluginParameter<java.lang.Boolean> |
getOverwriteParameter(java.lang.String label,
java.lang.String description)
Get a plugin parameter that asks if existing files should be overwritten
or not.
|
java.util.Collection<Permissions> |
getPermissions()
Request create and write access to File:s and Directory:s.
|
RequestInformation |
getRequestInformation(GuiContext context,
java.lang.String command)
This method will return the
RequestInformation for a given command, i.e. |
SignalHandler |
getSignalHandler()
Get the signal handler that is handling signals on behalf of this
object.
|
protected Directory |
getUnpackDirectory(DbControl dc)
Get the directory where the unpacked files are placed by the plugin.
|
protected File |
getZipFile(DbControl dc)
Get the file that is going to be unpacked by the plugin.
|
protected PluginParameter<File> |
getZipFileParameter(java.lang.String label,
java.lang.String description)
Get a plugin parameter that asks for the file that is going to
be unpacked.
|
java.lang.String |
isInContext(GuiContext context,
java.lang.Object item)
Check if the plugin can be used on the specified object.
|
boolean |
requiresConfiguration()
Returns FALSE.
|
void |
run(Request request,
Response response,
ProgressReporter progress)
Run the plugin.
|
boolean |
supportsConfigurations()
Returns FALSE.
|
cloneParameterWithDefaultValue, closeLogFile, createLogFile, done, getCopyAnnotationsParmeter, getCurrentConfiguration, getCurrentJob, getJobOrConfigurationValue, getOverwriteAnnotationsParameters, init, log, log, storeValue, storeValue, storeValues, validateRequestParameters
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getExtensions, getFormatName, getMimeTypes, unpack
private static final java.util.Set<GuiContext> guiContexts
private static final java.util.Set<Permissions> permissions
private static final ItemParameterType<File> zipFileType
private static final PathParameterType unpackType
private RequestInformation configureJob
private ThreadSignalHandler signalHandler
protected static final java.lang.String ZIP_FILE
protected static final java.lang.String UNPACK_DIRECTORY
protected static final java.lang.String OVERWRITE
public Plugin.MainType getMainType()
Plugin
getMainType
in interface Plugin
public boolean supportsConfigurations()
supportsConfigurations
in interface Plugin
supportsConfigurations
in class AbstractPlugin
public boolean requiresConfiguration()
requiresConfiguration
in interface Plugin
requiresConfiguration
in class AbstractPlugin
public java.util.Collection<Permissions> getPermissions()
getPermissions
in interface Plugin
getPermissions
in class AbstractPlugin
public void run(Request request, Response response, ProgressReporter progress)
Plugin
run
in interface Plugin
request
- Request object with the command and parametersresponse
- Response object in for the plugin to response
throughprogress
- A ProgressReporter
where the plugin can report
its progess, can be nullpublic java.util.Set<GuiContext> getGuiContexts()
InteractivePlugin
Item.REPORTER
.
This information is used by client applications to put the plugin
in the proper place in the user interface.getGuiContexts
in interface InteractivePlugin
Set
containing Item
:s, or null
if the plugin is not concerned about itemspublic java.lang.String isInContext(GuiContext context, java.lang.Object item)
InteractivePlugin
BasicItem
or BasicData
object, or null if called from
a list context. A client application should only call this method for
contexts matching one of
the contexts in the set returned by the InteractivePlugin.getGuiContexts()
method. For GuiContext.Type.ITEM
contexts an item
of the correct type should be passed as a parameter.
The plug-in can response with a null value indicating success, a warning-level message or throw an exception to indicate an error-level message. Client application should normally only show error-level messages to users, unless the user has requested to see warning messages.
NOTE! Before BASE 2.4 all messages were treated as error-level messages.
isInContext
in interface InteractivePlugin
context
- The current context of the client application,
it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
item
- The currently active item, it's type should match the
GuiContext.getItem()
type, or null if the context is a list
contextNull
if the plugin can use that item, or
a warning-level message explaining why the plugin can't be usedpublic RequestInformation getRequestInformation(GuiContext context, java.lang.String command) throws BaseException
InteractivePlugin
RequestInformation
for a given command, i.e.
the list of parameters and some nice help text.getRequestInformation
in interface InteractivePlugin
context
- The current context of the client application,
it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
command
- The commandRequestInformation
for the commandBaseException
- if there is an errorpublic void configure(GuiContext context, Request request, Response response)
InteractivePlugin
InteractivePlugin.getRequestInformation(GuiContext, String)
.configure
in interface InteractivePlugin
context
- The current context of the client application,
it is one of the values found in set returned by InteractivePlugin.getGuiContexts()
request
- Request object with the command and parametersresponse
- Response object in for the plugin to response
throughpublic SignalHandler getSignalHandler()
SignalTarget
getSignalHandler
in interface SignalTarget
protected PluginParameter<File> getZipFileParameter(java.lang.String label, java.lang.String description)
label
- The parameter label, or null to use the default (File)description
- The parameter description, or null to use the default
(The file to unpack.)protected File getZipFile(DbControl dc)
getZipFileParameter(String, String)
,
getCurrentFile(DbControl)
protected PluginParameter<java.lang.String> getDirectoryParameter(java.lang.String label, java.lang.String description)
label
- The parameter label, or null to use the default (Save in)description
- The parameter description, or null to use the default
(The directory where the unpacked files should be saved.)protected Directory getCurrentDirectory(DbControl dc)
dc
- A DbControl to use for database accessgetUnpackDirectory(DbControl)
protected File getCurrentFile(DbControl dc)
dc
- A DbControl to use for database accessgetZipFile(DbControl)
protected Directory getUnpackDirectory(DbControl dc)
getDirectoryParameter(String, String)
,
getCurrentDirectory(DbControl)
protected PluginParameter<java.lang.Boolean> getOverwriteParameter(java.lang.String label, java.lang.String description)
label
- The parameter label, or null to use the default (Overwrite)description
- The parameter description, or null to use the default
(Specify if existing files should be overwritten or not.)protected boolean getOverwrite()
getOverwriteParameter(String, String)
private RequestInformation getConfigureJobParameters(GuiContext context)