Class LightweightHttpWagon
- java.lang.Object
-
- org.apache.maven.wagon.AbstractWagon
-
- org.apache.maven.wagon.StreamWagon
-
- org.apache.maven.wagon.providers.http.LightweightHttpWagon
-
- All Implemented Interfaces:
StreamingWagon
,Wagon
- Direct Known Subclasses:
LightweightHttpsWagon
public class LightweightHttpWagon extends StreamWagon
LightweightHttpWagon, using JDK's HttpURLConnection.- See Also:
HttpURLConnection
-
-
Field Summary
Fields Modifier and Type Field Description private LightweightHttpWagonAuthenticator
authenticator
private java.util.Properties
httpHeaders
private static java.util.regex.Pattern
IOEXCEPTION_MESSAGE_PATTERN
static int
MAX_REDIRECTS
private boolean
preemptiveAuthentication
private java.net.Proxy
proxy
private java.net.HttpURLConnection
putConnection
private boolean
useCache
Whether to use any proxy cache or not.-
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 LightweightHttpWagon()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addHeaders(java.net.HttpURLConnection urlConnection)
private java.lang.String
buildUrl(Resource resource)
Builds a complete URL string from the repository URL and the relative path of the resource passed.void
closeConnection()
private TransferFailedException
convertHttpUrlConnectionException(java.io.IOException originalIOException, java.net.HttpURLConnection urlConnection, java.lang.String url)
Convert the IOException that is thrown for most transfer errors that HttpURLConnection encounters to the equivalentTransferFailedException
.void
fillInputData(InputData inputData)
void
fillOutputData(OutputData outputData)
protected void
finishPutTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output)
LightweightHttpWagonAuthenticator
getAuthenticator()
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.java.util.Properties
getHttpHeaders()
private java.net.Proxy
getProxy(ProxyInfo proxyInfo)
private java.net.Proxy.Type
getProxyType(ProxyInfo proxyInfo)
java.net.SocketAddress
getSocketAddress(ProxyInfo proxyInfo)
boolean
isUseCache()
protected void
openConnectionInternal()
java.net.PasswordAuthentication
requestProxyAuthentication()
java.net.PasswordAuthentication
requestServerAuthentication()
boolean
resourceExists(java.lang.String resourceName)
Check if a remote resource existsvoid
setAuthenticator(LightweightHttpWagonAuthenticator authenticator)
private void
setAuthorization(java.net.HttpURLConnection urlConnection)
void
setHttpHeaders(java.util.Properties httpHeaders)
void
setPreemptiveAuthentication(boolean preemptiveAuthentication)
(package private) void
setSystemProperty(java.lang.String key, java.lang.String value)
void
setUseCache(boolean useCache)
-
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, 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, putDirectory, putTransfer, putTransfer, removeSessionListener, removeTransferListener, setInteractive, setPermissionsOverride, setReadTimeout, setSessionEventSupport, setTimeout, setTransferEventSupport, supportsDirectoryCopy, 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, putDirectory, removeSessionListener, removeTransferListener, setInteractive, setReadTimeout, setTimeout, supportsDirectoryCopy
-
-
-
-
Field Detail
-
preemptiveAuthentication
private boolean preemptiveAuthentication
-
putConnection
private java.net.HttpURLConnection putConnection
-
proxy
private java.net.Proxy proxy
-
IOEXCEPTION_MESSAGE_PATTERN
private static final java.util.regex.Pattern IOEXCEPTION_MESSAGE_PATTERN
-
MAX_REDIRECTS
public static final int MAX_REDIRECTS
- See Also:
- Constant Field Values
-
useCache
private boolean useCache
Whether to use any proxy cache or not.
-
httpHeaders
private java.util.Properties httpHeaders
-
authenticator
private volatile LightweightHttpWagonAuthenticator authenticator
-
-
Method Detail
-
buildUrl
private java.lang.String buildUrl(Resource resource)
Builds a complete URL string from the repository URL and the relative path of the resource passed.- Parameters:
resource
- the resource to extract the relative path from.- Returns:
- the complete URL
-
fillInputData
public void fillInputData(InputData inputData) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- Specified by:
fillInputData
in classStreamWagon
- Throws:
TransferFailedException
ResourceDoesNotExistException
AuthorizationException
-
addHeaders
private void addHeaders(java.net.HttpURLConnection urlConnection)
-
setAuthorization
private void setAuthorization(java.net.HttpURLConnection urlConnection)
-
fillOutputData
public void fillOutputData(OutputData outputData) throws TransferFailedException
- Specified by:
fillOutputData
in classStreamWagon
- Throws:
TransferFailedException
-
finishPutTransfer
protected void finishPutTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- Overrides:
finishPutTransfer
in classAbstractWagon
- Throws:
TransferFailedException
AuthorizationException
ResourceDoesNotExistException
-
openConnectionInternal
protected void openConnectionInternal() throws ConnectionException, AuthenticationException
- Specified by:
openConnectionInternal
in classAbstractWagon
- Throws:
ConnectionException
AuthenticationException
-
requestProxyAuthentication
public java.net.PasswordAuthentication requestProxyAuthentication()
-
requestServerAuthentication
public java.net.PasswordAuthentication requestServerAuthentication()
-
getProxy
private java.net.Proxy getProxy(ProxyInfo proxyInfo)
-
getProxyType
private java.net.Proxy.Type getProxyType(ProxyInfo proxyInfo)
-
getSocketAddress
public java.net.SocketAddress getSocketAddress(ProxyInfo proxyInfo)
-
closeConnection
public void closeConnection() throws ConnectionException
- Specified by:
closeConnection
in classStreamWagon
- Throws:
ConnectionException
-
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
-
isUseCache
public boolean isUseCache()
-
setUseCache
public void setUseCache(boolean useCache)
-
getHttpHeaders
public java.util.Properties getHttpHeaders()
-
setHttpHeaders
public void setHttpHeaders(java.util.Properties httpHeaders)
-
setSystemProperty
void setSystemProperty(java.lang.String key, java.lang.String value)
-
setPreemptiveAuthentication
public void setPreemptiveAuthentication(boolean preemptiveAuthentication)
-
getAuthenticator
public LightweightHttpWagonAuthenticator getAuthenticator()
-
setAuthenticator
public void setAuthenticator(LightweightHttpWagonAuthenticator authenticator)
-
convertHttpUrlConnectionException
private TransferFailedException convertHttpUrlConnectionException(java.io.IOException originalIOException, java.net.HttpURLConnection urlConnection, java.lang.String url)
Convert the IOException that is thrown for most transfer errors that HttpURLConnection encounters to the equivalentTransferFailedException
.Details are extracted from the error stream if possible, either directly or indirectly by way of supporting accessors. The returned exception will include the passed IOException as a cause and a message that is as descriptive as possible.
- Parameters:
originalIOException
- an IOException thrown from an HttpURLConnection operationurlConnection
- instance that triggered the IOExceptionurl
- originating url that triggered the IOException- Returns:
- exception that is representative of the original cause
-
-