public class ArtisynthDataManager
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.io.File |
DEFAULT_LOCAL_ROOT
Default directory for storing downloaded files
|
| Constructor and Description |
|---|
ArtisynthDataManager() |
ArtisynthDataManager(java.lang.String remoteUri)
Creates a data manager capable of transfering files to/from a remote folder or server
|
ArtisynthDataManager(java.lang.String remoteUri,
java.io.File localRoot)
Creates a data manager capable of transfering files to/from a remote folder or server
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAuthenticator(URIxMatcher matcher,
org.apache.commons.vfs2.UserAuthenticator auth)
Adds an authenticator that can respond to domain/username/password requests.
|
Cryptor |
getCryptor()
Gets the current en/de-cryptor to be used for storing passwords.
|
java.io.File |
getFile(java.lang.String filename)
Get file with path relative to storage root.
|
java.io.File |
getFile(java.lang.String src,
java.lang.String dst)
Get file with path relative to storage root.
|
FileManager |
getFileManager()
Get underlying file manager
|
java.io.File |
getLocalRoot()
Gets the local directory containing downloaded files
|
java.io.File |
getPackageRelativeFile(java.lang.Object obj,
java.lang.String filename)
Returns a file retrieved from the data storage server, specified relative to
a given package.
|
java.io.File |
getPackageRelativeFile(java.lang.Package pkg,
java.lang.String filename)
Returns a file retrieved from the data storage server, specified relative to
a given package.
|
URIx |
getRemoteRoot()
Gets the root directory of the remove filesystem
|
void |
loadConfig(java.io.File configFile)
Loads configuration from a JSON file
|
void |
putFile(java.io.File source,
java.lang.String filename)
Upload a file with path relative to storage root
|
void |
putPackageRelativeFile(java.io.File source,
java.lang.Object obj,
java.lang.String dest)
Uploads a file to the data storage server, at a location specified relative to
a given package.
|
void |
putPackageRelativeFile(java.io.File source,
java.lang.Package pkg,
java.lang.String dest)
Uploads a file to the data storage server, specified relative to
a given package.
|
void |
setCredentials(java.lang.String username,
java.lang.String password)
Set username and password credentials.
|
void |
setCryptor(Cryptor cryptor)
Set an en/de-cryptor to be used for storing passwords
|
void |
setEncryptedCredentials(java.lang.String username,
java.lang.String encryptedPassword)
Set the username and password credentials.
|
void |
setLocalRoot(java.io.File file)
Sets the local directory to download files to
|
void |
setRemoteRoot(java.lang.String remote)
Sets the root directory of the remote filesystem
|
void |
setRemoteRoot(java.net.URI remote)
Sets the root directory of the remote filesystem
|
void |
setRemoteRoot(URIx remote)
Sets the root directory of the remote filesystem
|
public static final java.io.File DEFAULT_LOCAL_ROOT
public ArtisynthDataManager()
public ArtisynthDataManager(java.lang.String remoteUri)
remoteUri - URI for remote rootpublic ArtisynthDataManager(java.lang.String remoteUri,
java.io.File localRoot)
remoteUri - URI for remote rootlocalRoot - local directory to use for storing filespublic void loadConfig(java.io.File configFile)
Keys: remote_uri, local_dir, username, password, encrypted_password, cipher, cipher_key (base64)
{
"remote_uri": "davs://research.hct.ece.ubc.ca/owncloud/remote.php/webdav/",
"local_dir": "tmp/.cache/data/",
"username": "artisynth_user",
"password": "artisynth_password",
}
The encrypted password is assumed encrypted with the provided cipher/key. If no cipher is provided,
a default is assumed. An encrypted password takes precedence over a plaintext one if both are
provided.configFile - configuration filepublic void setRemoteRoot(java.net.URI remote)
remote - remote file system root directorypublic void setRemoteRoot(URIx remote)
remote - remote file system root directorypublic void setRemoteRoot(java.lang.String remote)
remote - remote file system root directorypublic URIx getRemoteRoot()
public void setLocalRoot(java.io.File file)
file - local directory for downloading filespublic java.io.File getLocalRoot()
public void setCryptor(Cryptor cryptor)
cryptor - en/de-cryptorpublic Cryptor getCryptor()
public void setCredentials(java.lang.String username,
java.lang.String password)
username - user namepassword - plaintext passwordpublic void setEncryptedCredentials(java.lang.String username,
java.lang.String encryptedPassword)
setCryptor(Cryptor)). This allows
for some obfuscation of passwords.username - user nameencryptedPassword - encrypted passwordpublic void addAuthenticator(URIxMatcher matcher, org.apache.commons.vfs2.UserAuthenticator auth)
matcher - object that checks whether a supplied URI matches a given set of criteriaauth - the authenticator objectpublic java.io.File getPackageRelativeFile(java.lang.Object obj,
java.lang.String filename)
The package is determined from obj, either directly,
if obj is an instance of Package, or by
determining the package that the supplied resource belongs to.
obj - object used to determine the packagefilename - path relative to the package directorypublic java.io.File getPackageRelativeFile(java.lang.Package pkg,
java.lang.String filename)
pkg - package used for determining path on storage serverfilename - path relative to the package directorypublic java.io.File getFile(java.lang.String filename)
filename - file path name relative to storage rootpublic java.io.File getFile(java.lang.String src,
java.lang.String dst)
src - file path name relative to storage rootdst - local destinationpublic void putPackageRelativeFile(java.io.File source,
java.lang.Object obj,
java.lang.String dest)
throws java.io.IOException
The package is determined from obj, either directly,
if obj is an instance of Package, or by
determining the package that the supplied resource belongs to.
source - file to uploadobj - object used to determine the packagedest - path relative to the package directoryjava.io.IOException - if upload fails, such as invalid destination or insufficient privilegespublic void putPackageRelativeFile(java.io.File source,
java.lang.Package pkg,
java.lang.String dest)
throws java.io.IOException
source - file to uploadpkg - package used for determining path on storage serverdest - path relative to the package directoryjava.io.IOException - if upload fails, such as invalid destination or insufficient privilegespublic void putFile(java.io.File source,
java.lang.String filename)
throws java.io.IOException
source - file to uploadfilename - destinationjava.io.IOException - if upload fails, such as invalid destination or insufficient privilegespublic FileManager getFileManager()