1 /*
2 * Copyright (c) 2019, Google LLC and others
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Distribution License v. 1.0 which is available at
6 * http://www.eclipse.org/org/documents/edl-v10.php.
7 *
8 * SPDX-License-Identifier: BSD-3-Clause
9 */
10
11 package org.eclipse.jgit.transport;
12
13 import java.io.IOException;
14 import java.util.List;
15 import java.util.Set;
16
17 import org.eclipse.jgit.lib.ObjectId;
18 import org.eclipse.jgit.lib.ProgressMonitor;
19 import org.eclipse.jgit.lib.Repository;
20 import org.eclipse.jgit.revwalk.RevWalk;
21
22 /**
23 * Checks that a received pack only depends on objects which are reachable from
24 * a defined set of references.
25 *
26 * @since 5.7
27 */
28 public interface ConnectivityChecker {
29
30 /**
31 * Checks connectivity of the commit graph after pack uploading.
32 *
33 * @param connectivityCheckInfo
34 * Input for the connectivity check.
35 * @param haves
36 * Set of references known for client.
37 * @param pm
38 * Monitor to publish progress to.
39 * @throws IOException
40 * an error occurred during connectivity checking.
41 *
42 */
43 void checkConnectivity(ConnectivityCheckInfo connectivityCheckInfo,
44 Set<ObjectId> haves, ProgressMonitor pm)
45 throws IOException;
46
47 /**
48 * POJO which is used to pass all information which is needed to perform
49 * connectivity check.
50 */
51 public static class ConnectivityCheckInfo {
52 private Repository repository;
53
54 private PackParser parser;
55
56 private boolean checkObjects;
57
58 private List<ReceiveCommand> commands;
59
60 private RevWalk walk;
61
62 /**
63 * @return database we write the stored objects into.
64 */
65 public Repository getRepository() {
66 return repository;
67 }
68
69 /**
70 * @param repository
71 * set database we write the stored objects into.
72 */
73 public void setRepository(Repository repository) {
74 this.repository = repository;
75 }
76
77 /**
78 * @return the parser used to parse pack.
79 */
80 public PackParser getParser() {
81 return parser;
82 }
83
84 /**
85 * @param parser
86 * the parser to set
87 */
88 public void setParser(PackParser parser) {
89 this.parser = parser;
90 }
91
92 /**
93 * @return if checker should check objects.
94 */
95 public boolean isCheckObjects() {
96 return checkObjects;
97 }
98
99 /**
100 * @param checkObjects
101 * set if checker should check referenced objects outside of
102 * the received pack are reachable.
103 */
104 public void setCheckObjects(boolean checkObjects) {
105 this.checkObjects = checkObjects;
106 }
107
108 /**
109 * @return command received by the current request.
110 */
111 public List<ReceiveCommand> getCommands() {
112 return commands;
113 }
114
115 /**
116 * @param commands
117 * set command received by the current request.
118 */
119 public void setCommands(List<ReceiveCommand> commands) {
120 this.commands = commands;
121 }
122
123 /**
124 * @param walk
125 * the walk to parse commits
126 */
127 public void setWalk(RevWalk walk) {
128 this.walk = walk;
129 }
130
131 /**
132 * @return the walk to parse commits
133 */
134 public RevWalk getWalk() {
135 return walk;
136 }
137 }
138 }