|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcz.vity.freerapid.plugins.webclient.AbstractRunner
public abstract class AbstractRunner
Parent class for all "Runners" - implementation of plugins.
| Field Summary | |
|---|---|
protected HttpDownloadClient |
client
Field client - to access internet |
protected HttpFileDownloadTask |
downloadTask
Task that manages download |
protected String |
fileURL
Field fileURL |
protected HttpFile |
httpFile
file that is being downloaded |
| Constructor Summary | |
|---|---|
AbstractRunner()
Constructs a new AbstractRunner. |
|
| Method Summary | |
|---|---|
protected void |
addCookie(org.apache.commons.httpclient.Cookie cookie)
Sets a cookie to the current session. |
protected String |
getBaseURL()
Returns base url for the site |
protected CaptchaSupport |
getCaptchaSupport()
Access to class that help to manage loading and showing CAPTCHA to the user |
protected String |
getContentAsString()
Returns last response from server as string |
protected DialogSupport |
getDialogSupport()
Help method to get support for showing simple dialogs to user during downloading or for user options |
protected org.apache.commons.httpclient.methods.GetMethod |
getGetMethod(String uri)
Help method for easier calling client.getGetMethod in Runner |
protected Matcher |
getMatcherAgainstContent(String regexp)
Method returns Matcher for given regular expression and content of the web page that was get from the last request |
protected MethodBuilder |
getMethodBuilder()
Returns new instance of MethodBuilder, which is used to create GET and POST method. |
protected MethodBuilder |
getMethodBuilder(String content)
Returns new instance of MethodBuilder, which is used to create GET and POST method. |
ShareDownloadService |
getPluginService()
Getter for property 'pluginService'. |
protected org.apache.commons.httpclient.methods.PostMethod |
getPostMethod(String uri)
Help method for easier calling client.getPostMethod in Runner |
void |
init(ShareDownloadService service,
HttpFileDownloadTask downloadTask)
Initialization of runner - this method is called as first before methods run() and runCheck() |
protected boolean |
makeRedirectedRequest(org.apache.commons.httpclient.HttpMethod method)
Method makeRequest does simple request to server via given HTTP method. |
protected boolean |
makeRequest(org.apache.commons.httpclient.HttpMethod method)
Method makeRequest does simple request to server via given HTTP method Autoredirect is off. |
void |
run()
Main "bussiness logic" of the plugin - process of file downloading from service If no exception is thrown, everything is being considered to be OK - file download state is set to COMPLETED automatically |
void |
runCheck()
Main "bussiness logic" of the plugin - process of downloading If no exception is thrown, everything is being considered to be OK - file state is set to FileState.EXISTING_AND_CHECKED automatically |
protected void |
setClientParameter(String parameterName,
Object parameterValue)
Sets client parameter for handling requests |
protected void |
setPageEncoding(String encoding)
Sets encoding for the web page - encoding must be sets manually, it's not determined automatically UTF-8 encoding is set by default |
protected boolean |
tryDownloadAndSaveFile(org.apache.commons.httpclient.HttpMethod method)
Method uses given method parameter to connect to the server and tries to download. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected HttpDownloadClient client
protected HttpFileDownloadTask downloadTask
protected HttpFile httpFile
protected String fileURL
| Constructor Detail |
|---|
public AbstractRunner()
| Method Detail |
|---|
public void init(ShareDownloadService service,
HttpFileDownloadTask downloadTask)
init in interface PluginRunnerservice - download service that is associated to this runnerdownloadTask - file downloader
public void run()
throws Exception
run in interface PluginRunnerException - if anything went wrongDownloadState,
FileState
public void runCheck()
throws Exception
runCheck in interface PluginRunnerExceptionDownloadState,
FileStateprotected CaptchaSupport getCaptchaSupport()
CaptchaSupportprotected DialogSupport getDialogSupport()
DialogSupport
protected boolean tryDownloadAndSaveFile(org.apache.commons.httpclient.HttpMethod method)
throws Exception
DownloadState.GETTING and then DownloadState.DOWNLOADING
method - HttpMethod - its URL should be a link to the file
Exception - when connection/writing to file failedpublic ShareDownloadService getPluginService()
protected boolean makeRequest(org.apache.commons.httpclient.HttpMethod method)
throws IOException
method - HTTP method
IOException - when there was error during getting response from serverHttpStatus.SC_OK
protected boolean makeRedirectedRequest(org.apache.commons.httpclient.HttpMethod method)
throws IOException
method - HTTP method
IOException - when there was error during getting response from serverHttpStatus.SC_OKprotected org.apache.commons.httpclient.methods.PostMethod getPostMethod(String uri)
uri - URI for connecting via this POST method
HttpDownloadClient.getPostMethod(String)protected org.apache.commons.httpclient.methods.GetMethod getGetMethod(String uri)
uri - URI for connecting via this GET method
HttpDownloadClient.getGetMethod(String)protected String getContentAsString()
protected Matcher getMatcherAgainstContent(String regexp)
regexp - regular expression that is used for parsing content
protected MethodBuilder getMethodBuilder()
throws BuildMethodException
BuildMethodException
protected MethodBuilder getMethodBuilder(String content)
throws BuildMethodException
content - specific content
BuildMethodExceptionprotected void addCookie(org.apache.commons.httpclient.Cookie cookie)
protected String getBaseURL()
protected void setClientParameter(String parameterName,
Object parameterValue)
parameterName - name of parameterparameterValue - parameter's valueprotected void setPageEncoding(String encoding)
encoding - encoding name - like Windows-1250, ISO-8859-1
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||