Merge branch 'stable-3.1' into master
* stable-3.1:
Add GerritHub PolyGerrit CSS style as example
Change-Id: I5b91bbc0576ec75be3149310739faded8a84c2a3
diff --git a/example-changeOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changeoperator/SampleOperator.java b/example-changeOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changeoperator/SampleOperator.java
index 6c1319c..447e9d3 100644
--- a/example-changeOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changeoperator/SampleOperator.java
+++ b/example-changeOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changeoperator/SampleOperator.java
@@ -14,10 +14,10 @@
package com.googlesource.gerrit.plugins.examples.changeoperator;
+import com.google.gerrit.entities.Change;
import com.google.gerrit.index.query.PostFilterPredicate;
import com.google.gerrit.index.query.Predicate;
import com.google.gerrit.index.query.QueryParseException;
-import com.google.gerrit.entities.Change;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
import com.google.inject.Singleton;
diff --git a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java
deleted file mode 120000
index 89edecb..0000000
--- a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../../../../../../example-adminSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java
\ No newline at end of file
diff --git a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java
new file mode 100644
index 0000000..84b7adb
--- /dev/null
+++ b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java
@@ -0,0 +1,26 @@
+// 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.examples.adminsshcommand;
+
+import com.google.gerrit.extensions.config.CapabilityDefinition;
+
+class AdminExampleCapability extends CapabilityDefinition {
+ static final String ADMIN_EXAMPLE = "adminExample";
+
+ @Override
+ public String getDescription() {
+ return "Administrate Example";
+ }
+}
diff --git a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java
deleted file mode 120000
index 0b87e21..0000000
--- a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../../../../../../example-adminSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java
\ No newline at end of file
diff --git a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java
new file mode 100644
index 0000000..3c31b6b
--- /dev/null
+++ b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java
@@ -0,0 +1,42 @@
+// 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.examples.adminsshcommand;
+
+import com.google.gerrit.extensions.annotations.RequiresCapability;
+import com.google.gerrit.sshd.CommandMetaData;
+import com.google.gerrit.sshd.SshCommand;
+import org.kohsuke.args4j.Option;
+
+@RequiresCapability(AdminExampleCapability.ADMIN_EXAMPLE)
+@CommandMetaData(name = "admin", description = "Administrate the example")
+public final class AdminExampleCommand extends SshCommand {
+ private int count = 1;
+
+ @Option(
+ name = "--count",
+ aliases = {"-c"},
+ metaVar = "COUNT",
+ usage = "Number of times to greet the administrator")
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ @Override
+ protected void run() {
+ while (count-- > 0) {
+ stdout.print("Hello, example administrator\n");
+ }
+ }
+}
diff --git a/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/AssigneeValidator.java b/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/AssigneeValidator.java
index 9201419..856c66d 100644
--- a/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/AssigneeValidator.java
+++ b/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/AssigneeValidator.java
@@ -14,10 +14,10 @@
package com.googlesource.gerrit.plugins.examples.validationlistenerassignee;
-import com.google.gerrit.exceptions.StorageException;
-import com.google.gerrit.index.query.QueryParseException;
import com.google.gerrit.entities.Account;
import com.google.gerrit.entities.Change;
+import com.google.gerrit.exceptions.StorageException;
+import com.google.gerrit.index.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;
@@ -40,10 +40,7 @@
@Override
public void validateAssignee(Change change, Account assignee) throws ValidationException {
try {
- if (queryProcessor
- .query(queryBuilder.assignee(assignee.preferredEmail()))
- .entities()
- .size()
+ if (queryProcessor.query(queryBuilder.assignee(assignee.preferredEmail())).entities().size()
> MAX_ASSIGNED_CHANGES) {
throw new ValidationException(
"Cannot assign user to more than " + MAX_ASSIGNED_CHANGES + " changes");