xref: /JGit/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackErrorHandler.java (revision abedaf0d3854f319d0df839851c0e95909aec06a)
1 /*
2  * Copyright (c) 2019, Google LLC  and others
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Distribution License v. 1.0 which is available at
6  * http://www.eclipse.org/org/documents/edl-v10.php.
7  *
8  * SPDX-License-Identifier: BSD-3-Clause
9  */
10 package org.eclipse.jgit.http.server;
11 
12 import java.io.IOException;
13 
14 import javax.servlet.http.HttpServletRequest;
15 import javax.servlet.http.HttpServletResponse;
16 
17 import org.eclipse.jgit.transport.ServiceMayNotContinueException;
18 import org.eclipse.jgit.transport.UploadPack;
19 
20 /**
21  * Handle git-upload-pack errors.
22  *
23  * <p>
24  * This is an entry point for customizing an error handler for git-upload-pack.
25  * Right before calling {@link UploadPack#uploadWithExceptionPropagation}, JGit
26  * will call this handler if specified through {@link GitFilter}. The
27  * implementation of this handler is responsible for calling
28  * {@link UploadPackRunnable} and handling exceptions for clients.
29  *
30  * <p>
31  * If a custom handler is not specified, JGit will use the default error
32  * handler.
33  *
34  * @since 5.6
35  */
36 public interface UploadPackErrorHandler {
37 	/**
38 	 * @param req
39 	 *            The HTTP request
40 	 * @param rsp
41 	 *            The HTTP response
42 	 * @param r
43 	 *            A continuation that handles a git-upload-pack request.
44 	 * @throws IOException
45 	 */
upload(HttpServletRequest req, HttpServletResponse rsp, UploadPackRunnable r)46 	void upload(HttpServletRequest req, HttpServletResponse rsp,
47 			UploadPackRunnable r) throws IOException;
48 
49 	/** Process a git-upload-pack request. */
50 	public interface UploadPackRunnable {
51 		/**
52 		 * See {@link UploadPack#uploadWithExceptionPropagation}.
53 		 *
54 		 * @throws ServiceMayNotContinueException
55 		 * @throws IOException
56 		 */
upload()57 		void upload() throws ServiceMayNotContinueException, IOException;
58 	}
59 }
60