public class MapRouletteConnection extends java.lang.Object implements TaskLoader, java.io.Serializable
| Modifier and Type | Method and Description |
|---|---|
long |
create(java.lang.String getURI,
java.lang.String postURI,
java.lang.String putURI,
com.google.gson.JsonObject data,
java.lang.String logSuccessMessage)
Will create a challenge if it has not already been created
|
long |
createChallenge(Project project,
Challenge challenge)
Creates a new challenge with the given
Challenge, if already exists then will attempt
to update |
long |
createProject(Project project)
Creates a new project with the
Project, if already exists then will attempt to update |
java.lang.String |
getConnectionInfo()
Retrieve the connection info for this connection
|
org.openstreetmap.atlas.streaming.resource.http.HttpResource |
setAuth(org.openstreetmap.atlas.streaming.resource.http.HttpResource resource) |
boolean |
uploadBatchTasks(long challengeId,
java.util.Set<Task> data)
Uploads tasks as a batch, instead of one at a time
|
boolean |
uploadTask(long challengeId,
Task task)
Uploads a task to MapRoulette
|
public java.lang.String getConnectionInfo()
TaskLoadergetConnectionInfo in interface TaskLoaderpublic org.openstreetmap.atlas.streaming.resource.http.HttpResource setAuth(org.openstreetmap.atlas.streaming.resource.http.HttpResource resource)
public boolean uploadBatchTasks(long challengeId,
java.util.Set<Task> data)
throws java.io.UnsupportedEncodingException,
java.net.URISyntaxException
TaskLoaderuploadBatchTasks in interface TaskLoaderchallengeId - The id of the parent challengedata - The list of tasks that should be uploaded for the challengejava.io.UnsupportedEncodingException - Exception could be thrown when you try and upload the batch.java.net.URISyntaxException - if the URI cannot be built correctlypublic boolean uploadTask(long challengeId,
Task task)
throws java.io.UnsupportedEncodingException,
java.net.URISyntaxException
TaskLoaderuploadTask in interface TaskLoaderchallengeId - The id of the parent challengetask - The JSON payload used to upload the taskjava.io.UnsupportedEncodingException - If the JSON is invalid, which it never should bejava.net.URISyntaxException - if the URI cannot be built correctlypublic long createProject(Project project) throws java.io.UnsupportedEncodingException, java.net.URISyntaxException
TaskLoaderProject, if already exists then will attempt to updatecreateProject in interface TaskLoaderproject - The project object containing name and descriptionjava.io.UnsupportedEncodingException - if json data for API payload cannot be encoded correctlyjava.net.URISyntaxException - if the URI for getting/creating/updating project is incorrectly generatedpublic long createChallenge(Project project, Challenge challenge) throws java.io.UnsupportedEncodingException, java.net.URISyntaxException
TaskLoaderChallenge, if already exists then will attempt
to updatecreateChallenge in interface TaskLoaderproject - The parent project object of the challengechallenge - The challenge to create or updatejava.io.UnsupportedEncodingException - if json data for API payload cannot be encoded correctlyjava.net.URISyntaxException - if the URI for getting/creating/updating project is incorrectly generatedpublic long create(java.lang.String getURI,
java.lang.String postURI,
java.lang.String putURI,
com.google.gson.JsonObject data,
java.lang.String logSuccessMessage)
throws java.io.UnsupportedEncodingException,
java.net.URISyntaxException
getURI - The URI used to retrieve the objectpostURI - The URI used to create the objectputURI - The URI used to update the objectdata - The data of the object to create/updatelogSuccessMessage - The message to display on successful creation/update of objectjava.io.UnsupportedEncodingException - if cannot encode string for post/put to map roulettejava.net.URISyntaxException - if URI supplied is invalid and cannot be built