Class SftpWagon
- java.lang.Object
-
- org.apache.maven.wagon.AbstractWagon
-
- org.apache.maven.wagon.StreamWagon
-
- org.apache.maven.wagon.providers.ssh.jsch.AbstractJschWagon
-
- org.apache.maven.wagon.providers.ssh.jsch.SftpWagon
-
- All Implemented Interfaces:
CommandExecutor,SshWagon,StreamingWagon,Wagon
public class SftpWagon extends AbstractJschWagon
SFTP protocol wagon.
-
-
Field Summary
Fields Modifier and Type Field Description private com.jcraft.jsch.ChannelSftpchannelprivate static longMILLIS_PER_SECprivate static intS_IFDIRprivate static java.lang.StringSFTP_CHANNEL-
Fields inherited from class org.apache.maven.wagon.providers.ssh.jsch.AbstractJschWagon
EXEC_CHANNEL, session, sshTool
-
Fields inherited from class org.apache.maven.wagon.AbstractWagon
authenticationInfo, BUFFER_SEGMENT_SIZE, DEFAULT_BUFFER_SIZE, interactive, MAXIMUM_BUFFER_SIZE, MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS, proxyInfo, repository, sessionEventSupport, transferEventSupport
-
Fields inherited from interface org.apache.maven.wagon.CommandExecutor
ROLE
-
Fields inherited from interface org.apache.maven.wagon.Wagon
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
-
-
Constructor Summary
Constructors Constructor Description SftpWagon()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private com.jcraft.jsch.SftpATTRSchangeToRepositoryDirectory(java.lang.String dir, java.lang.String filename)protected voidcleanupGetTransfer(Resource resource)protected voidcleanupPutTransfer(Resource resource)voidcloseConnection()voidfillInputData(InputData inputData)voidfillOutputData(OutputData outputData)protected voidfinishPutTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output)private voidftpRecursivePut(java.io.File sourceFile, java.lang.String prefix, java.lang.String fileName, int directoryMode)intgetDirectoryMode(RepositoryPermissions permissions)java.util.List<java.lang.String>getFileList(java.lang.String destinationDirectory)Returns aListof strings naming the files and directories in the directory denoted by this abstract pathname.private java.lang.StringgetFileName(java.lang.String prefix, java.lang.String fileName)intgetOctalMode(java.lang.String mode)private voidmkdir(java.lang.String dir, int mode)private voidmkdirs(java.lang.String resourceName, int mode)voidopenConnectionInternal()voidputDirectory(java.io.File sourceDirectory, java.lang.String destinationDirectory)Copy a directory from local system to remoteprivate voidputFile(java.io.File source, Resource resource, RepositoryPermissions permissions)booleanresourceExists(java.lang.String resourceName)Check if a remote resource existsprivate voidreturnToParentDirectory(Resource resource)private voidsetFileMode(java.lang.String filename, RepositoryPermissions permissions)private voidsetGroup(java.lang.String filename, RepositoryPermissions permissions)-
Methods inherited from class org.apache.maven.wagon.providers.ssh.jsch.AbstractJschWagon
executeCommand, executeCommand, executeCommand, getInteractiveUserInfo, getKnownHostsProvider, getPreferredAuthentications, getStrictHostKeyChecking, handleGetException, setInteractiveUserInfo, setKnownHostsProvider, setPreferredAuthentications, setStrictHostKeyChecking, setUIKeyboardInteractive, supportsDirectoryCopy, transfer
-
Methods inherited from class org.apache.maven.wagon.StreamWagon
checkInputStream, checkOutputStream, get, getIfNewer, getIfNewerToStream, getInputStream, getOutputStream, getToStream, put, putFromStream, putFromStream, putFromStream
-
Methods inherited from class org.apache.maven.wagon.AbstractWagon
addSessionListener, addTransferListener, connect, connect, connect, connect, connect, connect, createParentDirectories, disconnect, finishGetTransfer, fireGetCompleted, fireGetInitiated, fireGetStarted, firePutCompleted, firePutInitiated, firePutStarted, fireSessionConnectionRefused, fireSessionDebug, fireSessionDisconnected, fireSessionDisconnecting, fireSessionError, fireSessionLoggedIn, fireSessionLoggedOff, fireSessionOpened, fireSessionOpening, fireTransferDebug, fireTransferError, fireTransferProgress, getAuthenticationInfo, getBufferCapacityForTransfer, getPath, getPermissionsOverride, getProxyInfo, getProxyInfo, getReadTimeout, getRepository, getSessionEventSupport, getTimeout, getTransfer, getTransfer, getTransfer, getTransfer, getTransfer, getTransfer, getTransferEventSupport, hasSessionListener, hasTransferListener, isInteractive, openConnection, postProcessListeners, putTransfer, putTransfer, removeSessionListener, removeTransferListener, setInteractive, setPermissionsOverride, setReadTimeout, setSessionEventSupport, setTimeout, setTransferEventSupport, transfer, transfer, transfer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.maven.wagon.Wagon
addSessionListener, addTransferListener, connect, connect, connect, connect, connect, connect, disconnect, get, getIfNewer, getReadTimeout, getRepository, getTimeout, hasSessionListener, hasTransferListener, isInteractive, openConnection, put, removeSessionListener, removeTransferListener, setInteractive, setReadTimeout, setTimeout
-
-
-
-
Field Detail
-
SFTP_CHANNEL
private static final java.lang.String SFTP_CHANNEL
- See Also:
- Constant Field Values
-
S_IFDIR
private static final int S_IFDIR
- See Also:
- Constant Field Values
-
MILLIS_PER_SEC
private static final long MILLIS_PER_SEC
- See Also:
- Constant Field Values
-
channel
private com.jcraft.jsch.ChannelSftp channel
-
-
Method Detail
-
closeConnection
public void closeConnection()
- Overrides:
closeConnectionin classAbstractJschWagon
-
openConnectionInternal
public void openConnectionInternal() throws AuthenticationException- Overrides:
openConnectionInternalin classAbstractJschWagon- Throws:
AuthenticationException
-
returnToParentDirectory
private void returnToParentDirectory(Resource resource)
-
putFile
private void putFile(java.io.File source, Resource resource, RepositoryPermissions permissions) throws com.jcraft.jsch.SftpException, TransferFailedException- Throws:
com.jcraft.jsch.SftpExceptionTransferFailedException
-
setGroup
private void setGroup(java.lang.String filename, RepositoryPermissions permissions)
-
setFileMode
private void setFileMode(java.lang.String filename, RepositoryPermissions permissions)
-
mkdirs
private void mkdirs(java.lang.String resourceName, int mode) throws com.jcraft.jsch.SftpException, TransferFailedException- Throws:
com.jcraft.jsch.SftpExceptionTransferFailedException
-
mkdir
private void mkdir(java.lang.String dir, int mode) throws TransferFailedException, com.jcraft.jsch.SftpException- Throws:
TransferFailedExceptioncom.jcraft.jsch.SftpException
-
changeToRepositoryDirectory
private com.jcraft.jsch.SftpATTRS changeToRepositoryDirectory(java.lang.String dir, java.lang.String filename) throws ResourceDoesNotExistException, com.jcraft.jsch.SftpException- Throws:
ResourceDoesNotExistExceptioncom.jcraft.jsch.SftpException
-
putDirectory
public void putDirectory(java.io.File sourceDirectory, java.lang.String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:WagonCopy a directory from local system to remote- Specified by:
putDirectoryin interfaceWagon- Overrides:
putDirectoryin classAbstractJschWagon- Parameters:
sourceDirectory- the local directorydestinationDirectory- the remote destination- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
ftpRecursivePut
private void ftpRecursivePut(java.io.File sourceFile, java.lang.String prefix, java.lang.String fileName, int directoryMode) throws TransferFailedException, com.jcraft.jsch.SftpException- Throws:
TransferFailedExceptioncom.jcraft.jsch.SftpException
-
getFileName
private java.lang.String getFileName(java.lang.String prefix, java.lang.String fileName)
-
getFileList
public java.util.List<java.lang.String> getFileList(java.lang.String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:WagonReturns aListof strings naming the files and directories in the directory denoted by this abstract pathname. If this abstract pathname does not denote a directory, or does not exist, then this method throwsResourceDoesNotExistException. Otherwise aListof strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path. There is no guarantee that the name strings in the resulting list will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.- Specified by:
getFileListin interfaceWagon- Overrides:
getFileListin classAbstractJschWagon- Parameters:
destinationDirectory- directory to list contents of- Returns:
- A
Listof strings naming the files and directories in the directory denoted by this abstract pathname. TheListwill be empty if the directory is empty. - Throws:
TransferFailedException- if there's an error trying to access the remote sideResourceDoesNotExistException- if destinationDirectory does not exist or is not a directoryAuthorizationException- if not authorized to list the contents of the directory
-
resourceExists
public boolean resourceExists(java.lang.String resourceName) throws TransferFailedException, AuthorizationExceptionDescription copied from interface:WagonCheck if a remote resource exists- Specified by:
resourceExistsin interfaceWagon- Overrides:
resourceExistsin classAbstractJschWagon- Returns:
- whether the resource exists or not
- Throws:
TransferFailedException- if there's an error trying to access the remote sideAuthorizationException- if not authorized to verify the existence of the resource
-
cleanupGetTransfer
protected void cleanupGetTransfer(Resource resource)
- Overrides:
cleanupGetTransferin classAbstractWagon
-
cleanupPutTransfer
protected void cleanupPutTransfer(Resource resource)
- Overrides:
cleanupPutTransferin classAbstractWagon
-
finishPutTransfer
protected void finishPutTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output) throws TransferFailedException
- Overrides:
finishPutTransferin classAbstractWagon- Throws:
TransferFailedException
-
fillInputData
public void fillInputData(InputData inputData) throws TransferFailedException, ResourceDoesNotExistException
- Specified by:
fillInputDatain classStreamWagon- Throws:
TransferFailedExceptionResourceDoesNotExistException
-
fillOutputData
public void fillOutputData(OutputData outputData) throws TransferFailedException
- Specified by:
fillOutputDatain classStreamWagon- Throws:
TransferFailedException
-
getDirectoryMode
public int getDirectoryMode(RepositoryPermissions permissions)
- Parameters:
permissions- repository's permissions- Returns:
- the directory mode for the repository or
-1if it wasn't set
-
getOctalMode
public int getOctalMode(java.lang.String mode)
-
-