Big refactor: *Connection hierarchy
[egit/zawir.git] / org.spearce.jgit / src / org / spearce / jgit / transport / PushConnection.java
blob09c85ab40d06f6a020266ec48a014aa861b6a250
1 /*
2 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
3 * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or
8 * without modification, are permitted provided that the following
9 * conditions are met:
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
19 * - Neither the name of the Git Development Community nor the
20 * names of its contributors may be used to endorse or promote
21 * products derived from this software without specific prior
22 * written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
25 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
26 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 package org.spearce.jgit.transport;
41 import java.util.Map;
43 import org.spearce.jgit.errors.TransportException;
44 import org.spearce.jgit.lib.ProgressMonitor;
45 import org.spearce.jgit.transport.RemoteRefUpdate.Status;
47 /**
48 * Lists known refs from the remote and sends objects to the remote.
49 * <p>
50 * A push connection typically connects to the <code>git-receive-pack</code>
51 * service running where the remote repository is stored. This provides a
52 * one-way object transfer service to copy objects from the local repository
53 * into the remote repository, as well as a way to modify the refs stored by the
54 * remote repository.
55 * <p>
56 * Instances of a PushConnection must be created by a {@link Transport} that
57 * implements a specific object transfer protocol that both sides of the
58 * connection understand.
59 * <p>
60 * PushConnection instances are not thread safe and may be accessed by only one
61 * thread at a time.
63 * @see Transport
65 public interface PushConnection extends Connection {
67 /**
68 * Pushes to the remote repository basing on provided specification. This
69 * possibly result in update/creation/deletion of refs on remote repository
70 * and sending objects that remote repository need to have a consistent
71 * objects graph from new refs.
72 * <p>
73 * <p>
74 * Only one call per connection is allowed. Subsequent calls will result in
75 * {@link TransportException}.
76 * </p>
77 * <p>
78 * Implementation may use local repository to send a minimum set of objects
79 * needed by remote repository in efficient way.
80 * {@link Transport#isPushThin()} should be honored if applicable.
81 * refUpdates should be filled with information about status of each update.
82 * </p>
84 * @param monitor
85 * progress monitor to update the end-user about the amount of
86 * work completed, or to indicate cancellation. Implementors
87 * should poll the monitor at regular intervals to look for
88 * cancellation requests from the user.
89 * @param refUpdates
90 * map of remote refnames to remote refs update
91 * specifications/statuses. Can't be empty. This indicate what
92 * refs caller want to update on remote side. Only refs updates
93 * with {@link Status#NOT_ATTEMPTED} should passed.
94 * Implementation must ensure that and appropriate status with
95 * optional message should be set during call. No refUpdate with
96 * {@link Status#AWAITING_REPORT} or {@link Status#NOT_ATTEMPTED}
97 * can be leaved by implementation after return from this call.
98 * @throws TransportException
99 * objects could not be copied due to a network failure,
100 * critical protocol error, or error on remote side, or
101 * connection was already used for push - new connection must be
102 * created. Non-critical errors concerning only isolated refs
103 * should be placed in refUpdates.
105 public void push(final ProgressMonitor monitor,
106 final Map<String, RemoteRefUpdate> refUpdates)
107 throws TransportException;