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
13 package org.eclipse.jgit.transport;
14
15 import java.io.OutputStream;
16 import java.util.Collection;
17 import java.util.Set;
18
19 import org.eclipse.jgit.errors.TransportException;
20 import org.eclipse.jgit.lib.ObjectId;
21 import org.eclipse.jgit.lib.ProgressMonitor;
22 import org.eclipse.jgit.lib.Ref;
23
24 /**
25 * Base helper class for fetch connection implementations. Provides some common
26 * typical structures and methods used during fetch connection.
27 * <p>
28 * Implementors of fetch over pack-based protocols should consider using
29 * {@link BasePackFetchConnection} instead.
30 * </p>
31 */
32 abstract class BaseFetchConnection extends BaseConnection implements
33 FetchConnection {
34 /** {@inheritDoc} */
35 @Override
36 public final void fetch(final ProgressMonitor monitor,
37 final Collection<Ref> want, final Set<ObjectId> have)
38 throws TransportException {
39 fetch(monitor, want, have, null);
40 }
41
42 /** {@inheritDoc} */
43 @Override
44 public final void fetch(final ProgressMonitor monitor,
45 final Collection<Ref> want, final Set<ObjectId> have,
46 OutputStream out) throws TransportException {
47 markStartedOperation();
48 doFetch(monitor, want, have);
49 }
50
51 /**
52 * {@inheritDoc}
53 *
54 * Default implementation of {@link FetchConnection#didFetchIncludeTags()} -
55 * returning false.
56 */
57 @Override
58 public boolean didFetchIncludeTags() {
59 return false;
60 }
61
62 /**
63 * Implementation of {@link #fetch(ProgressMonitor, Collection, Set)}
64 * without checking for multiple fetch.
65 *
66 * @param monitor
67 * as in {@link #fetch(ProgressMonitor, Collection, Set)}
68 * @param want
69 * as in {@link #fetch(ProgressMonitor, Collection, Set)}
70 * @param have
71 * as in {@link #fetch(ProgressMonitor, Collection, Set)}
72 * @throws org.eclipse.jgit.errors.TransportException
73 * as in {@link #fetch(ProgressMonitor, Collection, Set)}, but
74 * implementation doesn't have to care about multiple
75 * {@link #fetch(ProgressMonitor, Collection, Set)} calls, as it
76 * is checked in this class.
77 */
78 protected abstract void doFetch(final ProgressMonitor monitor,
79 final Collection<Ref> want, final Set<ObjectId> have)
80 throws TransportException;
81 }