Class LocalFileScpTargetStreamResolver
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.scp.common.helpers.LocalFileScpTargetStreamResolver
-
- All Implemented Interfaces:
ScpTargetStreamResolver
public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implements ScpTargetStreamResolver
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.file.Pathfileprotected ScpFileOpeneropenerprotected java.nio.file.Pathpathprotected java.lang.Booleanstatus-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description LocalFileScpTargetStreamResolver(java.nio.file.Path path, ScpFileOpener opener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseTargetStream(Session session, java.lang.String name, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, java.io.OutputStream stream)Called when target stream received fromresolveTargetStreamcall is no longer needed since copy is successfully completed.java.nio.file.PathgetEventListenerFilePath()voidpostProcessReceivedData(java.lang.String name, boolean preserve, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, ScpTimestampCommandDetails time)Called after successful reception of the data (and after closing the stream)java.io.OutputStreamresolveTargetStream(Session session, java.lang.String name, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, java.nio.file.OpenOption... options)Called when receiving a file in order to obtain an output stream for the incoming datajava.lang.StringtoString()protected voidupdateFileProperties(java.lang.String name, java.nio.file.Path path, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, ScpTimestampCommandDetails time)
-
-
-
Field Detail
-
path
protected final java.nio.file.Path path
-
opener
protected final ScpFileOpener opener
-
status
protected final java.lang.Boolean status
-
file
private java.nio.file.Path file
-
-
Constructor Detail
-
LocalFileScpTargetStreamResolver
public LocalFileScpTargetStreamResolver(java.nio.file.Path path, ScpFileOpener opener) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
resolveTargetStream
public java.io.OutputStream resolveTargetStream(Session session, java.lang.String name, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, java.nio.file.OpenOption... options) throws java.io.IOException
Description copied from interface:ScpTargetStreamResolverCalled when receiving a file in order to obtain an output stream for the incoming data- Specified by:
resolveTargetStreamin interfaceScpTargetStreamResolver- Parameters:
session- The associatedSessionname- File name as received from remote sitelength- Number of bytes expected to receiveperms- TheSetofPosixFilePermissionexpectedoptions- TheOpenOptions to use - may benull/empty- Returns:
- The
OutputStreamto write the incoming data - Throws:
java.io.IOException- If failed to create the stream
-
closeTargetStream
public void closeTargetStream(Session session, java.lang.String name, long length, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, java.io.OutputStream stream) throws java.io.IOException
Description copied from interface:ScpTargetStreamResolverCalled when target stream received fromresolveTargetStreamcall is no longer needed since copy is successfully completed.- Specified by:
closeTargetStreamin interfaceScpTargetStreamResolver- Parameters:
session- The associatedSessionname- File name as received from remote sitelength- Number of bytes expected to receiveperms- TheSetofPosixFilePermissionexpectedstream- TheOutputStreamto close- Throws:
java.io.IOException- If failed to close the stream - Note: stream will be closed regardless of whether this method throws an exception or not.
-
getEventListenerFilePath
public java.nio.file.Path getEventListenerFilePath()
- Specified by:
getEventListenerFilePathin interfaceScpTargetStreamResolver- Returns:
- The
Pathto use when invoking theScpTransferEventListener
-
postProcessReceivedData
public void postProcessReceivedData(java.lang.String name, boolean preserve, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, ScpTimestampCommandDetails time) throws java.io.IOExceptionDescription copied from interface:ScpTargetStreamResolverCalled after successful reception of the data (and after closing the stream)- Specified by:
postProcessReceivedDatain interfaceScpTargetStreamResolver- Parameters:
name- File name as received from remote sitepreserve- Iftruethen the resolver should attempt to preserve the specified permissions and timestampperms- TheSetofPosixFilePermissionexpectedtime- If notnullthen the required timestamp(s) on the incoming data- Throws:
java.io.IOException- If failed to post-process the incoming data
-
updateFileProperties
protected void updateFileProperties(java.lang.String name, java.nio.file.Path path, java.util.Set<java.nio.file.attribute.PosixFilePermission> perms, ScpTimestampCommandDetails time) throws java.io.IOException- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-