1 /* 2 * Copyright (C) 2009-2010, Google Inc. 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 * https://www.eclipse.org/org/documents/edl-v10.php. 7 * 8 * SPDX-License-Identifier: BSD-3-Clause 9 */ 10 11 package org.eclipse.jgit.transport.resolver; 12 13 import org.eclipse.jgit.lib.Repository; 14 import org.eclipse.jgit.transport.ReceivePack; 15 16 /** 17 * Create and configure {@link org.eclipse.jgit.transport.ReceivePack} service 18 * instance. 19 * 20 * @param <C> 21 * type of connection 22 */ 23 public interface ReceivePackFactory<C> { 24 /** 25 * A factory disabling the ReceivePack service for all repositories 26 */ 27 ReceivePackFactory<?> DISABLED = (Object req, Repository db) -> { 28 throw new ServiceNotEnabledException(); 29 }; 30 31 /** 32 * Create and configure a new ReceivePack instance for a repository. 33 * 34 * @param req 35 * current request, in case information from the request may help 36 * configure the ReceivePack instance. 37 * @param db 38 * the repository the receive would write into. 39 * @return the newly configured ReceivePack instance, must not be null. 40 * @throws ServiceNotEnabledException 41 * this factory refuses to create the instance because it is not 42 * allowed on the target repository, by any user. 43 * @throws ServiceNotAuthorizedException 44 * this factory refuses to create the instance for this HTTP 45 * request and repository, such as due to a permission error. 46 */ 47 ReceivePack create(C req, Repository db) throws ServiceNotEnabledException, 48 ServiceNotAuthorizedException; 49 }