public class ScpHelper extends AbstractLoggingBean implements SessionHolder<Session>
| Modifier and Type | Field and Description |
|---|---|
protected java.nio.charset.Charset |
csIn |
protected java.nio.charset.Charset |
csOut |
static int |
DEFAULT_COPY_BUFFER_SIZE
Default size (in bytes) of send / receive buffer size
|
static int |
DEFAULT_RECEIVE_BUFFER_SIZE |
static int |
DEFAULT_SEND_BUFFER_SIZE |
protected java.nio.file.FileSystem |
fileSystem |
protected java.io.InputStream |
in |
protected ScpTransferEventListener |
listener |
static int |
MIN_COPY_BUFFER_SIZE
The minimum size for sending / receiving files
|
static int |
MIN_RECEIVE_BUFFER_SIZE |
static int |
MIN_SEND_BUFFER_SIZE |
protected ScpFileOpener |
opener |
protected java.io.OutputStream |
out |
static java.lang.String |
SCP_COMMAND_PREFIX
Command prefix used to identify SCP commands
|
private Session |
sessionInstance |
log| Constructor and Description |
|---|
ScpHelper(Session session,
java.io.InputStream in,
java.nio.charset.Charset csIn,
java.io.OutputStream out,
java.nio.charset.Charset csOut,
java.nio.file.FileSystem fileSystem,
ScpFileOpener opener,
ScpTransferEventListener eventListener) |
ScpHelper(Session session,
java.io.InputStream in,
java.io.OutputStream out,
java.nio.file.FileSystem fileSystem,
ScpFileOpener opener,
ScpTransferEventListener eventListener) |
| Modifier and Type | Method and Description |
|---|---|
Session |
getSession() |
ScpAckInfo |
readAck(boolean canEof) |
java.lang.String |
readLine() |
java.lang.String |
readLine(boolean canEof) |
void |
receive(java.nio.file.Path local,
boolean recursive,
boolean shouldBeDir,
boolean preserve,
int bufferSize) |
protected void |
receive(ScpReceiveLineHandler handler)
Reads command line(s) and invokes the handler until EOF or and "E" command is received
|
void |
receiveDir(java.lang.String header,
java.nio.file.Path local,
ScpTimestampCommandDetails time,
boolean preserve,
int bufferSize) |
void |
receiveFile(java.lang.String header,
java.nio.file.Path local,
ScpTimestampCommandDetails time,
boolean preserve,
int bufferSize) |
void |
receiveFileStream(java.io.OutputStream local,
int bufferSize) |
protected int |
receiveNextCmd() |
void |
receiveStream(java.lang.String header,
ScpTargetStreamResolver resolver,
ScpTimestampCommandDetails time,
boolean preserve,
int bufferSize) |
java.nio.file.Path |
resolveLocalPath(java.lang.String commandPath) |
java.nio.file.Path |
resolveLocalPath(java.lang.String basedir,
java.lang.String subpath) |
void |
send(java.util.Collection<java.lang.String> paths,
boolean recursive,
boolean preserve,
int bufferSize) |
protected void |
send(java.nio.file.Path local,
boolean recursive,
boolean preserve,
int bufferSize,
java.nio.file.LinkOption... options) |
protected ScpAckInfo |
sendAcknowledgedCommand(java.lang.String cmd) |
void |
sendDir(java.nio.file.Path local,
boolean preserve,
int bufferSize) |
protected void |
sendError(java.lang.String message) |
void |
sendFile(java.nio.file.Path local,
boolean preserve,
int bufferSize) |
void |
sendOk() |
void |
sendPaths(java.util.Collection<? extends java.nio.file.Path> paths,
boolean recursive,
boolean preserve,
int bufferSize) |
protected void |
sendResponseMessage(int level,
java.lang.String message) |
void |
sendStream(ScpSourceStreamResolver resolver,
boolean preserve,
int bufferSize) |
protected void |
sendWarning(java.lang.String message) |
java.lang.String |
toString() |
protected void |
validateAckReplyCode(java.lang.String command,
java.lang.Object location,
ScpAckInfo ackInfo) |
protected void |
validateCommandStatusCode(java.lang.String command,
java.lang.Object location,
ScpAckInfo ackInfo,
boolean eofAllowed) |
protected void |
validateFileOperationAckReplyCode(java.lang.String command,
Session session,
ScpTransferEventListener.FileOperation op,
java.nio.file.Path file,
long fileSize,
java.util.Set<java.nio.file.attribute.PosixFilePermission> perms,
ScpAckInfo ackInfo) |
protected void |
validateOperationReadyCode(java.lang.String command,
java.lang.Object location,
ScpAckInfo ackInfo) |
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetSessionContextpublic static final java.lang.String SCP_COMMAND_PREFIX
public static final int DEFAULT_COPY_BUFFER_SIZE
public static final int DEFAULT_RECEIVE_BUFFER_SIZE
public static final int DEFAULT_SEND_BUFFER_SIZE
public static final int MIN_COPY_BUFFER_SIZE
public static final int MIN_RECEIVE_BUFFER_SIZE
public static final int MIN_SEND_BUFFER_SIZE
protected final java.io.InputStream in
protected final java.nio.charset.Charset csIn
protected final java.io.OutputStream out
protected final java.nio.charset.Charset csOut
protected final java.nio.file.FileSystem fileSystem
protected final ScpFileOpener opener
protected final ScpTransferEventListener listener
private final Session sessionInstance
public ScpHelper(Session session, java.io.InputStream in, java.io.OutputStream out, java.nio.file.FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)
public ScpHelper(Session session, java.io.InputStream in, java.nio.charset.Charset csIn, java.io.OutputStream out, java.nio.charset.Charset csOut, java.nio.file.FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)
public Session getSession()
getSession in interface SessionHolder<Session>public void receiveFileStream(java.io.OutputStream local,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionpublic void receive(java.nio.file.Path local,
boolean recursive,
boolean shouldBeDir,
boolean preserve,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionprotected void receive(ScpReceiveLineHandler handler) throws java.io.IOException
handler - The ScpReceiveLineHandler to invoke when a command has been readjava.io.IOException - If failed to read/writeprotected int receiveNextCmd()
throws java.io.IOException
java.io.IOExceptionpublic void receiveDir(java.lang.String header,
java.nio.file.Path local,
ScpTimestampCommandDetails time,
boolean preserve,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionpublic void receiveFile(java.lang.String header,
java.nio.file.Path local,
ScpTimestampCommandDetails time,
boolean preserve,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionpublic void receiveStream(java.lang.String header,
ScpTargetStreamResolver resolver,
ScpTimestampCommandDetails time,
boolean preserve,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String readLine()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String readLine(boolean canEof)
throws java.io.IOException
java.io.IOExceptionpublic void send(java.util.Collection<java.lang.String> paths,
boolean recursive,
boolean preserve,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionpublic void sendPaths(java.util.Collection<? extends java.nio.file.Path> paths,
boolean recursive,
boolean preserve,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionprotected void send(java.nio.file.Path local,
boolean recursive,
boolean preserve,
int bufferSize,
java.nio.file.LinkOption... options)
throws java.io.IOException
java.io.IOExceptionpublic java.nio.file.Path resolveLocalPath(java.lang.String basedir,
java.lang.String subpath)
throws java.io.IOException
java.io.IOExceptionpublic java.nio.file.Path resolveLocalPath(java.lang.String commandPath)
throws java.io.IOException,
java.nio.file.InvalidPathException
commandPath - The command path using the local file separatorPathjava.io.IOException - If failed to resolve the pathjava.nio.file.InvalidPathException - If invalid local path valuepublic void sendFile(java.nio.file.Path local,
boolean preserve,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionpublic void sendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize) throws java.io.IOException
java.io.IOExceptionprotected void validateOperationReadyCode(java.lang.String command,
java.lang.Object location,
ScpAckInfo ackInfo)
throws java.io.IOException
java.io.IOExceptionprotected void validateFileOperationAckReplyCode(java.lang.String command,
Session session,
ScpTransferEventListener.FileOperation op,
java.nio.file.Path file,
long fileSize,
java.util.Set<java.nio.file.attribute.PosixFilePermission> perms,
ScpAckInfo ackInfo)
throws java.io.IOException
java.io.IOExceptionprotected void validateAckReplyCode(java.lang.String command,
java.lang.Object location,
ScpAckInfo ackInfo)
throws java.io.IOException
java.io.IOExceptionprotected void validateCommandStatusCode(java.lang.String command,
java.lang.Object location,
ScpAckInfo ackInfo,
boolean eofAllowed)
throws java.io.IOException
java.io.IOExceptionpublic void sendDir(java.nio.file.Path local,
boolean preserve,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionprotected ScpAckInfo sendAcknowledgedCommand(java.lang.String cmd) throws java.io.IOException
java.io.IOExceptionpublic void sendOk()
throws java.io.IOException
java.io.IOExceptionprotected void sendWarning(java.lang.String message)
throws java.io.IOException
java.io.IOExceptionprotected void sendError(java.lang.String message)
throws java.io.IOException
java.io.IOExceptionprotected void sendResponseMessage(int level,
java.lang.String message)
throws java.io.IOException
java.io.IOExceptionpublic ScpAckInfo readAck(boolean canEof) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object