|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.plugin.AbstractPlugin net.sf.basedb.util.zip.AbstractFileUnpacker
public abstract class AbstractFileUnpacker
This is a base class for all plugins that wants to implement the 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:
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface net.sf.basedb.core.plugin.Plugin |
---|
Plugin.MainType |
Field Summary | |
---|---|
private RequestInformation |
configureJob
|
private static Set<GuiContext> |
guiContexts
The context is always [ FILE, ITEM]. |
protected static String |
OVERWRITE
The name of the parameter that asks if existing files should be overwritten or not. |
private static Set<Permissions> |
permissions
|
private ThreadSignalHandler |
signalHandler
|
protected static 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 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. |
Fields inherited from class net.sf.basedb.core.plugin.AbstractPlugin |
---|
annotationSection, configuration, COPY_ANNOTATIONS, job, OVERWRITE_ANNOTATIONS, sc |
Constructor Summary | |
---|---|
AbstractFileUnpacker()
|
Method Summary | |
---|---|
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<String> |
getDirectoryParameter(String label,
String description)
Get a plugin parameter that asks for the directory where the unpacked files are stored. |
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<Boolean> |
getOverwriteParameter(String label,
String description)
Get a plugin parameter that asks if existing files should be overwritten or not. |
Collection<Permissions> |
getPermissions()
Request create and write access to File:s and Directory:s. |
RequestInformation |
getRequestInformation(GuiContext context,
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(String label,
String description)
Get a plugin parameter that asks for the file that is going to be unpacked. |
String |
isInContext(GuiContext context,
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. |
Methods inherited from class net.sf.basedb.core.plugin.AbstractPlugin |
---|
checkInterrupted, cloneParameterWithDefaultValue, closeLogFile, createLogFile, done, getCopyAnnotationsParmeter, getCurrentConfiguration, getCurrentJob, getJobOrConfigurationValue, getOverwriteAnnotationsParameters, init, log, log, storeValue, storeValue, storeValues, validateRequestParameters |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.basedb.util.zip.FileUnpacker |
---|
getExtensions, getFormatName, getMimeTypes, unpack |
Methods inherited from interface net.sf.basedb.core.plugin.Plugin |
---|
done, getAbout, init |
Field Detail |
---|
private static final Set<GuiContext> guiContexts
private static final Set<Permissions> permissions
private static final ItemParameterType<File> zipFileType
private static final PathParameterType unpackType
private RequestInformation configureJob
private ThreadSignalHandler signalHandler
protected static final String ZIP_FILE
getZipFileParameter(String, String)
,
Constant Field Valuesprotected static final String UNPACK_DIRECTORY
getZipFileParameter(String, String)
,
Constant Field Valuesprotected static final String OVERWRITE
getOverwriteParameter(String, String)
,
Constant Field ValuesConstructor Detail |
---|
public AbstractFileUnpacker()
Method Detail |
---|
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 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 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 String isInContext(GuiContext context, 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
context
Null
if the plugin can use that item, or
a warning-level message explaining why the plugin can't be usedpublic RequestInformation getRequestInformation(GuiContext context, 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 command
RequestInformation
for the command
BaseException
- 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(String label, 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<String> getDirectoryParameter(String label, 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 access
getUnpackDirectory(DbControl)
protected File getCurrentFile(DbControl dc)
dc
- A DbControl to use for database access
getZipFile(DbControl)
protected Directory getUnpackDirectory(DbControl dc)
getDirectoryParameter(String, String)
,
getCurrentDirectory(DbControl)
protected PluginParameter<Boolean> getOverwriteParameter(String label, 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)
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |