Class MapRouletteConnection
- java.lang.Object
-
- org.openstreetmap.atlas.checks.maproulette.MapRouletteConnection
-
- All Implemented Interfaces:
java.io.Serializable,TaskLoader
public class MapRouletteConnection extends java.lang.Object implements TaskLoader, java.io.Serializable
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcreate(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 createdlongcreateChallenge(Project project, Challenge challenge)Creates a new challenge with the givenChallenge, if already exists then will attempt to updatelongcreateProject(Project project)Creates a new project with theProject, if already exists then will attempt to updatejava.lang.StringgetConnectionInfo()Retrieve the connection info for this connectionorg.openstreetmap.atlas.streaming.resource.http.HttpResourcesetAuth(org.openstreetmap.atlas.streaming.resource.http.HttpResource resource)booleanuploadBatchTasks(long challengeId, java.util.Set<Task> data)Uploads tasks as a batch, instead of one at a timebooleanuploadTask(long challengeId, Task task)Uploads a task to MapRoulette
-
-
-
Method Detail
-
getConnectionInfo
public java.lang.String getConnectionInfo()
Description copied from interface:TaskLoaderRetrieve the connection info for this connection- Specified by:
getConnectionInfoin interfaceTaskLoader- Returns:
- A string
-
setAuth
public org.openstreetmap.atlas.streaming.resource.http.HttpResource setAuth(org.openstreetmap.atlas.streaming.resource.http.HttpResource resource)
-
uploadBatchTasks
public boolean uploadBatchTasks(long challengeId, java.util.Set<Task> data) throws java.io.UnsupportedEncodingException, java.net.URISyntaxExceptionDescription copied from interface:TaskLoaderUploads tasks as a batch, instead of one at a time- Specified by:
uploadBatchTasksin interfaceTaskLoader- Parameters:
challengeId- The id of the parent challengedata- The list of tasks that should be uploaded for the challenge- Returns:
- The JSON payload used to upload the task
- Throws:
java.io.UnsupportedEncodingException- Exception could be thrown when you try and upload the batch.java.net.URISyntaxException- if the URI cannot be built correctly
-
uploadTask
public boolean uploadTask(long challengeId, Task task) throws java.io.UnsupportedEncodingException, java.net.URISyntaxExceptionDescription copied from interface:TaskLoaderUploads a task to MapRoulette- Specified by:
uploadTaskin interfaceTaskLoader- Parameters:
challengeId- The id of the parent challengetask- The JSON payload used to upload the task- Returns:
- true if the task was uploaded successfully
- Throws:
java.io.UnsupportedEncodingException- If the JSON is invalid, which it never should bejava.net.URISyntaxException- if the URI cannot be built correctly
-
createProject
public long createProject(Project project) throws java.io.UnsupportedEncodingException, java.net.URISyntaxException
Description copied from interface:TaskLoaderCreates a new project with theProject, if already exists then will attempt to update- Specified by:
createProjectin interfaceTaskLoader- Parameters:
project- The project object containing name and description- Returns:
- The id for the project
- Throws:
java.io.UnsupportedEncodingException- if json data for API payload cannot be encoded correctlyjava.net.URISyntaxException- if the URI for getting/creating/updating project is incorrectly generated
-
createChallenge
public long createChallenge(Project project, Challenge challenge) throws java.io.UnsupportedEncodingException, java.net.URISyntaxException
Description copied from interface:TaskLoaderCreates a new challenge with the givenChallenge, if already exists then will attempt to update- Specified by:
createChallengein interfaceTaskLoader- Parameters:
project- The parent project object of the challengechallenge- The challenge to create or update- Returns:
- The id for the challenge
- Throws:
java.io.UnsupportedEncodingException- if json data for API payload cannot be encoded correctlyjava.net.URISyntaxException- if the URI for getting/creating/updating project is incorrectly generated
-
create
public 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.URISyntaxExceptionWill create a challenge if it has not already been created- Parameters:
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 object- Returns:
- The id of the created object
- Throws:
java.io.UnsupportedEncodingException- if cannot encode string for post/put to map roulettejava.net.URISyntaxException- if URI supplied is invalid and cannot be built
-
-