View Javadoc
1   /*
2    * Copyright (C) 2008, Google Inc.
3    * Copyright (C) 2009, Sasa Zivkov <sasa.zivkov@sap.com> and others
4    *
5    * This program and the accompanying materials are made available under the
6    * terms of the Eclipse Distribution License v. 1.0 which is available at
7    * https://www.eclipse.org/org/documents/edl-v10.php.
8    *
9    * SPDX-License-Identifier: BSD-3-Clause
10   */
11  
12  package org.eclipse.jgit.errors;
13  
14  import java.util.Map;
15  
16  import org.eclipse.jgit.internal.JGitText;
17  import org.eclipse.jgit.lib.ObjectId;
18  import org.eclipse.jgit.transport.URIish;
19  
20  /**
21   * Indicates a base/common object was required, but is not found.
22   */
23  public class MissingBundlePrerequisiteException extends TransportException {
24  	private static final long serialVersionUID = 1L;
25  
26  	private static String format(Map<ObjectId, String> missingCommits) {
27  		final StringBuilder r = new StringBuilder();
28  		r.append(JGitText.get().missingPrerequisiteCommits);
29  		for (Map.Entry<ObjectId, String> e : missingCommits.entrySet()) {
30  			r.append("\n  "); //$NON-NLS-1$
31  			r.append(e.getKey().name());
32  			if (e.getValue() != null)
33  				r.append(" ").append(e.getValue()); //$NON-NLS-1$
34  		}
35  		return r.toString();
36  	}
37  
38  	/**
39  	 * Constructs a MissingBundlePrerequisiteException for a set of objects.
40  	 *
41  	 * @param uri
42  	 *            URI used for transport
43  	 * @param missingCommits
44  	 *            the Map of the base/common object(s) we don't have. Keys are
45  	 *            ids of the missing objects and values are short descriptions.
46  	 */
47  	public MissingBundlePrerequisiteException(final URIish uri,
48  			final Map<ObjectId, String> missingCommits) {
49  		super(uri, format(missingCommits));
50  	}
51  }