Only try to validate commentLink associated to the Its

For commit validation, we tried to match all commentLinks to issues,
regardless of whether the commentLink refers to an issue or
not. Besides being unwarranted extra work, this approach caused
NumberFormatExceptions problems for hooks-bugzilla when trying to
match a non-numeric commentLink (e.g.: Change-Id) to a numeric issue
id.

Change-Id: Idc1dc1c1b6b296c28bdde07a1f3703734da83ce7
diff --git a/hooks-its/src/main/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateComment.java b/hooks-its/src/main/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateComment.java
index cfe8868..f157730 100644
--- a/hooks-its/src/main/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateComment.java
+++ b/hooks-its/src/main/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateComment.java
@@ -19,7 +19,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map.Entry;
-import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -36,6 +35,7 @@
 import com.google.gerrit.server.git.validators.CommitValidationMessage;
 import com.google.inject.Inject;
 import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
+import com.googlesource.gerrit.plugins.hooks.its.ItsName;
 
 public class ItsValidateComment implements CommitValidationListener {
 
@@ -49,6 +49,9 @@
   @GerritServerConfig
   private Config gerritConfig;
 
+  @Inject @ItsName
+  private String itsName;
+
   public List<CommitValidationMessage> validCommit(ReceiveCommand cmd, RevCommit commit) throws CommitValidationException {
 
     HashMap<Pattern, ItsAssociationPolicy> regexes = getCommentRegexMap();
@@ -133,14 +136,11 @@
   private HashMap<Pattern, ItsAssociationPolicy> getCommentRegexMap() {
     HashMap<Pattern, ItsAssociationPolicy> regexMap = new HashMap<Pattern, ItsAssociationPolicy>();
 
-    Set<String> linkSubsections = gerritConfig.getSubsections("commentLink");
-    for (String string : linkSubsections) {
-      String match = gerritConfig.getString("commentLink", string, "match");
-      if (match != null) {
-        regexMap
-            .put(Pattern.compile(match), gerritConfig.getEnum("commentLink",
-                string, "association", ItsAssociationPolicy.OPTIONAL));
-      }
+    String match = gerritConfig.getString("commentLink", itsName, "match");
+    if (match != null) {
+      regexMap
+          .put(Pattern.compile(match), gerritConfig.getEnum("commentLink",
+              itsName, "association", ItsAssociationPolicy.OPTIONAL));
     }
 
     return regexMap;