aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/ReceivePackFactory.java
blob: 69bfbc820663e1d325f16c80b9b48d7bb2258e49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Copyright (C) 2009-2010, Google Inc. and others
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0 which is available at
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package org.eclipse.jgit.transport.resolver;

import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.ReceivePack;

/**
 * Create and configure {@link org.eclipse.jgit.transport.ReceivePack} service
 * instance.
 *
 * @param <C>
 *            type of connection
 */
public interface ReceivePackFactory<C> {
	/**
	 * A factory disabling the ReceivePack service for all repositories
	 */
	ReceivePackFactory<?> DISABLED = (Object req, Repository db) -> {
		throw new ServiceNotEnabledException();
	};

	/**
	 * Create and configure a new ReceivePack instance for a repository.
	 *
	 * @param req
	 *            current request, in case information from the request may help
	 *            configure the ReceivePack instance.
	 * @param db
	 *            the repository the receive would write into.
	 * @return the newly configured ReceivePack instance, must not be null.
	 * @throws ServiceNotEnabledException
	 *             this factory refuses to create the instance because it is not
	 *             allowed on the target repository, by any user.
	 * @throws ServiceNotAuthorizedException
	 *             this factory refuses to create the instance for this HTTP
	 *             request and repository, such as due to a permission error.
	 */
	ReceivePack create(C req, Repository db) throws ServiceNotEnabledException,
			ServiceNotAuthorizedException;
}