public class FileRepoTransport extends AbstractRepoTransport
Constructor and Description |
---|
FileRepoTransport() |
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 File |
getFile(String path) |
byte[] |
getFileData(String path,
long offset,
int length)
Get the binary file data at the given
offset and with the given length . |
protected LocalRepoManager |
getLocalRepoManager() |
protected File |
getPathPrefixFile() |
byte[] |
getPublicKey() |
RepoFileDTO |
getRepoFileDTO(String path) |
RepositoryDTO |
getRepositoryDTO() |
UUID |
getRepositoryId()
Get the repository's unique ID.
|
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 FileRepoTransport()
public void close()
close
in interface RepoTransport
close
in class AbstractRepoTransport
public UUID getRepositoryId()
RepoTransport
public byte[] getPublicKey()
public void requestRepoConnection(byte[] publicKey)
RepoTransport
remoteRepositoryId
.publicKey
- the public key of the client-repository which requests the connection.public RepositoryDTO getRepositoryDTO()
public ChangeSetDTO getChangeSetDTO(boolean localSync)
protected File getPathPrefixFile()
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).
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)
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.
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)
protected LocalRepoManager getLocalRepoManager()
protected URL determineRemoteRootWithoutPathPrefix()
determineRemoteRootWithoutPathPrefix
in class AbstractRepoTransport
protected File getFile(String path)
path
- the prefixed path (relative to the real root).null
.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.
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.
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)
.
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)
public void endSyncFromRepository()
public void endSyncToRepository(long fromLocalRevision)
Copyright © 2013-2014. All Rights Reserved.