cz.vity.freerapid.plugins.webclient
Class AbstractFileShareService

java.lang.Object
  extended by org.java.plugin.Plugin
      extended by cz.vity.freerapid.plugins.webclient.AbstractFileShareService
All Implemented Interfaces:
ShareDownloadService

public abstract class AbstractFileShareService
extends org.java.plugin.Plugin
implements ShareDownloadService

Implements ShareDownloadService and adds basic functionality

Author:
Vity

Field Summary
 
Fields inherited from class org.java.plugin.Plugin
log
 
Constructor Summary
AbstractFileShareService()
          Constructor AbstractFileShareService creates a new AbstractFileShareService instance.
 
Method Summary
protected  void doStart()
           
protected  void doStop()
           
protected  PremiumAccount getAccountConfigFromFile(String pluginConfigFile)
          Loads PremiumAccount information from file.
 Icon getFaviconImage()
          Returns small icon (16x16) that represents service on the web
 String getId()
          Unique ID of the plugin
 PluginContext getPluginContext()
          Returns instance of plugin context to allow access UI or Locale storage
protected abstract  PluginRunner getPluginRunnerInstance()
          Returns new instance of "plugin's worker" - its methods are called from this class Instance should not be cached.
protected  void checkSupportedURL(HttpFileDownloadTask downloadTask)
          Method checkSupportedURL ...
 void run(HttpFileDownloadTask downloadTask)
          Main executable method for downloading file
 void runCheck(HttpFileDownloadTask downloadTask)
          Checks for file existence before downloading Shouldn't be called if the supportsRunCheck method returns false
 void setPluginContext(PluginContext pluginContext)
          Sets the new plugin context for this plugin
protected  PremiumAccount showAccountDialog(PremiumAccount account, String dialogTitle, String pluginConfigFile)
          Shows standard account dialog with given account
 void showOptions()
          Method called from user preferences to show configurable dialog to user
 boolean supportsRunCheck()
          Checks whether implementation/service supports a check for file existence before downloading
protected  boolean supportURL(String url)
          Method supportURL checks whether active plugin supports given URL
 String toString()
           
 
Methods inherited from class org.java.plugin.Plugin
getDescriptor, getManager, isActive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface cz.vity.freerapid.plugins.webclient.interfaces.ShareDownloadService
getMaxDownloadsFromOneIP, getName
 

Constructor Detail

AbstractFileShareService

public AbstractFileShareService()
Constructor AbstractFileShareService creates a new AbstractFileShareService instance.

Method Detail

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class org.java.plugin.Plugin
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class org.java.plugin.Plugin
Throws:
Exception

getFaviconImage

public Icon getFaviconImage()
Description copied from interface: ShareDownloadService
Returns small icon (16x16) that represents service on the web

Specified by:
getFaviconImage in interface ShareDownloadService
Returns:
small icon, null if there is no associated icon

getId

public String getId()
Description copied from interface: ShareDownloadService
Unique ID of the plugin

Specified by:
getId in interface ShareDownloadService
Returns:
unique ID plugin

supportURL

protected boolean supportURL(String url)
Method supportURL checks whether active plugin supports given URL

Parameters:
url - given URL to test
Returns:
boolean true if plugin supports downloading from this URL

toString

public String toString()
Overrides:
toString in class org.java.plugin.Plugin

run

public void run(HttpFileDownloadTask downloadTask)
         throws Exception
Description copied from interface: ShareDownloadService
Main executable method for downloading file

Specified by:
run in interface ShareDownloadService
Parameters:
downloadTask - file that is being downloaded
Throws:
Exception - exception during downloading

runCheck

public void runCheck(HttpFileDownloadTask downloadTask)
              throws Exception
Description copied from interface: ShareDownloadService
Checks for file existence before downloading Shouldn't be called if the supportsRunCheck method returns false

Specified by:
runCheck in interface ShareDownloadService
Parameters:
downloadTask - file that is being checked
Throws:
Exception
IllegalStateException - if service does not supports checking file

supportsRunCheck

public boolean supportsRunCheck()
Description copied from interface: ShareDownloadService
Checks whether implementation/service supports a check for file existence before downloading

Specified by:
supportsRunCheck in interface ShareDownloadService
Returns:
true if the implementation supports existence check, false otherwise

showOptions

public void showOptions()
                 throws Exception
Description copied from interface: ShareDownloadService
Method called from user preferences to show configurable dialog to user

Specified by:
showOptions in interface ShareDownloadService
Throws:
Exception

getPluginContext

public PluginContext getPluginContext()
Description copied from interface: ShareDownloadService
Returns instance of plugin context to allow access UI or Locale storage

Specified by:
getPluginContext in interface ShareDownloadService
Returns:
instance of plugin context

checkSupportedURL

protected void checkSupportedURL(HttpFileDownloadTask downloadTask)
                          throws NotSupportedDownloadByServiceException
Method checkSupportedURL ...

Parameters:
downloadTask -
Throws:
NotSupportedDownloadByServiceException - when

setPluginContext

public void setPluginContext(PluginContext pluginContext)
Description copied from interface: ShareDownloadService
Sets the new plugin context for this plugin

Specified by:
setPluginContext in interface ShareDownloadService
Parameters:
pluginContext - instance of plugin context

showAccountDialog

protected PremiumAccount showAccountDialog(PremiumAccount account,
                                           String dialogTitle,
                                           String pluginConfigFile)
Shows standard account dialog with given account

Parameters:
account - account with user name and password
dialogTitle - title for dialog
pluginConfigFile - file name for storing configuration
Returns:
returns account parametr, if user pressed Cancel button, otherwise it returns updated account instance

getAccountConfigFromFile

protected PremiumAccount getAccountConfigFromFile(String pluginConfigFile)
Loads PremiumAccount information from file.
Returns new PremiumAccount instance if there is no configuration file yet.

Parameters:
pluginConfigFile - file name of configuration file
Returns:
instance of PremiumAccount - loaded from file or new instance if there is no configuration on disk yet

getPluginRunnerInstance

protected abstract PluginRunner getPluginRunnerInstance()
Returns new instance of "plugin's worker" - its methods are called from this class Instance should not be cached. It should return always new instance.

Returns:
instance of PluginRunner