View Javadoc
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.UploadPack;
15  
16  /**
17   * Create and configure {@link org.eclipse.jgit.transport.UploadPack} service
18   * instance.
19   *
20   * @param <C>
21   *            the connection type
22   */
23  public interface UploadPackFactory<C> {
24  	/**
25  	 * A factory disabling the UploadPack service for all repositories.
26  	 */
27  	UploadPackFactory<?> DISABLED = (Object req, Repository db) -> {
28  		throw new ServiceNotEnabledException();
29  	};
30  
31  	/**
32  	 * Create and configure a new UploadPack instance for a repository.
33  	 *
34  	 * @param req
35  	 *            current request, in case information from the request may help
36  	 *            configure the UploadPack instance.
37  	 * @param db
38  	 *            the repository the upload would read from.
39  	 * @return the newly configured UploadPack 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  	UploadPack create(C req, Repository db) throws ServiceNotEnabledException,
48  			ServiceNotAuthorizedException;
49  }