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 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,
ScpTransferEventListener eventListener) |
Modifier and Type | Method and Description |
---|---|
void |
ack() |
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) |
public 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 FileSystem fileSystem
protected final InputStream in
protected final OutputStream out
protected final ScpTransferEventListener listener
public ScpHelper(Session session, InputStream in, OutputStream out, FileSystem fileSystem, ScpTransferEventListener eventListener)
public Session getSession()
getSession
in interface SessionHolder<Session>
public void receiveFileStream(OutputStream local, int bufferSize) throws IOException
IOException
public void receive(Path local, boolean recursive, boolean shouldBeDir, boolean preserve, int bufferSize) throws IOException
IOException
protected void receive(ScpReceiveLineHandler handler) throws IOException
IOException
public void receiveDir(String header, Path local, ScpTimestamp time, boolean preserve, int bufferSize) throws IOException
IOException
public void receiveFile(String header, Path local, ScpTimestamp time, boolean preserve, int bufferSize) throws IOException
IOException
public void receiveStream(String header, ScpTargetStreamResolver resolver, ScpTimestamp time, boolean preserve, int bufferSize) throws IOException
IOException
protected void updateFileProperties(Path file, Set<PosixFilePermission> perms, ScpTimestamp time) throws IOException
IOException
public String readLine() throws IOException
IOException
public String readLine(boolean canEof) throws IOException
IOException
public void send(Collection<String> paths, boolean recursive, boolean preserve, int bufferSize) throws IOException
IOException
public void sendPaths(Collection<? extends Path> paths, boolean recursive, boolean preserve, int bufferSize) throws IOException
IOException
protected void send(Path local, boolean recursive, boolean preserve, int bufferSize, LinkOption... options) throws IOException
IOException
public Path resolveLocalPath(String basedir, String subpath) throws IOException
IOException
public Path resolveLocalPath(String commandPath) throws IOException, InvalidPathException
commandPath
- The command path using the local file separatorPath
IOException
- If failed to resolve the pathInvalidPathException
- If invalid local path valuepublic void sendFile(Path local, boolean preserve, int bufferSize) throws IOException
IOException
public void sendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize) throws IOException
IOException
public void sendDir(Path local, boolean preserve, int bufferSize) throws IOException
IOException
public static String getOctalPermissions(Path path, LinkOption... options) throws IOException
IOException
public static String getOctalPermissions(Collection<PosixFilePermission> perms)
public static Set<PosixFilePermission> setOctalPermissions(Path path, String str) throws IOException
IOException
public static Set<PosixFilePermission> parseOctalPermissions(String str)
protected void sendWarning(String message) throws IOException
IOException
protected void sendError(String message) throws IOException
IOException
protected void sendResponseMessage(int level, String message) throws IOException
IOException
public static <O extends OutputStream> O sendWarning(O out, String message) throws IOException
IOException
public static <O extends OutputStream> O sendError(O out, String message) throws IOException
IOException
public static <O extends OutputStream> O sendResponseMessage(O out, int level, String message) throws IOException
IOException
public void ack() throws IOException
IOException
public int readAck(boolean canEof) throws IOException
IOException
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.