aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs.server
Commit message (Collapse)AuthorAgeFilesLines
* Prepare 4.6.0-SNAPSHOT buildsMatthias Sohn2016-09-192-15/+15
| | | | | Change-Id: Id2eafc331ee32c332c2a9b867b05c260beb0d10f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Improve JavaDoc for LfsProtocolServlet.getLargeFileRepositoryMatthias Sohn2016-09-011-0/+23
| | | | | | Guide implementors which exception to throw in case of errors. Change-Id: I74fb76cdf6b7cdef513f3fe8c144572e869cc533 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Add specific exception for LFS unavailableDavid Pursehouse2016-08-301-10/+11
| | | | | | | | | | | | Instead of returning null, LfsProtocolServlet#getLargeFileRepository should throw LfsUnavailable. If null is returned, throw a generic LfsException. Handle LfsException as an internal server error and return HTTP 500. Change-Id: I33e2a19fcc0fde8aaf0f703860c8fa8ce2de2db5 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LfsProtocolServlet: Add support for insufficient storage errorDavid Pursehouse2016-08-241-0/+4
| | | | | | | | | | | | | Since [1], the git-lfs specification allows the server to return HTTP 507 if there is insufficient storage for the uploaded object(s). Add a new exception class, which implementations may throw from the getRepository() method, causing HTTP 507 to be returned to the client. [1] https://github.com/github/git-lfs/pull/1473 Change-Id: If5bc0a35fcf870d4216af6ca2f7c8924689ef9c5 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LfsProtocolServlet: Add support for rate limit and bandwidth limit errorsDavid Pursehouse2016-08-201-0/+10
| | | | | | | | | | | | | | | | | | | | | | The git-lfs specification [1] describes the following optional status codes that may be returned: 429 - The user has hit a rate limit with the server. Though the API does not specify any rate limits, implementors are encouraged to set some for availability reasons. 509 - Returned if the bandwidth limit for the user or repository has been exceeded. The API does not specify any bandwidth limit, but implementors may track usage. Add two new exception classes to represent these cases. Implementations may throw these from #getLargeFileRepository(), causing the corresponding HTTP status codes to be returned to the client. [1] https://github.com/github/git-lfs/blob/master/docs/api/v1/http-v1-batch.md Change-Id: I7b93f3cf90f7344c90b1587e07927fdeb167097e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LfsProtocolServlet: Always include message in error responseDavid Pursehouse2016-08-201-1/+2
| | | | | | | | | If the message is not sent, the client shows: Unable to parse HTTP response for POST http://admin@localhost:8080/test-project/info/lfs/objects/batch Change-Id: I8b72d1aded2bcd41b7389676e2373034625a1379 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LfsProtocolServlet: Always set the Content-Type header on responseDavid Pursehouse2016-08-161-2/+3
| | | | | | | | | | | If the Content-Type is not set on error responses, the git-lfs client does not read the body which contains the error message, and instead just displays a generic error message. Also set the charset on the Content-Type header. Change-Id: I88e6f07f20b622a670e7c5063145dffb8b630aee Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LfsProtocolServlet: Don't set pretty printing on GsonDavid Pursehouse2016-08-161-5/+4
| | | | | | | | Pretty printing is only used for outputting json content, which is interpreted by the client and does not need to be pretty printed. Change-Id: I48e0280241b6b0f5706300ae0f4c9bc461a89110 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LfsProtocolServlet: Reuse existing Writer when sending error responseDavid Pursehouse2016-08-091-27/+19
| | | | | | | | Trying to open a new writer on the response causes an illegal state exception and the response is not sent. Change-Id: Ic718d23cfb3e74f5691cc2aea7283003af7df207 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Silence API errors in LfsProtocolServletMatthias Sohn2016-08-091-0/+17
| | | | | | | | bb9988c2 changed the signature of getLargeFileRepository() which is only breaking implementors which is ok according to OSGi semantic versioning rules. Change-Id: I68bda7900b72e217571f74aee53705167f8100a2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Add missing @since tags for new APIMatthias Sohn2016-08-092-1/+7
| | | | Change-Id: I8db29a0313fbc476152cef47f2eaa76954f1e280 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* LfsProtocolServlet: Allow access to objects in requestDavid Pursehouse2016-08-052-1/+28
| | | | | | | | | | | Classes implementing the LFS servlet should be able to inspect the objects given in the request. Add a getObjects method. Make the LfsObject class public, and add accessor methods. Change-Id: I27961679f620eb3a89dc8521aadd4ea2f936c60e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LfsProtocolServlet: Allow getLargeFileRepository to raise exceptionsDavid Pursehouse2016-08-051-6/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to the specification [1] the server may return the following HTTP error responses: - 403: The user has read, but not write access. - 404: The repository does not exist for the user. - 422: Validation error with one or more of the objects in the request. In the current implementation, however, getLargeFileRepository can only return null to indicate an error. This results in the error code: - 503: Service Unavailable being returned to the client regardless of what the actual reason was. Add exception classes to cover these cases, derived from a common base exception, and change the specification of getLargeFileRepository to throw the base exception. In LfsProtocolServlet#post, handle the new exceptions and send back the appropriate HTTP responses as mentioned above. The specification also mentions several other optional response codes (406, 429, 501, and 509) but these are not implemented in this commit. It should be trivial to implement them in follow-up commits. [1] https://github.com/github/git-lfs/blob/master/docs/api/v1/http-v1-batch.md#response-errors Change-Id: I91be6165bcaf856d0cefc533882330962e2fc9b2 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Fix typo in email address in copyright headersDavid Pursehouse2016-07-282-2/+2
| | | | | Change-Id: Ib7b73d7d37574682bb58f969822c842e4e579233 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* LfsProtocolServlet: Pass request and path to getLargeFileRepositoryDavid Pursehouse2016-07-271-12/+29
| | | | | | | | | | | | Passing the request and path to the method will allow implementations to have more control over determination of the backend, for example: - return different backends for different requests - accept or refuse requests based on request characteristics - etc Change-Id: I1ec6ec54c91a5f0601b620ed18846eb4a3f46783 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* FileLfsServlet: Include error message in response bodyDavid Pursehouse2016-07-271-3/+29
| | | | | | | | | | According to the specification [1], the error response body must include the error message in json format. [1] https://github.com/github/git-lfs/blob/master/docs/api/v1/http-v1-batch.md#response-errors Change-Id: I79e7a841d230fdedefa53b9c6d2d477e81e1f9e6 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* FileLfsServlet: Return HTTP 422 instead of 400David Pursehouse2016-07-271-2/+2
| | | | | | | | | | | According to the specification [1], the error response status code should be 422 when there is a validation error with one or more of the objects in the request [1] https://github.com/github/git-lfs/blob/master/docs/api/v1/http-v1-batch.md#response-errors Change-Id: Id03fe00a2109b896d9a154228a14a33bce5accc3 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Ignore 'The value of exception parameter is not used' warningDavid Pursehouse2016-07-261-0/+1
| | | | | Change-Id: I50407e4a33e35b718ca40503fdd436f1f9f70fba Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Update links to LFS API documentationDavid Pursehouse2016-07-262-2/+2
| | | | | | | | The location of the API v1 documentation has changed. Update the links accordingly. Change-Id: If0148a0b573c474bbe157fcb7e6674c0055fe8b4 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Remove duplicated single quotes in text not handled by MessageFormatMarkus Keller2016-07-011-5/+5
| | | | | Change-Id: I4b803b34d30a86105d111be417d4a4e6bfb1057b Signed-off-by: Markus Keller <markus_keller@ch.ibm.com>
* Prepare 4.5.0-SNAPSHOT buildsMatthias Sohn2016-06-012-15/+15
| | | | | Change-Id: I572fe9fea0e5ca0bec4648c916ae95a5b1ccf125 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* [findBugs] Prevent potential NPE in FileLfsRepository.getOutputStream()Matthias Sohn2016-05-301-1/+4
| | | | Change-Id: I6f91997e8a976e5f4ace91c082d8b9adf1451adc Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* [findBugs] Fix calculation of host header in SignerV4Matthias Sohn2016-05-191-3/+3
| | | | | | | | We ignored the returned concatenation of host name and port number. Fix this and use a StringBuilder to avoid creation of unnecessary String objects. Change-Id: I61fac639d4a4c95412eb41a0f9131d0c38aca794 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Prepare 4.4.0-SNAPSHOT buildsMatthias Sohn2016-04-082-15/+15
| | | | | Change-Id: If3162f4cc4ae6319b9f1e3293549485b039cfe7f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Prepare 4.3.1-SNAPSHOT versionsMatthias Sohn2016-04-082-15/+15
| | | | | Change-Id: I52c98ba8fb3a303269a1f9380af114b6dd8c5009 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* JGit v4.3.0.201604071810-rv4.3.0.201604071810-rMatthias Sohn2016-04-082-2/+2
| | | | | Change-Id: I902cdf1ff92ce8c6e9d80c4965d8d5bd8b9ac6c1 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* JGit v4.3.0.201604071045-rMatthias Sohn2016-04-072-2/+2
| | | | | Change-Id: Iafab78d6be34d31a13f979b7be67611135c0f8bd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Prepare 4.3-SNAPSHOT buildsMatthias Sohn2016-04-052-2/+2
| | | | | Change-Id: Ib831f8870938113bd5338763f90a07d5c108b1de Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* JGit v4.3.0.201603230630-rc1v4.3.0.201603230630-rc1Matthias Sohn2016-03-232-2/+2
| | | | | Change-Id: I10835e5aa3618e5033424595942cc1649152cb24 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Make the FileLfsRepository thread safeSaša Živkov2016-03-222-25/+12
| | | | | | | | | | | | | | The FileLfsRepository.out member could have been accessed from multiple threads which would corrupt the content. Don't store the AtomicObjectOutputStream in the FileLfsRepository.out but move it to the ObjectUploadListener which is instantiated per-request. Add a parallel upload test. Change-Id: I62298630e99c46b500d376843ffcde934436215b Signed-off-by: Saša Živkov <sasa.zivkov@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Support Amazon S3 based storage for LFSMatthias Sohn2016-02-177-1/+808
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a storage implementation storing large objects in Amazon S3. The AmazonS3Repository pre-signs download and upload requests. AWS access and secret key are expected to be in the $HOME/.aws/credentials file in the following format: [default] accessKey = ... secretKey = ... Use AWS version 4 request signing [1] because it is more secure and supported by all regions. The version 3 signing is not supported in newer regions. In follow up changes we should: - implement getVerifyAction() and do actual verification. Subclasses of S3Repository can implement caching for object meta data (size) in order to avoid extra roundtrips to S3. Verification should ensure that meta data store and content of S3 storage are in sync - HEAD request used in S3Repository.getSize() seems to always return Content-length 0 in contrast to the documentation [2]. So getSize() does detect if the object exists in S3 or not but in case the object exists it always returns size 0 [1] http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html [2] https://forums.aws.amazon.com/thread.jspa?threadID=223616 Change-Id: Ic47f094928a259e5264c92b3aacf6d90210907a8 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
* Support LFS protocol and a file system based LFS storageMatthias Sohn2016-02-0430-0/+2395
Implement LfsProtocolServlet handling the "Git LFS v1 Batch API" protocol [1]. Add a simple file system based LFS content store and the debug-lfs-store command to simplify testing. Introduce a LargeFileRepository interface to enable additional storage implementation while reusing the same protocol implementation. At the client side we have to configure the lfs.url, specify that we use the batch API and we don't use authentication: [lfs] url = http://host:port/lfs batch = true [lfs "http://host:port/lfs"] access = none the git-lfs client appends the "objects/batch" to the lfs.url. Hard code an Authorization header in the FileLfsRepository.getAction because then git-lfs client will skip asking for credentials. It will just forward the Authorization header from the response to the download/upload request. The FileLfsServlet supports file content storage for "Large File Storage" (LFS) server as defined by the Github LFS API [2]. - upload and download of large files is probably network bound hence use an asynchronous servlet for good scalability - simple object storage in file system with 2 level fan-out - use LockFile to protect writing large objects against multiple concurrent uploads of the same object - to prevent corrupt uploads the uploaded file is rejected if its hash doesn't match id given in URL The debug-lfs-store command is used to run the LfsProtocolServlet and, optionally, the FileLfsServlet which makes it easier to setup a local test server. [1] https://github.com/github/git-lfs/blob/master/docs/api/http-v1-batch.md [2] https://github.com/github/git-lfs/tree/master/docs/api Bug: 472961 Change-Id: I7378da5575159d2195138d799704880c5c82d5f3 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>