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 int |
DEFAULT_RECEIVE_BUFFER_SIZE |
static int |
DEFAULT_SEND_BUFFER_SIZE |
static int |
ERROR |
protected FileSystem |
fileSystem |
protected 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 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 String |
SCP_COMMAND_PREFIX
Command prefix used to identify SCP commands
|
static int |
WARNING |
log| Constructor and Description |
|---|
ScpHelper(Session session,
InputStream in,
OutputStream out,
FileSystem fileSystem,
ScpFileOpener opener,
ScpTransferEventListener eventListener) |
| Modifier and Type | Method and Description |
|---|---|
void |
ack() |
static String |
getExitStatusName(Integer exitStatus) |
static String |
getOctalPermissions(Collection<PosixFilePermission> perms) |
static String |
getOctalPermissions(Path path,
LinkOption... options) |
Session |
getSession() |
static Set<PosixFilePermission> |
parseOctalPermissions(String str) |
int |
readAck(boolean canEof) |
String |
readLine() |
String |
readLine(boolean canEof) |
void |
receive(Path local,
boolean recursive,
boolean shouldBeDir,
boolean preserve,
int bufferSize) |
protected void |
receive(ScpReceiveLineHandler handler) |
void |
receiveDir(String header,
Path local,
ScpTimestamp time,
boolean preserve,
int bufferSize) |
void |
receiveFile(String header,
Path local,
ScpTimestamp time,
boolean preserve,
int bufferSize) |
void |
receiveFileStream(OutputStream local,
int bufferSize) |
void |
receiveStream(String header,
ScpTargetStreamResolver resolver,
ScpTimestamp time,
boolean preserve,
int bufferSize) |
Path |
resolveLocalPath(String commandPath) |
Path |
resolveLocalPath(String basedir,
String subpath) |
void |
send(Collection<String> paths,
boolean recursive,
boolean preserve,
int bufferSize) |
protected void |
send(Path local,
boolean recursive,
boolean preserve,
int bufferSize,
LinkOption... options) |
void |
sendDir(Path local,
boolean preserve,
int bufferSize) |
static <O extends OutputStream> |
sendError(O out,
String message) |
protected void |
sendError(String message) |
void |
sendFile(Path local,
boolean preserve,
int bufferSize) |
void |
sendPaths(Collection<? extends Path> paths,
boolean recursive,
boolean preserve,
int bufferSize) |
protected void |
sendResponseMessage(int level,
String message) |
static <O extends OutputStream> |
sendResponseMessage(O out,
int level,
String message) |
void |
sendStream(ScpSourceStreamResolver resolver,
boolean preserve,
int bufferSize) |
static <O extends OutputStream> |
sendWarning(O out,
String message) |
protected void |
sendWarning(String message) |
static Set<PosixFilePermission> |
setOctalPermissions(Path path,
String str) |
String |
toString() |
protected void |
updateFileProperties(Path file,
Set<PosixFilePermission> perms,
ScpTimestamp time) |
protected void |
validateAckReplyCode(String command,
Object location,
int replyCode,
boolean eofAllowed) |
protected void |
validateCommandStatusCode(String command,
Object location,
int statusCode,
boolean eofAllowed) |
protected void |
validateOperationReadyCode(String command,
Object location,
int readyCode,
boolean eofAllowed) |
getSimplifiedLoggerpublic static final 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
protected final InputStream in
protected final OutputStream out
protected final FileSystem fileSystem
protected final ScpFileOpener opener
protected final ScpTransferEventListener listener
public ScpHelper(Session session, InputStream in, OutputStream out, FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)
public Session getSession()
getSession in interface SessionHolder<Session>public void receiveFileStream(OutputStream local, int bufferSize) throws IOException
IOExceptionpublic void receive(Path local, boolean recursive, boolean shouldBeDir, boolean preserve, int bufferSize) throws IOException
IOExceptionprotected void receive(ScpReceiveLineHandler handler) throws IOException
IOExceptionpublic void receiveDir(String header, Path local, ScpTimestamp time, boolean preserve, int bufferSize) throws IOException
IOExceptionpublic void receiveFile(String header, Path local, ScpTimestamp time, boolean preserve, int bufferSize) throws IOException
IOExceptionpublic void receiveStream(String header, ScpTargetStreamResolver resolver, ScpTimestamp time, boolean preserve, int bufferSize) throws IOException
IOExceptionprotected void updateFileProperties(Path file, Set<PosixFilePermission> perms, ScpTimestamp time) throws IOException
IOExceptionpublic String readLine() throws IOException
IOExceptionpublic String readLine(boolean canEof) throws IOException
IOExceptionpublic void send(Collection<String> paths, boolean recursive, boolean preserve, int bufferSize) throws IOException
IOExceptionpublic void sendPaths(Collection<? extends Path> paths, boolean recursive, boolean preserve, int bufferSize) throws IOException
IOExceptionprotected void send(Path local, boolean recursive, boolean preserve, int bufferSize, LinkOption... options) throws IOException
IOExceptionpublic Path resolveLocalPath(String basedir, String subpath) throws IOException
IOExceptionpublic Path resolveLocalPath(String commandPath) throws IOException, InvalidPathException
commandPath - The command path using the local file separatorPathIOException - If failed to resolve the pathInvalidPathException - If invalid local path valuepublic void sendFile(Path local, boolean preserve, int bufferSize) throws IOException
IOExceptionpublic void sendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize) throws IOException
IOExceptionprotected void validateOperationReadyCode(String command, Object location, int readyCode, boolean eofAllowed) throws IOException
IOExceptionprotected void validateAckReplyCode(String command, Object location, int replyCode, boolean eofAllowed) throws IOException
IOExceptionprotected void validateCommandStatusCode(String command, Object location, int statusCode, boolean eofAllowed) throws IOException
IOExceptionpublic void sendDir(Path local, boolean preserve, int bufferSize) throws IOException
IOExceptionpublic static String getOctalPermissions(Path path, LinkOption... options) throws IOException
IOExceptionpublic static String getOctalPermissions(Collection<PosixFilePermission> perms)
public static Set<PosixFilePermission> setOctalPermissions(Path path, String str) throws IOException
IOExceptionpublic static Set<PosixFilePermission> parseOctalPermissions(String str)
protected void sendWarning(String message) throws IOException
IOExceptionprotected void sendError(String message) throws IOException
IOExceptionprotected void sendResponseMessage(int level,
String message)
throws IOException
IOExceptionpublic static <O extends OutputStream> O sendWarning(O out, String message) throws IOException
IOExceptionpublic static <O extends OutputStream> O sendError(O out, String message) throws IOException
IOExceptionpublic static <O extends OutputStream> O sendResponseMessage(O out, int level, String message) throws IOException
IOExceptionpublic void ack()
throws IOException
IOExceptionpublic int readAck(boolean canEof)
throws IOException
IOExceptionCopyright © 2008–2017 The Apache Software Foundation. All rights reserved.