Remove Assignee Validation from plugin. Assignee is being removed from gerrit. This example will stop working once it is removed. Google-Bug-Id: b/33429040 Release-Notes: skip Change-Id: Ice5e1dda5a7ce78a6d2cc9c8367d02994ac8b854
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/AssigneeValidator.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/AssigneeValidator.java deleted file mode 100644 index 3bec9da..0000000 --- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/AssigneeValidator.java +++ /dev/null
@@ -1,54 +0,0 @@ -// Copyright (C) 2014 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.googlesource.gerrit.plugins.cookbook; - -import com.google.gerrit.reviewdb.client.Account; -import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.server.query.QueryParseException; -import com.google.gerrit.server.query.change.ChangeQueryBuilder; -import com.google.gerrit.server.query.change.ChangeQueryProcessor; -import com.google.gerrit.server.validators.AssigneeValidationListener; -import com.google.gerrit.server.validators.ValidationException; -import com.google.gwtorm.server.OrmException; -import com.google.inject.Inject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AssigneeValidator implements AssigneeValidationListener { - private static final Logger log = LoggerFactory.getLogger(AssigneeValidationListener.class); - - private static int MAX_ASSIGNED_CHANGES = 5; - - @Inject ChangeQueryBuilder queryBuilder; - - @Inject ChangeQueryProcessor queryProcessor; - - @Override - public void validateAssignee(Change change, Account assignee) throws ValidationException { - try { - if (queryProcessor - .query(queryBuilder.assignee(assignee.getPreferredEmail())) - .entities() - .size() - > MAX_ASSIGNED_CHANGES) { - throw new ValidationException( - "Cannot assign user to more than " + MAX_ASSIGNED_CHANGES + " changes"); - } - } catch (OrmException | QueryParseException e) { - log.error("Failed to validate assignee for change " + change.getId(), e); - // Allow assignee. - } - } -}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java index de0b2c3..e70a4ed 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java +++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java
@@ -42,7 +42,6 @@ import com.google.gerrit.server.git.validators.UploadValidationListener; import com.google.gerrit.server.plugins.ServerPluginProvider; import com.google.gerrit.server.query.change.ChangeQueryBuilder.ChangeOperatorFactory; -import com.google.gerrit.server.validators.AssigneeValidationListener; import com.google.gerrit.server.validators.HashtagValidationListener; import com.google.inject.AbstractModule; import com.googlesource.gerrit.plugins.cookbook.pluginprovider.HelloSshPluginProvider; @@ -71,7 +70,6 @@ DynamicSet.bind(binder(), UploadValidationListener.class).to(DenyUploadExample.class); DynamicSet.bind(binder(), MergeValidationListener.class).to(MergeUserValidator.class); DynamicSet.bind(binder(), HashtagValidationListener.class).to(HashtagValidator.class); - DynamicSet.bind(binder(), AssigneeValidationListener.class).to(AssigneeValidator.class); DynamicSet.bind(binder(), CommitValidationListener.class).to(CommitValidator.class); DynamicSet.bind(binder(), NewProjectCreatedListener.class).to(ProjectCreatedListener.class); DynamicSet.bind(binder(), RefOperationValidationListener.class)