Package org.eclipse.jgit.lfs.internal
Class LfsConnectionFactory
- java.lang.Object
-
- org.eclipse.jgit.lfs.internal.LfsConnectionFactory
-
public class LfsConnectionFactory extends java.lang.Object
Provides means to get a valid LFS connection for a given repository.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
LfsConnectionFactory.AuthCache
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
SCHEME_HTTPS
private static java.lang.String
SCHEME_SSH
private static int
SSH_AUTH_TIMEOUT_SECONDS
private static java.util.Map<java.lang.String,LfsConnectionFactory.AuthCache>
sshAuthCache
-
Constructor Summary
Constructors Constructor Description LfsConnectionFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
discoverLfsUrl(Repository db, java.lang.String purpose, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.String remoteUrl)
private static java.lang.String
extractProjectName(URIish u)
static HttpConnection
getLfsConnection(Repository db, java.lang.String method, java.lang.String purpose)
Determine URL of LFS server by looking into config parameters lfs.url, lfs.[remote].url or remote.[remote].url.static HttpConnection
getLfsContentConnection(Repository repo, Protocol.Action action, java.lang.String method)
Create a connection for the specifiedProtocol.Action
.private static java.lang.String
getLfsUrl(Repository db, java.lang.String purpose, java.util.Map<java.lang.String,java.lang.String> additionalHeaders)
private static Protocol.ExpiringAction
getSshAuthentication(Repository db, java.lang.String purpose, java.lang.String remoteUrl, URIish u)
static Protocol.Request
toRequest(java.lang.String operation, LfsPointer... resources)
-
-
-
Field Detail
-
SSH_AUTH_TIMEOUT_SECONDS
private static final int SSH_AUTH_TIMEOUT_SECONDS
- See Also:
- Constant Field Values
-
SCHEME_HTTPS
private static final java.lang.String SCHEME_HTTPS
- See Also:
- Constant Field Values
-
SCHEME_SSH
private static final java.lang.String SCHEME_SSH
- See Also:
- Constant Field Values
-
sshAuthCache
private static final java.util.Map<java.lang.String,LfsConnectionFactory.AuthCache> sshAuthCache
-
-
Method Detail
-
getLfsConnection
public static HttpConnection getLfsConnection(Repository db, java.lang.String method, java.lang.String purpose) throws java.io.IOException
Determine URL of LFS server by looking into config parameters lfs.url, lfs.[remote].url or remote.[remote].url. The LFS server URL is computed from remote.[remote].url by appending "/info/lfs". In case there is no URL configured, a SSH remote URI can be used to auto-detect the LFS URI by using the remote "git-lfs-authenticate" command.- Parameters:
db
- the repository to work withmethod
- the method (GET,PUT,...) of the request this connection will be used forpurpose
- the action, e.g. Protocol.OPERATION_DOWNLOAD- Returns:
- the url for the lfs server. e.g. "https://github.com/github/git-lfs.git/info/lfs"
- Throws:
java.io.IOException
-
getLfsUrl
private static java.lang.String getLfsUrl(Repository db, java.lang.String purpose, java.util.Map<java.lang.String,java.lang.String> additionalHeaders) throws LfsConfigInvalidException
- Throws:
LfsConfigInvalidException
-
discoverLfsUrl
private static java.lang.String discoverLfsUrl(Repository db, java.lang.String purpose, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.String remoteUrl) throws java.net.URISyntaxException, java.io.IOException, CommandFailedException
- Throws:
java.net.URISyntaxException
java.io.IOException
CommandFailedException
-
getSshAuthentication
private static Protocol.ExpiringAction getSshAuthentication(Repository db, java.lang.String purpose, java.lang.String remoteUrl, URIish u) throws java.io.IOException, CommandFailedException
- Throws:
java.io.IOException
CommandFailedException
-
getLfsContentConnection
@NonNull public static HttpConnection getLfsContentConnection(Repository repo, Protocol.Action action, java.lang.String method) throws java.io.IOException
Create a connection for the specifiedProtocol.Action
.- Parameters:
repo
- the repo to fetch required configuration fromaction
- the action for which to create a connectionmethod
- the target method (GET or PUT)- Returns:
- a connection. output mode is not set.
- Throws:
java.io.IOException
- in case of any error.
-
extractProjectName
private static java.lang.String extractProjectName(URIish u)
-
toRequest
public static Protocol.Request toRequest(java.lang.String operation, LfsPointer... resources)
- Parameters:
operation
- the operation to perform, e.g. Protocol.OPERATION_DOWNLOADresources
- the LFS resources affected- Returns:
- a request that can be serialized to JSON
-
-