UploadPackFactory.java

  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. package org.eclipse.jgit.transport.resolver;

  11. import org.eclipse.jgit.lib.Repository;
  12. import org.eclipse.jgit.transport.UploadPack;

  13. /**
  14.  * Create and configure {@link org.eclipse.jgit.transport.UploadPack} service
  15.  * instance.
  16.  *
  17.  * @param <C>
  18.  *            the connection type
  19.  */
  20. public interface UploadPackFactory<C> {
  21.     /**
  22.      * A factory disabling the UploadPack service for all repositories.
  23.      */
  24.     UploadPackFactory<?> DISABLED = (Object req, Repository db) -> {
  25.         throw new ServiceNotEnabledException();
  26.     };

  27.     /**
  28.      * Create and configure a new UploadPack instance for a repository.
  29.      *
  30.      * @param req
  31.      *            current request, in case information from the request may help
  32.      *            configure the UploadPack instance.
  33.      * @param db
  34.      *            the repository the upload would read from.
  35.      * @return the newly configured UploadPack instance, must not be null.
  36.      * @throws ServiceNotEnabledException
  37.      *             this factory refuses to create the instance because it is not
  38.      *             allowed on the target repository, by any user.
  39.      * @throws ServiceNotAuthorizedException
  40.      *             this factory refuses to create the instance for this HTTP
  41.      *             request and repository, such as due to a permission error.
  42.      */
  43.     UploadPack create(C req, Repository db) throws ServiceNotEnabledException,
  44.             ServiceNotAuthorizedException;
  45. }