Top Description Inners Fields Constructors Methods
org.eclipse.jgit.lfs.server

public abstract Class LfsProtocolServlet

extends HttpServlet
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.UTF_8, org.apache.http.HttpStatus.SC_FORBIDDEN, .HttpStatus.SC_INSUFFICIENT_STORAGE, .HttpStatus.SC_INTERNAL_SERVER_ERROR, .HttpStatus.SC_NOT_FOUND, .HttpStatus.SC_OK, .HttpStatus.SC_SERVICE_UNAVAILABLE, .HttpStatus.SC_UNAUTHORIZED, .HttpStatus.SC_UNPROCESSABLE_ENTITY, org.eclipse.jgit.lfs.lib.Constants.DOWNLOAD, .Constants.UPLOAD, .Constants.VERIFY, org.eclipse.jgit.util.HttpSupport.HDR_AUTHORIZATION

LFS protocol handler implementing the LFS batch API [1] [1] https://github.com/github/git-lfs/blob/master/docs/api/v1/http-v1-batch.md
Since
4.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final Logger
private static final int
private static final int
private static final long
Inherited from jakarta.servlet.http.HttpServlet:
LEGACY_DO_HEAD

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
doPost(HttpServletRequest
an HttpServletRequest object that contains the request the client has made of the servlet
req
,
HttpServletResponse
an HttpServletResponse object that contains the response the servlet sends to the client
res
)

Overrides jakarta.servlet.http.HttpServlet.doPost.

Called by the server (via the service method) to allow a servlet to handle a POST request.

protected abstract LargeFileRepository

Returns:

the large file repository storing large files.
getLargeFileRepository
(LfsProtocolServlet.LfsRequest
the request
request
,
String
the path
path
,
String
the Authorization HTTP header
auth
)

Get the large file repository for the given request and path.

private void
sendError(HttpServletResponse rsp, Writer writer, int status, String message)

Inherited from jakarta.servlet.http.HttpServlet:
doDeletedoGetdoHeaddoOptionsdoPatchdoPutdoTracegetLastModifiedinitisSensitiveHeaderserviceservice

Field Detail

CONTENTTYPE_VND_GIT_LFS_JSONback to summary
private static final String CONTENTTYPE_VND_GIT_LFS_JSON
LOGback to summary
private static final Logger LOG
SC_BANDWIDTH_LIMIT_EXCEEDEDback to summary
private static final int SC_BANDWIDTH_LIMIT_EXCEEDED
SC_RATE_LIMIT_EXCEEDEDback to summary
private static final int SC_RATE_LIMIT_EXCEEDED
serialVersionUIDback to summary
private static final long serialVersionUID

Hides jakarta.servlet.http.HttpServlet.serialVersionUID.

Constructor Detail

LfsProtocolServletback to summary
public LfsProtocolServlet()

Method Detail

doPostback to summary
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException

Overrides jakarta.servlet.http.HttpServlet.doPost.

Doc from jakarta.servlet.http.HttpServlet.doPost.

Called by the server (via the service method) to allow a servlet to handle a POST request. The HTTP POST method allows the client to send data of unlimited length to the Web server a single time and is useful when posting information such as credit card numbers.

When overriding this method, read the request data, write the response headers, get the response's writer or output stream object, and finally, write the response data. It's best to include content type and encoding. When using a PrintWriter object to return the response, set the content type before accessing the PrintWriter object.

The servlet container must write the headers before committing the response, because in HTTP the headers must be sent before the response body.

Where possible, set the Content-Length header (with the jakarta.servlet.ServletResponse#setContentLength method), to allow the servlet container to use a persistent connection to return its response to the client, improving performance. The content length is automatically set if the entire response fits inside the response buffer.

When using HTTP 1.1 chunked encoding (which means that the response has a Transfer-Encoding header), do not set the Content-Length header.

This method does not need to be either safe or idempotent. Operations requested through POST can have side effects for which the user can be held accountable, for example, updating stored data or buying items online.

If the HTTP POST request is incorrectly formatted, doPost returns an HTTP "Bad Request" message.

Parameters
req:HttpServletRequest

an HttpServletRequest object that contains the request the client has made of the servlet

res:HttpServletResponse

an HttpServletResponse object that contains the response the servlet sends to the client

Annotations
@Override
Exceptions
ServletException:
if the request for the POST could not be handled
IOException:
if an input or output error is detected when the servlet handles the request
getLargeFileRepositoryback to summary
protected abstract LargeFileRepository getLargeFileRepository(LfsProtocolServlet.LfsRequest request, String path, String auth) throws LfsException

Get the large file repository for the given request and path.

Parameters
request:LfsProtocolServlet.LfsRequest

the request

path:String

the path

auth:String

the Authorization HTTP header

Returns:LargeFileRepository

the large file repository storing large files.

Exceptions
LfsException:
implementations should throw more specific exceptions to signal which type of error occurred:
org.eclipse.jgit.lfs.errors.LfsValidationError
when there is a validation error with one or more of the objects in the request
org.eclipse.jgit.lfs.errors.LfsRepositoryNotFound
when the repository does not exist for the user
org.eclipse.jgit.lfs.errors.LfsRepositoryReadOnly
when the user has read, but not write access. Only applicable when the operation in the request is "upload"
org.eclipse.jgit.lfs.errors.LfsRateLimitExceeded
when the user has hit a rate limit with the server
org.eclipse.jgit.lfs.errors.LfsBandwidthLimitExceeded
when the bandwidth limit for the user or repository has been exceeded
org.eclipse.jgit.lfs.errors.LfsInsufficientStorage
when there is insufficient storage on the server
org.eclipse.jgit.lfs.errors.LfsUnavailable
when LFS is not available
org.eclipse.jgit.lfs.errors.LfsException
when an unexpected internal server error occurred
Since
4.7
sendErrorback to summary
private void sendError(HttpServletResponse rsp, Writer writer, int status, String message)
org.eclipse.jgit.lfs.server back to summary

protected Class LfsProtocolServlet.LfsRequest

extends Object
Class Inheritance

LFS request.
Since
4.5

Field Summary

Modifier and TypeField and Description
private List<LfsObject>
private String

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public List<LfsObject>

Returns:

the objects
getObjects
()

Get the LFS objects.

public String

Returns:

the operation
getOperation
()

Get the LFS operation.

public boolean

Returns:

true if the operation is download.
isDownload
()

Whether the operation is download

public boolean

Returns:

true if the operation is upload.
isUpload
()

Whether operation is upload

public boolean

Returns:

true if the operation is verify.
isVerify
()

Whether the operation is verify

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

objectsback to summary
private List<LfsObject> objects
operationback to summary
private String operation

Constructor Detail

LfsRequestback to summary
protected LfsRequest()

Method Detail

getObjectsback to summary
public List<LfsObject> getObjects()

Get the LFS objects.

Returns:List<LfsObject>

the objects

getOperationback to summary
public String getOperation()

Get the LFS operation.

Returns:String

the operation

isDownloadback to summary
public boolean isDownload()

Whether the operation is download

Returns:boolean

true if the operation is download.

Since
4.7
isUploadback to summary
public boolean isUpload()

Whether operation is upload

Returns:boolean

true if the operation is upload.

Since
4.7
isVerifyback to summary
public boolean isVerify()

Whether the operation is verify

Returns:boolean

true if the operation is verify.

Since
4.7