diff options
Diffstat (limited to 'org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs')
4 files changed, 40 insertions, 62 deletions
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 { |