Class TransportHttp.HttpObjectDB
- java.lang.Object
-
- org.eclipse.jgit.transport.WalkRemoteObjectDatabase
-
- org.eclipse.jgit.transport.TransportHttp.HttpObjectDB
-
- Enclosing class:
- TransportHttp
class TransportHttp.HttpObjectDB extends WalkRemoteObjectDatabase
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jgit.transport.WalkRemoteObjectDatabase
WalkRemoteObjectDatabase.FileStream
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.URLhttpObjectsUrl-
Fields inherited from class org.eclipse.jgit.transport.WalkRemoteObjectDatabase
INFO_PACKS, INFO_REFS, ROOT_DIR
-
-
Constructor Summary
Constructors Constructor Description HttpObjectDB(java.net.URL b)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidclose()Close any resources used by this connection.private PackProtocolExceptionduplicateAdvertisement(java.lang.String n)(package private) java.util.Collection<WalkRemoteObjectDatabase>getAlternates()Obtain alternate connections to alternate object databases (if any).(package private) java.util.Collection<java.lang.String>getPackNames()Obtain the list of available packs (if any).(package private) URIishgetURI()private PackProtocolExceptioninvalidAdvertisement(java.lang.String n)(package private) WalkRemoteObjectDatabase.FileStreamopen(java.lang.String path)Open a single file for reading.(package private) WalkRemoteObjectDatabase.FileStreamopen(java.lang.String path, TransportHttp.AcceptEncoding acceptEncoding)(package private) WalkRemoteObjectDatabaseopenAlternate(java.lang.String location)Create a new connection for a discovered alternate object database(package private) java.io.BufferedReaderopenReader(java.lang.String path)Open a buffered reader around a file.private PackProtocolExceptionoutOfOrderAdvertisement(java.lang.String n)(package private) java.util.Map<java.lang.String,Ref>readAdvertisedImpl(java.io.BufferedReader br)-
Methods inherited from class org.eclipse.jgit.transport.WalkRemoteObjectDatabase
deleteFile, deleteRef, deleteRefLog, readAlternates, readPackedRefs, writeFile, writeFile, writeInfoPacks, writeRef
-
-
-
-
Method Detail
-
getURI
URIish getURI()
- Specified by:
getURIin classWalkRemoteObjectDatabase
-
getAlternates
java.util.Collection<WalkRemoteObjectDatabase> getAlternates() throws java.io.IOException
Description copied from class:WalkRemoteObjectDatabaseObtain alternate connections to alternate object databases (if any).Alternates are typically read from the file
Constants.INFO_ALTERNATESorConstants.INFO_HTTP_ALTERNATES. The content of each line must be resolved by the implementation and a new database reference should be returned to represent the additional location.Alternates may reuse the same network connection handle, however the fetch connection will
WalkRemoteObjectDatabase.close()each created alternate.- Specified by:
getAlternatesin classWalkRemoteObjectDatabase- Returns:
- list of additional object databases the caller could fetch from; null or empty list if none are configured.
- Throws:
java.io.IOException- The connection is unable to read the remote repository's list of configured alternates.
-
openAlternate
WalkRemoteObjectDatabase openAlternate(java.lang.String location) throws java.io.IOException
Description copied from class:WalkRemoteObjectDatabaseCreate a new connection for a discovered alternate object databaseThis method is typically called by
WalkRemoteObjectDatabase.readAlternates(String)when subclasses us the generic alternate parsing logic for their implementation ofWalkRemoteObjectDatabase.getAlternates().- Specified by:
openAlternatein classWalkRemoteObjectDatabase- Parameters:
location- the location of the new alternate, relative to the current object database.- Returns:
- a new database connection that can read from the specified alternate.
- Throws:
java.io.IOException- The database connection cannot be established with the alternate, such as if the alternate location does not actually exist and the connection's constructor attempts to verify that.
-
openReader
java.io.BufferedReader openReader(java.lang.String path) throws java.io.IOExceptionDescription copied from class:WalkRemoteObjectDatabaseOpen a buffered reader around a file.This method is suitable for reading line-oriented resources like
info/packs,info/refs, and the alternates list.- Overrides:
openReaderin classWalkRemoteObjectDatabase- Parameters:
path- location of the file to read, relative to this objects directory (e.g.info/packs).- Returns:
- a stream to read from the file. Never null.
- Throws:
java.io.FileNotFoundException- the requested file does not exist at the given location.java.io.IOException- The connection is unable to read the remote's file, and the failure occurred prior to being able to determine if the file exists, or after it was determined to exist but before the stream could be created.
-
getPackNames
java.util.Collection<java.lang.String> getPackNames() throws java.io.IOExceptionDescription copied from class:WalkRemoteObjectDatabaseObtain the list of available packs (if any).Pack names should be the file name in the packs directory, that is
pack-035760ab452d6eebd123add421f253ce7682355a.pack. Index names should not be included in the returned collection.- Specified by:
getPackNamesin classWalkRemoteObjectDatabase- Returns:
- list of pack names; null or empty list if none are available.
- Throws:
java.io.IOException- The connection is unable to read the remote repository's list of available pack files.
-
open
WalkRemoteObjectDatabase.FileStream open(java.lang.String path) throws java.io.IOException
Description copied from class:WalkRemoteObjectDatabaseOpen a single file for reading.Implementors should make every attempt possible to ensure
FileNotFoundExceptionis used when the remote object does not exist. However when fetching over HTTP some misconfigured servers may generate a 200 OK status message (rather than a 404 Not Found) with an HTML formatted message explaining the requested resource does not exist. Callers such asWalkFetchConnectionare prepared to handle this by validating the content received, and assuming content that fails to match its hash is an incorrectly phrased FileNotFoundException.This method is recommended for already compressed files like loose objects and pack files. For text files, see
WalkRemoteObjectDatabase.openReader(String).- Specified by:
openin classWalkRemoteObjectDatabase- Parameters:
path- location of the file to read, relative to this objects directory (e.g.cb/95df6ab7ae9e57571511ef451cf33767c26dd2orpack/pack-035760ab452d6eebd123add421f253ce7682355a.pack).- Returns:
- a stream to read from the file. Never null.
- Throws:
java.io.FileNotFoundException- the requested file does not exist at the given location.java.io.IOException- The connection is unable to read the remote's file, and the failure occurred prior to being able to determine if the file exists, or after it was determined to exist but before the stream could be created.
-
open
WalkRemoteObjectDatabase.FileStream open(java.lang.String path, TransportHttp.AcceptEncoding acceptEncoding) throws java.io.IOException
- Throws:
java.io.IOException
-
readAdvertisedImpl
java.util.Map<java.lang.String,Ref> readAdvertisedImpl(java.io.BufferedReader br) throws java.io.IOException, PackProtocolException
- Throws:
java.io.IOExceptionPackProtocolException
-
outOfOrderAdvertisement
private PackProtocolException outOfOrderAdvertisement(java.lang.String n)
-
invalidAdvertisement
private PackProtocolException invalidAdvertisement(java.lang.String n)
-
duplicateAdvertisement
private PackProtocolException duplicateAdvertisement(java.lang.String n)
-
close
void close()
Description copied from class:WalkRemoteObjectDatabaseClose any resources used by this connection.If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.
- Specified by:
closein classWalkRemoteObjectDatabase
-
-