public class DataService
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.lang.String |
apiKey
The API-key for the current instance.
|
Constructor and Description |
---|
DataService()
Initialize with default values
|
DataService(java.lang.String key)
Initializes the object with the api key
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getContentOfRemoteFile(java.lang.String filename)
Downloads the contents of a file from Redunda.
|
java.lang.String |
getContentOfRemoteFile(java.lang.String filename,
boolean trackFile)
Downloads the contents of a file from Redunda
|
com.google.gson.JsonArray |
getRemoteFileList()
Returns the list of files on the server as `JsonArray`
|
int |
getSyncInterval()
Returns the time in seconds between two syncs.
|
java.util.List<java.lang.String> |
getTrackedFiles()
Returns the list of tracked files
A tracked file may NOT contain the string `_slash_`!
|
void |
pushFile(java.lang.String filename)
Uploads a file to Redunda
This will ALWAYS overwrite the files on the server
|
void |
pushFiles()
Uploads all tracked files to Redunda.
|
void |
setSyncInterval(int seconds)
Sets the time between two syncs.
|
void |
start()
Resets the executor services and starts checking the files after 30 seconds
If the bot has just started, it is better to call `syncAndStart()`.
|
void |
syncAndStart()
Synchronizes the files synchronously and then starts the background thread.
|
void |
syncFiles()
Synchronizes the files for the bot via Redunda.
|
void |
trackFile(java.lang.String path)
Adds a file to the list of tracked files
|
public java.lang.String apiKey
public DataService()
public DataService(java.lang.String key)
key
- The API key for Redunda. You can get it form the instances overviewpublic void setSyncInterval(int seconds)
seconds
- The new valuepublic int getSyncInterval()
public void trackFile(java.lang.String path)
path
- The path to the file to trackpublic java.util.List<java.lang.String> getTrackedFiles()
public void pushFiles() throws java.io.IOException
java.io.IOException
- If the upload of a file failspublic void pushFile(java.lang.String filename) throws java.io.IOException
filename
- The name of the file to uploadjava.io.IOException
- if the file couldn't be readpublic com.google.gson.JsonArray getRemoteFileList() throws java.lang.Throwable
java.lang.Throwable
- If the download/parsing failspublic java.lang.String getContentOfRemoteFile(java.lang.String filename) throws java.lang.Throwable
filename
- The name of the file to downloadjava.lang.Throwable
- If an error occurs while downloading the filepublic java.lang.String getContentOfRemoteFile(java.lang.String filename, boolean trackFile) throws java.lang.Throwable
filename
- The name of the file to downloadtrackFile
- If `true`, the file will be added to the list of tracked filesjava.lang.Throwable
- If an error occurs while downloading the filepublic void syncFiles()
public final void syncAndStart()
public final void start()