public class ScpHelper extends AbstractLoggingBean implements SessionHolder<Session>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_COPY_BUFFER_SIZE
Default size (in bytes) of send / receive buffer size
|
static java.lang.String |
DEFAULT_DIR_OCTAL_PERMISSIONS |
static java.lang.String |
DEFAULT_FILE_OCTAL_PERMISSIONS |
static int |
DEFAULT_RECEIVE_BUFFER_SIZE |
static int |
DEFAULT_SEND_BUFFER_SIZE |
static int |
ERROR |
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 |
static int |
OK |
protected ScpFileOpener |
opener |
protected java.io.OutputStream |
out |
static int |
S_IRGRP |
static int |
S_IROTH |
static int |
S_IRUSR |
static int |
S_IWGRP |
static int |
S_IWOTH |
static int |
S_IWUSR |
static int |
S_IXGRP |
static int |
S_IXOTH |
static int |
S_IXUSR |
static java.lang.String |
SCP_COMMAND_PREFIX
Command prefix used to identify SCP commands
|
private Session |
sessionInstance |
static int |
WARNING |
log
Constructor and Description |
---|
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 |
---|---|
void |
ack() |
static java.lang.String |
getExitStatusName(java.lang.Integer exitStatus) |
static java.lang.String |
getOctalPermissions(java.util.Collection<java.nio.file.attribute.PosixFilePermission> perms) |
Session |
getSession() |
static java.util.Set<java.nio.file.attribute.PosixFilePermission> |
parseOctalPermissions(java.lang.String str) |
int |
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) |
void |
receiveDir(java.lang.String header,
java.nio.file.Path local,
ScpTimestamp time,
boolean preserve,
int bufferSize) |
void |
receiveFile(java.lang.String header,
java.nio.file.Path local,
ScpTimestamp time,
boolean preserve,
int bufferSize) |
void |
receiveFileStream(java.io.OutputStream local,
int bufferSize) |
void |
receiveStream(java.lang.String header,
ScpTargetStreamResolver resolver,
ScpTimestamp 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) |
void |
sendDir(java.nio.file.Path local,
boolean preserve,
int bufferSize) |
static <O extends java.io.OutputStream> |
sendError(O out,
java.lang.String message) |
protected void |
sendError(java.lang.String message) |
void |
sendFile(java.nio.file.Path local,
boolean preserve,
int bufferSize) |
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) |
static <O extends java.io.OutputStream> |
sendResponseMessage(O out,
int level,
java.lang.String message) |
void |
sendStream(ScpSourceStreamResolver resolver,
boolean preserve,
int bufferSize) |
static <O extends java.io.OutputStream> |
sendWarning(O out,
java.lang.String message) |
protected void |
sendWarning(java.lang.String message) |
java.lang.String |
toString() |
protected void |
validateAckReplyCode(java.lang.String command,
java.lang.Object location,
int replyCode,
boolean eofAllowed) |
protected void |
validateCommandStatusCode(java.lang.String command,
java.lang.Object location,
int statusCode,
boolean eofAllowed) |
protected void |
validateOperationReadyCode(java.lang.String command,
java.lang.Object location,
int readyCode,
boolean eofAllowed) |
getSimplifiedLogger
public static final java.lang.String SCP_COMMAND_PREFIX
public static final int OK
public static final int WARNING
public static final int ERROR
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
public static final int S_IRUSR
public static final int S_IWUSR
public static final int S_IXUSR
public static final int S_IRGRP
public static final int S_IWGRP
public static final int S_IXGRP
public static final int S_IROTH
public static final int S_IWOTH
public static final int S_IXOTH
public static final java.lang.String DEFAULT_DIR_OCTAL_PERMISSIONS
public static final java.lang.String DEFAULT_FILE_OCTAL_PERMISSIONS
protected final java.io.InputStream in
protected final java.io.OutputStream out
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 Session getSession()
getSession
in interface SessionHolder<Session>
public void receiveFileStream(java.io.OutputStream local, int bufferSize) throws java.io.IOException
java.io.IOException
public void receive(java.nio.file.Path local, boolean recursive, boolean shouldBeDir, boolean preserve, int bufferSize) throws java.io.IOException
java.io.IOException
protected void receive(ScpReceiveLineHandler handler) throws java.io.IOException
java.io.IOException
public void receiveDir(java.lang.String header, java.nio.file.Path local, ScpTimestamp time, boolean preserve, int bufferSize) throws java.io.IOException
java.io.IOException
public void receiveFile(java.lang.String header, java.nio.file.Path local, ScpTimestamp time, boolean preserve, int bufferSize) throws java.io.IOException
java.io.IOException
public void receiveStream(java.lang.String header, ScpTargetStreamResolver resolver, ScpTimestamp time, boolean preserve, int bufferSize) throws java.io.IOException
java.io.IOException
public java.lang.String readLine() throws java.io.IOException
java.io.IOException
public java.lang.String readLine(boolean canEof) throws java.io.IOException
java.io.IOException
public void send(java.util.Collection<java.lang.String> paths, boolean recursive, boolean preserve, int bufferSize) throws java.io.IOException
java.io.IOException
public void sendPaths(java.util.Collection<? extends java.nio.file.Path> paths, boolean recursive, boolean preserve, int bufferSize) throws java.io.IOException
java.io.IOException
protected void send(java.nio.file.Path local, boolean recursive, boolean preserve, int bufferSize, java.nio.file.LinkOption... options) throws java.io.IOException
java.io.IOException
public java.nio.file.Path resolveLocalPath(java.lang.String basedir, java.lang.String subpath) throws java.io.IOException
java.io.IOException
public 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 separatorPath
java.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.IOException
public void sendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize) throws java.io.IOException
java.io.IOException
protected void validateOperationReadyCode(java.lang.String command, java.lang.Object location, int readyCode, boolean eofAllowed) throws java.io.IOException
java.io.IOException
protected void validateAckReplyCode(java.lang.String command, java.lang.Object location, int replyCode, boolean eofAllowed) throws java.io.IOException
java.io.IOException
protected void validateCommandStatusCode(java.lang.String command, java.lang.Object location, int statusCode, boolean eofAllowed) throws java.io.IOException
java.io.IOException
public void sendDir(java.nio.file.Path local, boolean preserve, int bufferSize) throws java.io.IOException
java.io.IOException
public static java.lang.String getOctalPermissions(java.util.Collection<java.nio.file.attribute.PosixFilePermission> perms)
public static java.util.Set<java.nio.file.attribute.PosixFilePermission> parseOctalPermissions(java.lang.String str)
protected void sendWarning(java.lang.String message) throws java.io.IOException
java.io.IOException
protected void sendError(java.lang.String message) throws java.io.IOException
java.io.IOException
protected void sendResponseMessage(int level, java.lang.String message) throws java.io.IOException
java.io.IOException
public static <O extends java.io.OutputStream> O sendWarning(O out, java.lang.String message) throws java.io.IOException
java.io.IOException
public static <O extends java.io.OutputStream> O sendError(O out, java.lang.String message) throws java.io.IOException
java.io.IOException
public static <O extends java.io.OutputStream> O sendResponseMessage(O out, int level, java.lang.String message) throws java.io.IOException
java.io.IOException
public static java.lang.String getExitStatusName(java.lang.Integer exitStatus)
public void ack() throws java.io.IOException
java.io.IOException
public int readAck(boolean canEof) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object