public class RestRepoTransport extends AbstractRepoTransport implements CredentialsProvider
Constructor and Description |
---|
RestRepoTransport() |
Modifier and Type | Method and Description |
---|---|
void |
beginPutFile(String path)
Begins a file transfer to this
RepoTransport . |
void |
close() |
void |
copy(String fromPath,
String toPath) |
void |
delete(String path)
Deletes the file (or directory) specified by
path . |
protected URL |
determineRemoteRootWithoutPathPrefix() |
void |
endPutFile(String path,
Date lastModified,
long length,
String sha1) |
void |
endSyncFromRepository() |
void |
endSyncToRepository(long fromLocalRevision) |
ChangeSetDTO |
getChangeSetDTO(boolean localSync) |
protected CloudStoreRESTClient |
getClient() |
protected DynamicX509TrustManagerCallback |
getDynamicX509TrustManagerCallback() |
byte[] |
getFileData(String path,
long offset,
int length)
Get the binary file data at the given
offset and with the given length . |
String |
getPassword() |
protected String |
getPathAfterBaseURL() |
byte[] |
getPublicKey() |
RepoFileDTO |
getRepoFileDTO(String path) |
RepositoryDTO |
getRepositoryDTO() |
UUID |
getRepositoryId()
Get the repository's unique ID.
|
protected String |
getRepositoryName() |
String |
getUserName() |
void |
makeDirectory(String path,
Date lastModified)
Creates the specified directory (including all parent-directories).
|
void |
makeSymlink(String path,
String target,
Date lastModified) |
void |
move(String fromPath,
String toPath) |
void |
putFileData(String path,
long offset,
byte[] fileData)
Write a block of binary data into the file.
|
void |
requestRepoConnection(byte[] publicKey)
Request to connect this repository with the remote repository identified by the given
remoteRepositoryId . |
finalize, getClientRepositoryId, getClientRepositoryIdOrFail, getPathPrefix, getRemoteRoot, getRemoteRootWithoutPathPrefix, getRepoTransportFactory, isPathUnderPathPrefix, prefixPath, setClientRepositoryId, setRemoteRoot, setRepoTransportFactory, unprefixPath
public RestRepoTransport()
protected DynamicX509TrustManagerCallback getDynamicX509TrustManagerCallback()
public UUID getRepositoryId()
RepoTransport
getRepositoryId
in interface RepoTransport
public byte[] getPublicKey()
getPublicKey
in interface RepoTransport
public RepositoryDTO getRepositoryDTO()
getRepositoryDTO
in interface RepoTransport
public void requestRepoConnection(byte[] publicKey)
RepoTransport
remoteRepositoryId
.requestRepoConnection
in interface RepoTransport
publicKey
- the public key of the client-repository which requests the connection.public void close()
close
in interface RepoTransport
close
in class AbstractRepoTransport
public ChangeSetDTO getChangeSetDTO(boolean localSync)
getChangeSetDTO
in interface RepoTransport
public void makeDirectory(String path, Date lastModified)
RepoTransport
If the directory already exists, this is a noop.
If there is any obstruction in the way of this path (e.g. a normal file), it is moved away (renamed or simply deleted depending on the conflict resolution strategy).
makeDirectory
in interface RepoTransport
path
- the path of the directory. Must not be null
. No matter which operating system is used,
the separation-character is always '/'. This path may start with a "/", but there is no difference, if it does:
It is always relative to the repository's root directory.lastModified
- the last-modified-timestamp the newly created
directory will be set to.
May be null
(in which case the lastModified
property is not touched). This applies only to the
actual directory and not to the parent-directories! The parent-directories' lastModified
properties are never
touched - even if the parent-directories are newly created.public void makeSymlink(String path, String target, Date lastModified)
makeSymlink
in interface RepoTransport
public void copy(String fromPath, String toPath)
copy
in interface RepoTransport
public void move(String fromPath, String toPath)
move
in interface RepoTransport
public void delete(String path)
RepoTransport
path
.
If there is no such file (or directory), this method is a noop.
If path
denotes a directory, all its children (if there are) are deleted recursively.
delete
in interface RepoTransport
path
- the path of the file (or directory) to be deleted. Must not be null
. No matter which
operating system is used, the separation-character is always '/'. This path may start with a "/", but there is no
difference, if it does: It is always relative to the repository's root directory.public RepoFileDTO getRepoFileDTO(String path)
getRepoFileDTO
in interface RepoTransport
public byte[] getFileData(String path, long offset, int length)
RepoTransport
offset
and with the given length
.
If the file was modified/deleted, this method should not fail, but simply return null
or a result being shorter than the length
specified.
getFileData
in interface RepoTransport
path
- the path of the file. Must not be null
. No matter which operating system is used,
the separation-character is always '/'. This path may start with a "/", but there is no difference, if it does:
It is always relative to the repository's root directory.offset
- the offset of the first byte to be read (0-based).length
- the length of the data to be read. -1 to read from offset
to the end of the file.public void beginPutFile(String path)
RepoTransport
RepoTransport
.
Usually, this method creates the specified file in the file system (if necessary with parent-directories)
and in the database. But this operation may be deferred until RepoTransport.endPutFile(String, Date, long, String)
.
If the file is immediately created, it should not be synchronised to any other repository, yet! It should
be ignored, until RepoTransport.endPutFile(String, Date, long, String)
was called for it.
In normal operation, zero or more invocations of RepoTransport.putFileData(String, long, byte[])
and
finally one invocation of RepoTransport.endPutFile(String, Date, long, String)
follow this method. However, this is not
guaranteed and the file transfer may be interrupted. If it is resumed, later this method is called again,
without RepoTransport.endPutFile(String, Date, long, String)
ever having been called inbetween.
beginPutFile
in interface RepoTransport
path
- the path of the file. Must not be null
. No matter which operating system is used,
the separation-character is always '/'. This path may start with a "/", but there is no difference, if it does:
It is always relative to the repository's root directory.RepoTransport.putFileData(String, long, byte[])
,
RepoTransport.endPutFile(String, Date, long, String)
public void putFileData(String path, long offset, byte[] fileData)
RepoTransport
This method may only be called after RepoTransport.beginPutFile(String)
and before RepoTransport.endPutFile(String, Date, long, String)
.
putFileData
in interface RepoTransport
offset
- the 0-based position in the file at which the block should be written.RepoTransport.beginPutFile(String)
,
RepoTransport.endPutFile(String, Date, long, String)
public void endPutFile(String path, Date lastModified, long length, String sha1)
endPutFile
in interface RepoTransport
public void endSyncFromRepository()
endSyncFromRepository
in interface RepoTransport
public void endSyncToRepository(long fromLocalRevision)
endSyncToRepository
in interface RepoTransport
public String getUserName()
getUserName
in interface CredentialsProvider
public String getPassword()
getPassword
in interface CredentialsProvider
protected CloudStoreRESTClient getClient()
protected URL determineRemoteRootWithoutPathPrefix()
determineRemoteRootWithoutPathPrefix
in class AbstractRepoTransport
protected String getRepositoryName()
protected String getPathAfterBaseURL()
Copyright © 2013-2014. All Rights Reserved.