Class FtpWagon
- java.lang.Object
-
- org.apache.maven.wagon.AbstractWagon
-
- org.apache.maven.wagon.StreamWagon
-
- org.apache.maven.wagon.providers.ftp.FtpWagon
-
- All Implemented Interfaces:
StreamingWagon
,Wagon
- Direct Known Subclasses:
FtpHttpWagon
,FtpsWagon
public class FtpWagon extends StreamWagon
FtpWagon
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
FtpWagon.PrintCommandListener
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
controlEncoding
private org.apache.commons.net.ftp.FTPClient
ftp
private boolean
passiveMode
-
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.Wagon
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
-
-
Constructor Summary
Constructors Constructor Description FtpWagon()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeConnection()
protected org.apache.commons.net.ftp.FTPClient
createClient()
void
fillInputData(InputData inputData)
void
fillOutputData(OutputData outputData)
protected void
fireGetCompleted(Resource resource, java.io.File localFile)
protected void
firePutCompleted(Resource resource, java.io.File file)
protected void
fireSessionDebug(java.lang.String msg)
private void
ftpChangeDirectory(Resource resource)
private void
ftpRecursivePut(java.io.File sourceFile, java.lang.String fileName)
java.lang.String
getControlEncoding()
java.util.List<java.lang.String>
getFileList(java.lang.String destinationDirectory)
Returns aList
of strings naming the files and directories in the directory denoted by this abstract pathname.boolean
isPassiveMode()
private boolean
makeFtpDirectoryRecursive(java.lang.String fileName, RepositoryPermissions permissions)
Recursively create directories.protected void
openConnectionInternal()
void
putDirectory(java.io.File sourceDirectory, java.lang.String destinationDirectory)
Copy a directory from local system to remoteboolean
resourceExists(java.lang.String resourceName)
Check if a remote resource existsvoid
setControlEncoding(java.lang.String controlEncoding)
void
setPassiveMode(boolean passiveMode)
private void
setPermissions(RepositoryPermissions permissions)
Set the permissions (if given) for the underlying folder.boolean
supportsDirectoryCopy()
Flag indicating if this wagon supports directory copy operations.-
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, cleanupGetTransfer, cleanupPutTransfer, connect, connect, connect, connect, connect, connect, createParentDirectories, disconnect, finishGetTransfer, finishPutTransfer, fireGetInitiated, fireGetStarted, firePutInitiated, firePutStarted, fireSessionConnectionRefused, 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, 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, getReadTimeout, getRepository, getTimeout, hasSessionListener, hasTransferListener, isInteractive, openConnection, removeSessionListener, removeTransferListener, setInteractive, setReadTimeout, setTimeout
-
-
-
-
Method Detail
-
isPassiveMode
public boolean isPassiveMode()
-
setPassiveMode
public void setPassiveMode(boolean passiveMode)
-
openConnectionInternal
protected void openConnectionInternal() throws ConnectionException, AuthenticationException
- Specified by:
openConnectionInternal
in classAbstractWagon
- Throws:
ConnectionException
AuthenticationException
-
createClient
protected org.apache.commons.net.ftp.FTPClient createClient()
-
firePutCompleted
protected void firePutCompleted(Resource resource, java.io.File file)
- Overrides:
firePutCompleted
in classAbstractWagon
-
fireGetCompleted
protected void fireGetCompleted(Resource resource, java.io.File localFile)
- Overrides:
fireGetCompleted
in classAbstractWagon
-
closeConnection
public void closeConnection() throws ConnectionException
- Specified by:
closeConnection
in classStreamWagon
- Throws:
ConnectionException
-
fillOutputData
public void fillOutputData(OutputData outputData) throws TransferFailedException
- Specified by:
fillOutputData
in classStreamWagon
- Throws:
TransferFailedException
-
fillInputData
public void fillInputData(InputData inputData) throws TransferFailedException, ResourceDoesNotExistException
- Specified by:
fillInputData
in classStreamWagon
- Throws:
TransferFailedException
ResourceDoesNotExistException
-
ftpChangeDirectory
private void ftpChangeDirectory(Resource resource) throws java.io.IOException, TransferFailedException, ResourceDoesNotExistException
- Throws:
java.io.IOException
TransferFailedException
ResourceDoesNotExistException
-
fireSessionDebug
protected void fireSessionDebug(java.lang.String msg)
- Overrides:
fireSessionDebug
in classAbstractWagon
-
getFileList
public java.util.List<java.lang.String> getFileList(java.lang.String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
Description copied from interface:Wagon
Returns aList
of 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 aList
of 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:
getFileList
in interfaceWagon
- Overrides:
getFileList
in classAbstractWagon
- Parameters:
destinationDirectory
- directory to list contents of- Returns:
- A
List
of strings naming the files and directories in the directory denoted by this abstract pathname. TheList
will 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, AuthorizationException
Description copied from interface:Wagon
Check if a remote resource exists- Specified by:
resourceExists
in interfaceWagon
- Overrides:
resourceExists
in classAbstractWagon
- 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
-
supportsDirectoryCopy
public boolean supportsDirectoryCopy()
Description copied from interface:Wagon
Flag indicating if this wagon supports directory copy operations.- Specified by:
supportsDirectoryCopy
in interfaceWagon
- Overrides:
supportsDirectoryCopy
in classAbstractWagon
- Returns:
- whether if this wagon supports directory operations
-
putDirectory
public void putDirectory(java.io.File sourceDirectory, java.lang.String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
Description copied from interface:Wagon
Copy a directory from local system to remote- Specified by:
putDirectory
in interfaceWagon
- Overrides:
putDirectory
in classAbstractWagon
- Parameters:
sourceDirectory
- the local directorydestinationDirectory
- the remote destination- Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException
-
ftpRecursivePut
private void ftpRecursivePut(java.io.File sourceFile, java.lang.String fileName) throws TransferFailedException
- Throws:
TransferFailedException
-
setPermissions
private void setPermissions(RepositoryPermissions permissions)
Set the permissions (if given) for the underlying folder. Note: Since the FTP SITE command might be server dependent, we cannot rely on the functionality available on each FTP server! So we can only try and hope it works (and catch away all Exceptions).- Parameters:
permissions
- group and directory permissions
-
makeFtpDirectoryRecursive
private boolean makeFtpDirectoryRecursive(java.lang.String fileName, RepositoryPermissions permissions) throws java.io.IOException
Recursively create directories.- Parameters:
fileName
- the path to create (might be nested)permissions
-- Returns:
- ok
- Throws:
java.io.IOException
-
getControlEncoding
public java.lang.String getControlEncoding()
-
setControlEncoding
public void setControlEncoding(java.lang.String controlEncoding)
-
-