aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java
blob: 2fe071539582aba449541bf1506223c693c57242 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Copyright (C) 2008, Google Inc.
 * Copyright (C) 2009, Sasa Zivkov <sasa.zivkov@sap.com> and others
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0 which is available at
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package org.eclipse.jgit.errors;

import java.util.Map;

import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.transport.URIish;

/**
 * Indicates a base/common object was required, but is not found.
 */
public class MissingBundlePrerequisiteException extends TransportException {
	private static final long serialVersionUID = 1L;

	private static String format(Map<ObjectId, String> missingCommits) {
		final StringBuilder r = new StringBuilder();
		r.append(JGitText.get().missingPrerequisiteCommits);
		for (Map.Entry<ObjectId, String> e : missingCommits.entrySet()) {
			r.append("\n  "); //$NON-NLS-1$
			r.append(e.getKey().name());
			if (e.getValue() != null)
				r.append(" ").append(e.getValue()); //$NON-NLS-1$
		}
		return r.toString();
	}

	/**
	 * Constructs a MissingBundlePrerequisiteException for a set of objects.
	 *
	 * @param uri
	 *            URI used for transport
	 * @param missingCommits
	 *            the Map of the base/common object(s) we don't have. Keys are
	 *            ids of the missing objects and values are short descriptions.
	 */
	public MissingBundlePrerequisiteException(final URIish uri,
			final Map<ObjectId, String> missingCommits) {
		super(uri, format(missingCommits));
	}
}