Class DropBoxFileSystem
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.internal.lang.FileSystem
com.northconcepts.datapipeline.filesystem.dropbox.DropBoxFileSystem
Class for accessing the DropBox file system.
-
Field Summary
Fields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionEnables access to DropBox with the access token supplied through aCredentialsResolver(seesetCredentialsResolver(CredentialsResolver)).DropBoxFileSystem(String token) Creates a file system that uses the given DropBox access token unless aCredentialsResolversupplies one. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the DropBox connection.List<Metadata> listFolder(String folderName) Returns an list of all DropBox files and folders belonging to thefolderName.List<Metadata> Returns aListof all DropBox files and folders in the root folder.voidopen()Opens a connection to the DropBox file system.Reads the file in the DropBox root folder.Reads the file in the specified DropBox folder.setCredentialsResolver(CredentialsResolver credentialsResolver) Sets the resolver supplying this file system's access token (Credentials.TOKEN) — resolved on eachopen(), never at construction, so rotated tokens are picked up on the next connection.Writes the file to the DropBox File System.Writes the file to the specified folder in the DropBox File System.Methods inherited from class com.northconcepts.datapipeline.internal.lang.FileSystem
credentialValue, getCredentialsResolver, getCurrentCredentials, refreshCredentials, resolveCredentialsMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, addExceptionProperties, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getNestedEndpoint, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getRootEndpoint, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription, toString
-
Constructor Details
-
DropBoxFileSystem
Creates a file system that uses the given DropBox access token unless aCredentialsResolversupplies one. -
DropBoxFileSystem
public DropBoxFileSystem()Enables access to DropBox with the access token supplied through aCredentialsResolver(seesetCredentialsResolver(CredentialsResolver)).
-
-
Method Details
-
setCredentialsResolver
Sets the resolver supplying this file system's access token (Credentials.TOKEN) — resolved on eachopen(), never at construction, so rotated tokens are picked up on the next connection. When the resolved credentials don't contain a token, the constructor-supplied token is used.- Overrides:
setCredentialsResolverin classFileSystem
-
open
Opens a connection to the DropBox file system.- Overrides:
openin classEndpoint- Throws:
DataException
-
close
Closes the DropBox connection.- Overrides:
closein classFileSystem- Throws:
DataException
-
readFile
Reads the file in the specified DropBox folder. To specify a nested folder, use "/" as separator.
Example:
- readFile("folderOne", "fileName") - reads the file in folderOne folder
- readFile("folderOne/folderTwo", "fileName") - reads the file in folderTwo which is under folderOne
- Parameters:
folderName- the name of the folderfileName- the file name to read.- Returns:
- an
InputStream - Throws:
Throwable
-
readFile
Reads the file in the DropBox root folder.- Parameters:
fileName- the file name to read.- Returns:
- an
InputStream - Throws:
Throwable
-
listFolder
Returns an list of all DropBox files and folders belonging to thefolderName. To specify a nested folder, use "/" as separator.
Example:
- listFolder("folderOne") - reads the contents in folderOne which is under the root folder
- listFolder("folderOne/folderTwo") - reads the contents in folderTwo which is under folderOne
- Parameters:
folderName- the folder name to read- Returns:
- the contents as a
List - Throws:
Throwable
-
listRootFolder
Returns aListof all DropBox files and folders in the root folder.- Returns:
- the contents as a
List - Throws:
Throwable
-
writeFile
Writes the file to the DropBox File System. Throws aDataExceptionif the file already exists.- Parameters:
fileName- the name of the file- Returns:
- an
OutputStreamfor writing - Throws:
Throwable
-
writeFile
Writes the file to the specified folder in the DropBox File System. Throws aDataExceptionif the file already exists.- Parameters:
folderName- the destination folder of the file being writtenfileName- the name of the file- Returns:
- an
OutputStreamfor writing - Throws:
Throwable
-