public class ApiUrlTestTask extends PleaseWaitRunnable
isSuccess()
replies true, otherwise false.
Note: it fetches a list of changesets instead of the much smaller capabilities because - strangely enough -
an OSM server "https://x.y.y/api/0.6" not only responds to "https://x.y.y/api/0.6/capabilities" but also
to "https://x.y.y/api/0/capabilities" or "https://x.y.y/a/capabilities" with valid capabilities. If we get
valid capabilities with an URL we therefore can't be sure that the base URL is valid API URL.Modifier and Type | Field and Description |
---|---|
private boolean |
canceled |
private java.net.HttpURLConnection |
connection |
private java.awt.Component |
parent |
private boolean |
success |
private java.lang.String |
url |
progressMonitor
Constructor and Description |
---|
ApiUrlTestTask(java.awt.Component parent,
java.lang.String url)
Creates the task
|
Modifier and Type | Method and Description |
---|---|
protected void |
alertConnectionFailed() |
protected void |
alertInvalidChangesetList() |
protected void |
alertInvalidChangesetUrl(java.lang.String url) |
protected void |
alertInvalidServerResult(int retCode) |
protected void |
alertInvalidUrl(java.lang.String url) |
protected void |
cancel()
User pressed cancel button.
|
protected void |
finish()
Finish up the data work.
|
protected java.lang.String |
getNormalizedApiUrl()
Removes leading and trailing whitespace from the API URL and removes trailing
'/'.
|
boolean |
isCanceled()
Determines if the test has been canceled.
|
boolean |
isSuccess()
Determines if the test has succeeded.
|
protected void |
realRun()
Called in the worker thread to do the actual work.
|
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
private java.lang.String url
private boolean canceled
private boolean success
private java.awt.Component parent
private java.net.HttpURLConnection connection
public ApiUrlTestTask(java.awt.Component parent, java.lang.String url) throws java.lang.IllegalArgumentException
parent
- the parent component relative to which the PleaseWaitRunnable
-Dialog is displayedurl
- the url. Must not be null.java.lang.IllegalArgumentException
- thrown if url is null.protected void alertInvalidUrl(java.lang.String url)
protected void alertInvalidChangesetUrl(java.lang.String url)
protected void alertConnectionFailed()
protected void alertInvalidServerResult(int retCode)
protected void alertInvalidChangesetList()
protected void cancel()
PleaseWaitRunnable
cancel
in class PleaseWaitRunnable
protected void finish()
PleaseWaitRunnable
finish
in class PleaseWaitRunnable
protected java.lang.String getNormalizedApiUrl()
protected void realRun() throws org.xml.sax.SAXException, java.io.IOException, OsmTransferException
PleaseWaitRunnable
realRun
in class PleaseWaitRunnable
org.xml.sax.SAXException
java.io.IOException
OsmTransferException
public boolean isCanceled()
true
if canceled, false
otherwisepublic boolean isSuccess()
true
if success, false
otherwise