summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2017-05-16 10:56:27 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-05-16 10:56:28 +0000
commit273b005c4689638b16e3ee4da6bcb5080b858b65 (patch)
tree932788eb403d1240dcdca5bbdb9180096ef322b9
parentb38e18ed3b1178d6622c18b6c146692f8600b804 (diff)
parent3ffecce534373e6f8b1e0f06dfa034ad544230ef (diff)
Merge "Enhance UploadValidators to allow listening to negotation start" into stable-2.13
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidationListener.java19
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidators.java8
m---------plugins/cookbook-plugin0
3 files changed, 27 insertions, 0 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidationListener.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidationListener.java
index e6923c145d..c86e87a10c 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidationListener.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidationListener.java
@@ -42,6 +42,7 @@ public interface UploadValidationListener {
* @param repository The repository
* @param project The project
* @param remoteHost Remote address/hostname of the user
+ * @param up the UploadPack instance being processed
* @param wants The list of wanted objects. These may be RevObject or
* RevCommit if the processor parsed them. Implementors should not rely
* on the values being parsed.
@@ -55,4 +56,22 @@ public interface UploadValidationListener {
String remoteHost, UploadPack up, Collection<? extends ObjectId> wants,
Collection<? extends ObjectId> haves)
throws ValidationException;
+
+ /**
+ * Invoked before negotiation round is started.
+ *
+ * @param repository The repository
+ * @param project The project
+ * @param remoteHost Remote address/hostname of the user
+ * @param up the UploadPack instance being processed
+ * @param wants The list of wanted objects. These may be RevObject or
+ * RevCommit if the processor parsed them. Implementors should not rely
+ * on the values being parsed.
+ * @param cntOffered number of objects the client has offered.
+ * @throws ValidationException to block the upload and send a message back to
+ * the end-user over the client's protocol connection.
+ */
+ void onBeginNegotiate(Repository repository, Project project,
+ String remoteHost, UploadPack up, Collection<? extends ObjectId> wants,
+ int cntOffered) throws ValidationException;
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidators.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidators.java
index eb2e136924..66cc0e52a4 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidators.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/UploadValidators.java
@@ -69,6 +69,14 @@ public class UploadValidators implements PreUploadHook {
public void onBeginNegotiateRound(UploadPack up,
Collection<? extends ObjectId> wants, int cntOffered)
throws ServiceMayNotContinueException {
+ for (UploadValidationListener validator : uploadValidationListeners) {
+ try {
+ validator.onBeginNegotiate(repository, project, remoteHost, up, wants,
+ cntOffered);
+ } catch (ValidationException e) {
+ throw new UploadValidationException(e.getMessage());
+ }
+ }
}
@Override
diff --git a/plugins/cookbook-plugin b/plugins/cookbook-plugin
-Subproject 536beda3ab4f6f8d8d8c5be1e3cf0e6b4e9b10d
+Subproject e291425ca82cf8cb4bcd53b5f65e881fc04961c