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 LightweightHttpWagonAuthenticatorauthenticatorprivate java.util.PropertieshttpHeadersprivate static java.util.regex.PatternIOEXCEPTION_MESSAGE_PATTERNstatic intMAX_REDIRECTSprivate booleanpreemptiveAuthenticationprivate java.net.Proxyproxyprivate java.net.HttpURLConnectionputConnectionprivate booleanuseCacheWhether 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 voidaddHeaders(java.net.HttpURLConnection urlConnection)private java.lang.StringbuildUrl(Resource resource)Builds a complete URL string from the repository URL and the relative path of the resource passed.voidcloseConnection()private TransferFailedExceptionconvertHttpUrlConnectionException(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.voidfillInputData(InputData inputData)voidfillOutputData(OutputData outputData)protected voidfinishPutTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output)LightweightHttpWagonAuthenticatorgetAuthenticator()java.util.PropertiesgetHttpHeaders()private java.net.ProxygetProxy(ProxyInfo proxyInfo)private java.net.Proxy.TypegetProxyType(ProxyInfo proxyInfo)java.net.SocketAddressgetSocketAddress(ProxyInfo proxyInfo)booleanisUseCache()protected voidopenConnectionInternal()java.net.PasswordAuthenticationrequestProxyAuthentication()java.net.PasswordAuthenticationrequestServerAuthentication()booleanresourceExists(java.lang.String resourceName)Check if a remote resource existsvoidsetAuthenticator(LightweightHttpWagonAuthenticator authenticator)private voidsetAuthorization(java.net.HttpURLConnection urlConnection)voidsetHttpHeaders(java.util.Properties httpHeaders)voidsetPreemptiveAuthentication(boolean preemptiveAuthentication)(package private) voidsetSystemProperty(java.lang.String key, java.lang.String value)voidsetUseCache(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, getFileList, 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, getFileList, 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:
fillInputDatain classStreamWagon- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
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:
fillOutputDatain classStreamWagon- Throws:
TransferFailedException
-
finishPutTransfer
protected void finishPutTransfer(Resource resource, java.io.InputStream input, java.io.OutputStream output) throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- Overrides:
finishPutTransferin classAbstractWagon- Throws:
TransferFailedExceptionAuthorizationExceptionResourceDoesNotExistException
-
openConnectionInternal
protected void openConnectionInternal() throws ConnectionException, AuthenticationException- Specified by:
openConnectionInternalin classAbstractWagon- Throws:
ConnectionExceptionAuthenticationException
-
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:
closeConnectionin classStreamWagon- Throws:
ConnectionException
-
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 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
-
-