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 "http://x.y.y/api/0.6" not only responds to "http://x.y.y/api/0.6/capabilities" but also
to "http://x.y.y/api/0/capabilities" or "http://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 HttpURLConnection |
connection |
private Component |
parent |
private boolean |
success |
private String |
url |
progressMonitor
Constructor and Description |
---|
ApiUrlTestTask(Component parent,
String url)
Creates the task
|
Modifier and Type | Method and Description |
---|---|
protected void |
alertConnectionFailed() |
protected void |
alertInvalidChangesetList() |
protected void |
alertInvalidChangesetUrl(String url) |
protected void |
alertInvalidServerResult(int retCode) |
protected void |
alertInvalidUrl(String url) |
protected void |
cancel()
User pressed cancel button.
|
protected void |
finish()
Finish up the data work.
|
protected String |
getNormalizedApiUrl()
Removes leading and trailing whitespace from the API URL and removes trailing
'/'.
|
boolean |
isCanceled() |
boolean |
isSuccess() |
protected void |
realRun()
Called in the worker thread to do the actual work.
|
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
private boolean canceled
private boolean success
private HttpURLConnection connection
public ApiUrlTestTask(Component parent, String url) throws IllegalArgumentException
parent
- the parent component relative to which the PleaseWaitRunnable
-Dialog is displayedurl
- the url. Must not be null.IllegalArgumentException
- thrown if url is null.protected void alertInvalidUrl(String url)
protected void alertInvalidChangesetUrl(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 String getNormalizedApiUrl()
protected void realRun() throws SAXException, IOException, OsmTransferException
PleaseWaitRunnable
realRun
in class PleaseWaitRunnable
SAXException
IOException
OsmTransferException
public boolean isCanceled()
public boolean isSuccess()