Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.lfs.server')
-rw-r--r--org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF31
-rw-r--r--org.eclipse.jgit.lfs.server/pom.xml2
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java10
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsObject.java4
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java67
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/Response.java7
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java8
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java54
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java13
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectUploadListener.java27
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/internal/LfsGson.java120
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/internal/LfsServerText.java2
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Config.java14
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Repository.java4
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java8
15 files changed, 240 insertions, 131 deletions
diff --git a/org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF b/org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF
index f4e8f775db..ddd35a4c9e 100644
--- a/org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF
@@ -1,20 +1,21 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin_name
+Automatic-Module-Name: org.eclipse.jgit.lfs.server
Bundle-SymbolicName: org.eclipse.jgit.lfs.server
-Bundle-Version: 4.9.11.qualifier
+Bundle-Version: 4.10.1.qualifier
Bundle-Localization: plugin
Bundle-Vendor: %provider_name
-Export-Package: org.eclipse.jgit.lfs.server;version="4.9.11";
+Export-Package: org.eclipse.jgit.lfs.server;version="4.10.1";
uses:="javax.servlet.http,
org.eclipse.jgit.lfs.lib",
- org.eclipse.jgit.lfs.server.fs;version="4.9.11";
+ org.eclipse.jgit.lfs.server.fs;version="4.10.1";
uses:="javax.servlet,
javax.servlet.http,
org.eclipse.jgit.lfs.server,
org.eclipse.jgit.lfs.lib",
- org.eclipse.jgit.lfs.server.internal;version="4.9.11";x-internal:=true,
- org.eclipse.jgit.lfs.server.s3;version="4.9.11";
+ org.eclipse.jgit.lfs.server.internal;version="4.10.1";x-internal:=true,
+ org.eclipse.jgit.lfs.server.s3;version="4.10.1";
uses:="org.eclipse.jgit.lfs.server,
org.eclipse.jgit.lfs.lib"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
@@ -24,14 +25,14 @@ Import-Package: com.google.gson;version="[2.2.4,3.0.0)",
javax.servlet.http;version="[3.1.0,4.0.0)",
org.apache.http;version="[4.3.0,5.0.0)",
org.apache.http.client;version="[4.3.0,5.0.0)",
- org.eclipse.jgit.annotations;version="[4.9.11,4.10.0)",
- org.eclipse.jgit.internal;version="[4.9.11,4.10.0)",
- org.eclipse.jgit.internal.storage.file;version="[4.9.11,4.10.0)",
- org.eclipse.jgit.lfs.errors;version="[4.9.11,4.10.0)",
- org.eclipse.jgit.lfs.internal;version="[4.9.11,4.10.0)",
- org.eclipse.jgit.lfs.lib;version="[4.9.11,4.10.0)",
- org.eclipse.jgit.nls;version="[4.9.11,4.10.0)",
- org.eclipse.jgit.transport.http;version="[4.9.11,4.10.0)",
- org.eclipse.jgit.transport.http.apache;version="[4.9.11,4.10.0)",
- org.eclipse.jgit.util;version="[4.9.11,4.10.0)",
+ org.eclipse.jgit.annotations;version="[4.10.1,4.11.0)",
+ org.eclipse.jgit.internal;version="[4.10.1,4.11.0)",
+ org.eclipse.jgit.internal.storage.file;version="[4.10.1,4.11.0)",
+ org.eclipse.jgit.lfs.errors;version="[4.10.1,4.11.0)",
+ org.eclipse.jgit.lfs.internal;version="[4.10.1,4.11.0)",
+ org.eclipse.jgit.lfs.lib;version="[4.10.1,4.11.0)",
+ org.eclipse.jgit.nls;version="[4.10.1,4.11.0)",
+ org.eclipse.jgit.transport.http;version="[4.10.1,4.11.0)",
+ org.eclipse.jgit.transport.http.apache;version="[4.10.1,4.11.0)",
+ org.eclipse.jgit.util;version="[4.10.1,4.11.0)",
org.slf4j;version="[1.7.0,2.0.0)"
diff --git a/org.eclipse.jgit.lfs.server/pom.xml b/org.eclipse.jgit.lfs.server/pom.xml
index 415b34f052..351802d782 100644
--- a/org.eclipse.jgit.lfs.server/pom.xml
+++ b/org.eclipse.jgit.lfs.server/pom.xml
@@ -50,7 +50,7 @@
<parent>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit-parent</artifactId>
- <version>4.9.11-SNAPSHOT</version>
+ <version>4.10.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.jgit.lfs.server</artifactId>
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java
index 3bdf8d08b2..cfa53af9cd 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java
@@ -55,6 +55,8 @@ import org.eclipse.jgit.lfs.lib.AnyLongObjectId;
public interface LargeFileRepository {
/**
+ * Get download action
+ *
* @param id
* id of the object to download
* @return Action for downloading the object
@@ -62,6 +64,8 @@ public interface LargeFileRepository {
public Response.Action getDownloadAction(AnyLongObjectId id);
/**
+ * Get upload action
+ *
* @param id
* id of the object to upload
* @param size
@@ -71,6 +75,8 @@ public interface LargeFileRepository {
public Response.Action getUploadAction(AnyLongObjectId id, long size);
/**
+ * Get verify action
+ *
* @param id
* id of the object to be verified
* @return Action for verifying the object, or {@code null} if the server
@@ -79,11 +85,13 @@ public interface LargeFileRepository {
public @Nullable Response.Action getVerifyAction(AnyLongObjectId id);
/**
+ * Get size of an object
+ *
* @param id
* id of the object
* @return length of the object content in bytes, -1 if the object doesn't
* exist
- * @throws IOException
+ * @throws java.io.IOException
*/
public long getSize(AnyLongObjectId id) throws IOException;
}
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsObject.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsObject.java
index 4d975024e6..907e156035 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsObject.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsObject.java
@@ -52,6 +52,8 @@ public class LfsObject {
long size;
/**
+ * Get the <code>oid</code> of this object.
+ *
* @return the object ID.
*/
public String getOid() {
@@ -59,6 +61,8 @@ public class LfsObject {
}
/**
+ * Get the <code>size</code> of this object.
+ *
* @return the object size.
*/
public long getSize() {
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
index 2473dcdc8c..6968d75636 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
@@ -81,13 +81,10 @@ import org.eclipse.jgit.lfs.errors.LfsUnauthorized;
import org.eclipse.jgit.lfs.errors.LfsUnavailable;
import org.eclipse.jgit.lfs.errors.LfsValidationError;
import org.eclipse.jgit.lfs.internal.LfsText;
+import org.eclipse.jgit.lfs.server.internal.LfsGson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.FieldNamingPolicy;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
/**
* LFS protocol handler implementing the LFS batch API [1]
*
@@ -108,8 +105,6 @@ public abstract class LfsProtocolServlet extends HttpServlet {
private static final int SC_BANDWIDTH_LIMIT_EXCEEDED = 509;
- private Gson gson = createGson();
-
/**
* Get the large file repository for the given request and path.
*
@@ -117,30 +112,29 @@ public abstract class LfsProtocolServlet extends HttpServlet {
* the request
* @param path
* the path
- *
* @return the large file repository storing large files.
- * @throws LfsException
+ * @throws org.eclipse.jgit.lfs.errors.LfsException
* implementations should throw more specific exceptions to
* signal which type of error occurred:
* <dl>
- * <dt>{@link LfsValidationError}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsValidationError}</dt>
* <dd>when there is a validation error with one or more of the
* objects in the request</dd>
- * <dt>{@link LfsRepositoryNotFound}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsRepositoryNotFound}</dt>
* <dd>when the repository does not exist for the user</dd>
- * <dt>{@link LfsRepositoryReadOnly}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsRepositoryReadOnly}</dt>
* <dd>when the user has read, but not write access. Only
* applicable when the operation in the request is "upload"</dd>
- * <dt>{@link LfsRateLimitExceeded}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsRateLimitExceeded}</dt>
* <dd>when the user has hit a rate limit with the server</dd>
- * <dt>{@link LfsBandwidthLimitExceeded}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsBandwidthLimitExceeded}</dt>
* <dd>when the bandwidth limit for the user or repository has
* been exceeded</dd>
- * <dt>{@link LfsInsufficientStorage}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsInsufficientStorage}</dt>
* <dd>when there is insufficient storage on the server</dd>
- * <dt>{@link LfsUnavailable}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsUnavailable}</dt>
* <dd>when LFS is not available</dd>
- * <dt>{@link LfsException}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsException}</dt>
* <dd>when an unexpected internal server error occurred</dd>
* </dl>
* @since 4.5
@@ -162,30 +156,29 @@ public abstract class LfsProtocolServlet extends HttpServlet {
* the path
* @param auth
* the Authorization HTTP header
- *
* @return the large file repository storing large files.
- * @throws LfsException
+ * @throws org.eclipse.jgit.lfs.errors.LfsException
* implementations should throw more specific exceptions to
* signal which type of error occurred:
* <dl>
- * <dt>{@link LfsValidationError}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsValidationError}</dt>
* <dd>when there is a validation error with one or more of the
* objects in the request</dd>
- * <dt>{@link LfsRepositoryNotFound}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsRepositoryNotFound}</dt>
* <dd>when the repository does not exist for the user</dd>
- * <dt>{@link LfsRepositoryReadOnly}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsRepositoryReadOnly}</dt>
* <dd>when the user has read, but not write access. Only
* applicable when the operation in the request is "upload"</dd>
- * <dt>{@link LfsRateLimitExceeded}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsRateLimitExceeded}</dt>
* <dd>when the user has hit a rate limit with the server</dd>
- * <dt>{@link LfsBandwidthLimitExceeded}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsBandwidthLimitExceeded}</dt>
* <dd>when the bandwidth limit for the user or repository has
* been exceeded</dd>
- * <dt>{@link LfsInsufficientStorage}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsInsufficientStorage}</dt>
* <dd>when there is insufficient storage on the server</dd>
- * <dt>{@link LfsUnavailable}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsUnavailable}</dt>
* <dd>when LFS is not available</dd>
- * <dt>{@link LfsException}</dt>
+ * <dt>{@link org.eclipse.jgit.lfs.errors.LfsException}</dt>
* <dd>when an unexpected internal server error occurred</dd>
* </dl>
* @since 4.7
@@ -246,6 +239,7 @@ public abstract class LfsProtocolServlet extends HttpServlet {
}
}
+ /** {@inheritDoc} */
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
@@ -254,7 +248,7 @@ public abstract class LfsProtocolServlet extends HttpServlet {
Reader r = new BufferedReader(
new InputStreamReader(req.getInputStream(), UTF_8));
- LfsRequest request = gson.fromJson(r, LfsRequest.class);
+ LfsRequest request = LfsGson.fromJson(r, LfsRequest.class);
String path = req.getPathInfo();
res.setContentType(CONTENTTYPE_VND_GIT_LFS_JSON);
@@ -271,7 +265,7 @@ public abstract class LfsProtocolServlet extends HttpServlet {
res.setStatus(SC_OK);
TransferHandler handler = TransferHandler
.forOperation(request.operation, repo, request.objects);
- gson.toJson(handler.process(), w);
+ LfsGson.toJson(handler.process(), w);
} catch (LfsValidationError e) {
sendError(res, w, SC_UNPROCESSABLE_ENTITY, e.getMessage());
} catch (LfsRepositoryNotFound e) {
@@ -295,24 +289,9 @@ public abstract class LfsProtocolServlet extends HttpServlet {
}
}
- static class Error {
- String message;
-
- Error(String m) {
- this.message = m;
- }
- }
-
private void sendError(HttpServletResponse rsp, Writer writer, int status,
String message) {
rsp.setStatus(status);
- gson.toJson(new Error(message), writer);
- }
-
- private Gson createGson() {
- return new GsonBuilder()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
- .disableHtmlEscaping()
- .create();
+ LfsGson.toJson(message, writer);
}
}
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/Response.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/Response.java
index dc972e04ee..a80e5b9c3c 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/Response.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/Response.java
@@ -46,11 +46,10 @@ import java.util.List;
import java.util.Map;
/**
- * POJOs for Gson serialization/deserialization
+ * POJOs for Gson serialization/de-serialization.
*
- * See
- * {@link <a href="https://github.com/github/git-lfs/tree/master/docs/api">LFS
- * API specification</a>}
+ * See the <a href="https://github.com/github/git-lfs/tree/master/docs/api">LFS
+ * API specification</a>
*
* @since 4.3
*/
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java
index a05fa01424..5b12be6651 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java
@@ -71,11 +71,13 @@ public class FileLfsRepository implements LargeFileRepository {
private final Path dir;
/**
+ * <p>Constructor for FileLfsRepository.</p>
+ *
* @param url
* external URL of this repository
* @param dir
* storage directory
- * @throws IOException
+ * @throws java.io.IOException
*/
public FileLfsRepository(String url, Path dir) throws IOException {
this.url = url;
@@ -83,21 +85,25 @@ public class FileLfsRepository implements LargeFileRepository {
Files.createDirectories(dir);
}
+ /** {@inheritDoc} */
@Override
public Response.Action getDownloadAction(AnyLongObjectId id) {
return getAction(id);
}
+ /** {@inheritDoc} */
@Override
public Action getUploadAction(AnyLongObjectId id, long size) {
return getAction(id);
}
+ /** {@inheritDoc} */
@Override
public @Nullable Action getVerifyAction(AnyLongObjectId id) {
return null;
}
+ /** {@inheritDoc} */
@Override
public long getSize(AnyLongObjectId id) throws IOException {
Path p = getPath(id);
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java
index d02d466021..b805ef5396 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsServlet.java
@@ -58,12 +58,9 @@ import org.eclipse.jgit.lfs.errors.InvalidLongObjectIdException;
import org.eclipse.jgit.lfs.lib.AnyLongObjectId;
import org.eclipse.jgit.lfs.lib.Constants;
import org.eclipse.jgit.lfs.lib.LongObjectId;
+import org.eclipse.jgit.lfs.server.internal.LfsGson;
import org.eclipse.jgit.lfs.server.internal.LfsServerText;
-import com.google.gson.FieldNamingPolicy;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
/**
* Servlet supporting upload and download of large objects as defined by the
* GitHub Large File Storage extension API extending git to allow separate
@@ -81,9 +78,9 @@ public class FileLfsServlet extends HttpServlet {
private final long timeout;
- private static Gson gson = createGson();
-
/**
+ * <p>Constructor for FileLfsServlet.</p>
+ *
* @param repository
* the repository storing the large objects
* @param timeout
@@ -95,16 +92,9 @@ public class FileLfsServlet extends HttpServlet {
}
/**
- * Handles object downloads
+ * {@inheritDoc}
*
- * @param req
- * servlet request
- * @param rsp
- * servlet response
- * @throws ServletException
- * if a servlet-specific error occurs
- * @throws IOException
- * if an I/O error occurs
+ * Handle object downloads
*/
@Override
protected void doGet(HttpServletRequest req,
@@ -134,9 +124,9 @@ public class FileLfsServlet extends HttpServlet {
* servlet response
* @return object id, or <code>null</code> if the object id could not be
* retrieved
- * @throws IOException
+ * @throws java.io.IOException
* if an I/O error occurs
- * @since 4.6
+ * @since 4.6
*/
protected AnyLongObjectId getObjectToTransfer(HttpServletRequest req,
HttpServletResponse rsp) throws IOException {
@@ -156,16 +146,9 @@ public class FileLfsServlet extends HttpServlet {
}
/**
- * Handle object uploads
+ * {@inheritDoc}
*
- * @param req
- * servlet request
- * @param rsp
- * servlet response
- * @throws ServletException
- * if a servlet-specific error occurs
- * @throws IOException
- * if an I/O error occurs
+ * Handle object uploads
*/
@Override
protected void doPut(HttpServletRequest req,
@@ -179,14 +162,6 @@ public class FileLfsServlet extends HttpServlet {
}
}
- static class Error {
- String message;
-
- Error(String m) {
- this.message = m;
- }
- }
-
/**
* Send an error response.
*
@@ -196,7 +171,7 @@ public class FileLfsServlet extends HttpServlet {
* HTTP status code
* @param message
* error message
- * @throws IOException
+ * @throws java.io.IOException
* on failure to send the response
* @since 4.6
*/
@@ -209,16 +184,9 @@ public class FileLfsServlet extends HttpServlet {
rsp.reset();
rsp.setStatus(status);
PrintWriter writer = rsp.getWriter();
- gson.toJson(new Error(message), writer);
+ LfsGson.toJson(message, writer);
writer.flush();
writer.close();
rsp.flushBuffer();
}
-
- private static Gson createGson() {
- return new GsonBuilder()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
- .disableHtmlEscaping()
- .create();
- }
}
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java
index a76f7ef0d8..06a7726955 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java
@@ -83,6 +83,8 @@ public class ObjectDownloadListener implements WriteListener {
private ByteBuffer buffer = ByteBuffer.allocateDirect(8192);
/**
+ * <p>Constructor for ObjectDownloadListener.</p>
+ *
* @param repository
* the repository storing large objects
* @param context
@@ -91,7 +93,7 @@ public class ObjectDownloadListener implements WriteListener {
* the servlet response
* @param id
* id of the object to be downloaded
- * @throws IOException
+ * @throws java.io.IOException
*/
public ObjectDownloadListener(FileLfsRepository repository,
AsyncContext context, HttpServletResponse response,
@@ -108,9 +110,9 @@ public class ObjectDownloadListener implements WriteListener {
}
/**
- * Write file content
+ * {@inheritDoc}
*
- * @throws IOException
+ * Write file content
*/
@Override
public void onWritePossible() throws IOException {
@@ -150,10 +152,9 @@ public class ObjectDownloadListener implements WriteListener {
}
/**
- * Handle errors
+ * {@inheritDoc}
*
- * @param e
- * the cause
+ * Handle errors
*/
@Override
public void onError(Throwable e) {
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectUploadListener.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectUploadListener.java
index da86880472..c5b6a67876 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectUploadListener.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectUploadListener.java
@@ -88,14 +88,20 @@ public class ObjectUploadListener implements ReadListener {
private final ByteBuffer buffer = ByteBuffer.allocateDirect(8192);
/**
+ * Constructor for ObjectUploadListener.
+ *
* @param repository
* the repository storing large objects
* @param context
+ * a {@link javax.servlet.AsyncContext} object.
* @param request
+ * a {@link javax.servlet.http.HttpServletRequest} object.
* @param response
+ * a {@link javax.servlet.http.HttpServletResponse} object.
* @param id
- * @throws FileNotFoundException
- * @throws IOException
+ * a {@link org.eclipse.jgit.lfs.lib.AnyLongObjectId} object.
+ * @throws java.io.FileNotFoundException
+ * @throws java.io.IOException
*/
public ObjectUploadListener(FileLfsRepository repository,
AsyncContext context, HttpServletRequest request,
@@ -111,9 +117,9 @@ public class ObjectUploadListener implements ReadListener {
}
/**
- * Writes all the received data to the output channel
+ * {@inheritDoc}
*
- * @throws IOException
+ * Writes all the received data to the output channel
*/
@Override
public void onDataAvailable() throws IOException {
@@ -133,16 +139,16 @@ public class ObjectUploadListener implements ReadListener {
}
}
- /**
- * @throws IOException
- */
+ /** {@inheritDoc} */
@Override
public void onAllDataRead() throws IOException {
close();
}
/**
- * @throws IOException
+ * Close resources held by this listener
+ *
+ * @throws java.io.IOException
*/
protected void close() throws IOException {
try {
@@ -158,10 +164,7 @@ public class ObjectUploadListener implements ReadListener {
}
}
- /**
- * @param e
- * the exception that caused the problem
- */
+ /** {@inheritDoc} */
@Override
public void onError(Throwable e) {
try {
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/internal/LfsGson.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/internal/LfsGson.java
new file mode 100644
index 0000000000..7974b24124
--- /dev/null
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/internal/LfsGson.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2017, David Pursehouse <david.pursehouse@gmail.com>
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.lfs.server.internal;
+
+import java.io.Reader;
+
+import com.google.gson.FieldNamingPolicy;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonIOException;
+import com.google.gson.JsonSyntaxException;
+
+/**
+ * Wrapper for {@link com.google.gson.Gson} used by LFS servlets.
+ *
+ * @since 4.10.0
+ */
+public class LfsGson {
+ private static final Gson gson = new GsonBuilder()
+ .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
+ .disableHtmlEscaping()
+ .create();
+
+ /**
+ * Wrapper class only used for serialization of error messages.
+ */
+ static class Error {
+ String message;
+
+ Error(String m) {
+ this.message = m;
+ }
+ }
+
+ /**
+ * Serializes the specified object into its equivalent Json representation.
+ *
+ * @param src
+ * the object for which Json representation is to be created. If
+ * this is a String, it is wrapped in an instance of
+ * {@link org.eclipse.jgit.lfs.server.internal.LfsGson.Error}.
+ * @param writer
+ * Writer to which the Json representation needs to be written
+ * @throws com.google.gson.JsonIOException
+ * if there was a problem writing to the writer
+ * @see Gson#toJson(Object, Appendable)
+ */
+ public static void toJson(Object src, Appendable writer)
+ throws JsonIOException {
+ if (src instanceof String) {
+ gson.toJson(new Error((String) src), writer);
+ } else {
+ gson.toJson(src, writer);
+ }
+ }
+
+ /**
+ * Deserializes the Json read from the specified reader into an object of
+ * the specified type.
+ *
+ * @param json
+ * reader producing json from which the object is to be
+ * deserialized
+ * @param classOfT
+ * specified type to deserialize
+ * @return an Object of type T
+ * @throws com.google.gson.JsonIOException
+ * if there was a problem reading from the Reader
+ * @throws com.google.gson.JsonSyntaxException
+ * if json is not a valid representation for an object of type
+ * @see Gson#fromJson(Reader, java.lang.reflect.Type)
+ * @param <T>
+ * a T object.
+ */
+ public static <T> T fromJson(Reader json, Class<T> classOfT)
+ throws JsonSyntaxException, JsonIOException {
+ return gson.fromJson(json, classOfT);
+ }
+}
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/internal/LfsServerText.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/internal/LfsServerText.java
index 2e088fde8d..5d6bbfa020 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/internal/LfsServerText.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/internal/LfsServerText.java
@@ -51,6 +51,8 @@ import org.eclipse.jgit.nls.TranslationBundle;
public class LfsServerText extends TranslationBundle {
/**
+ * Get an instance of this translation bundle
+ *
* @return an instance of this translation bundle
*/
public static LfsServerText get() {
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Config.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Config.java
index 4876fb8cb5..4c2142196e 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Config.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Config.java
@@ -58,6 +58,8 @@ public class S3Config {
private final boolean disableSslVerify;
/**
+ * <p>Constructor for S3Config.</p>
+ *
* @param region
* AWS region
* @param bucket
@@ -88,6 +90,8 @@ public class S3Config {
}
/**
+ * Get the <code>region</code>.
+ *
* @return Get name of AWS region this bucket resides in
*/
public String getRegion() {
@@ -95,6 +99,8 @@ public class S3Config {
}
/**
+ * Get the <code>bucket</code>.
+ *
* @return Get S3 storage bucket name
*/
public String getBucket() {
@@ -102,6 +108,8 @@ public class S3Config {
}
/**
+ * Get the <code>storageClass</code>.
+ *
* @return S3 storage class to use for objects stored in this bucket
*/
public String getStorageClass() {
@@ -109,6 +117,8 @@ public class S3Config {
}
/**
+ * Get the <code>accessKey</code>.
+ *
* @return access key for authenticating to AWS
*/
public String getAccessKey() {
@@ -116,6 +126,8 @@ public class S3Config {
}
/**
+ * Get the <code>secretKey</code>.
+ *
* @return secret key for authenticating to AWS
*/
public String getSecretKey() {
@@ -123,6 +135,8 @@ public class S3Config {
}
/**
+ * Get the <code>expirationSeconds</code>.
+ *
* @return period in seconds after which requests signed for this bucket
* will expire
*/
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Repository.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Repository.java
index ed896adff2..043d3d0a34 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Repository.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/S3Repository.java
@@ -91,6 +91,7 @@ public class S3Repository implements LargeFileRepository {
this.s3Config = config;
}
+ /** {@inheritDoc} */
@Override
public Response.Action getDownloadAction(AnyLongObjectId oid) {
URL endpointUrl = getObjectUrl(oid);
@@ -107,6 +108,7 @@ public class S3Repository implements LargeFileRepository {
return a;
}
+ /** {@inheritDoc} */
@Override
public Response.Action getUploadAction(AnyLongObjectId oid, long size) {
cacheObjectMetaData(oid, size);
@@ -126,11 +128,13 @@ public class S3Repository implements LargeFileRepository {
return a;
}
+ /** {@inheritDoc} */
@Override
public Action getVerifyAction(AnyLongObjectId id) {
return null; // TODO(ms) implement this
}
+ /** {@inheritDoc} */
@Override
public long getSize(AnyLongObjectId oid) throws IOException {
URL endpointUrl = getObjectUrl(oid);
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java
index a9b0ec46e4..b21c94e4e6 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java
@@ -43,12 +43,12 @@
*/
package org.eclipse.jgit.lfs.server.s3;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.util.HttpSupport.HDR_AUTHORIZATION;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
@@ -359,13 +359,13 @@ class SignerV4 {
private static byte[] hash(String s) {
MessageDigest md = Constants.newMessageDigest();
- md.update(s.getBytes(StandardCharsets.UTF_8));
+ md.update(s.getBytes(UTF_8));
return md.digest();
}
private static byte[] sign(String stringData, byte[] key) {
try {
- byte[] data = stringData.getBytes("UTF-8"); //$NON-NLS-1$
+ byte[] data = stringData.getBytes(UTF_8);
Mac mac = Mac.getInstance(HMACSHA256);
mac.init(new SecretKeySpec(key, HMACSHA256));
return mac.doFinal(data);
@@ -395,7 +395,7 @@ class SignerV4 {
private static String urlEncode(String url, boolean keepPathSlash) {
String encoded;
try {
- encoded = URLEncoder.encode(url, StandardCharsets.UTF_8.name());
+ encoded = URLEncoder.encode(url, UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(LfsServerText.get().unsupportedUtf8, e);
}

Back to the top