BaseFetchConnection.java

  1. /*
  2.  * Copyright (C) 2008, Google Inc.
  3.  * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
  4.  * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
  5.  *
  6.  * This program and the accompanying materials are made available under the
  7.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  8.  * https://www.eclipse.org/org/documents/edl-v10.php.
  9.  *
  10.  * SPDX-License-Identifier: BSD-3-Clause
  11.  */

  12. package org.eclipse.jgit.transport;

  13. import java.io.OutputStream;
  14. import java.util.Collection;
  15. import java.util.Set;

  16. import org.eclipse.jgit.errors.TransportException;
  17. import org.eclipse.jgit.lib.ObjectId;
  18. import org.eclipse.jgit.lib.ProgressMonitor;
  19. import org.eclipse.jgit.lib.Ref;

  20. /**
  21.  * Base helper class for fetch connection implementations. Provides some common
  22.  * typical structures and methods used during fetch connection.
  23.  * <p>
  24.  * Implementors of fetch over pack-based protocols should consider using
  25.  * {@link BasePackFetchConnection} instead.
  26.  * </p>
  27.  */
  28. abstract class BaseFetchConnection extends BaseConnection implements
  29.         FetchConnection {
  30.     /** {@inheritDoc} */
  31.     @Override
  32.     public final void fetch(final ProgressMonitor monitor,
  33.             final Collection<Ref> want, final Set<ObjectId> have)
  34.             throws TransportException {
  35.         fetch(monitor, want, have, null);
  36.     }

  37.     /** {@inheritDoc} */
  38.     @Override
  39.     public final void fetch(final ProgressMonitor monitor,
  40.             final Collection<Ref> want, final Set<ObjectId> have,
  41.             OutputStream out) throws TransportException {
  42.         markStartedOperation();
  43.         doFetch(monitor, want, have);
  44.     }

  45.     /**
  46.      * {@inheritDoc}
  47.      *
  48.      * Default implementation of {@link FetchConnection#didFetchIncludeTags()} -
  49.      * returning false.
  50.      */
  51.     @Override
  52.     public boolean didFetchIncludeTags() {
  53.         return false;
  54.     }

  55.     /**
  56.      * Implementation of {@link #fetch(ProgressMonitor, Collection, Set)}
  57.      * without checking for multiple fetch.
  58.      *
  59.      * @param monitor
  60.      *            as in {@link #fetch(ProgressMonitor, Collection, Set)}
  61.      * @param want
  62.      *            as in {@link #fetch(ProgressMonitor, Collection, Set)}
  63.      * @param have
  64.      *            as in {@link #fetch(ProgressMonitor, Collection, Set)}
  65.      * @throws org.eclipse.jgit.errors.TransportException
  66.      *             as in {@link #fetch(ProgressMonitor, Collection, Set)}, but
  67.      *             implementation doesn't have to care about multiple
  68.      *             {@link #fetch(ProgressMonitor, Collection, Set)} calls, as it
  69.      *             is checked in this class.
  70.      */
  71.     protected abstract void doFetch(final ProgressMonitor monitor,
  72.             final Collection<Ref> want, final Set<ObjectId> have)
  73.             throws TransportException;
  74. }