Match the whole project name when listing projects

Project names can contain many path components like:

  relative/path/to/my/project

When traversing the files under the lockRoot, match the whole relative
path of the file against the given match. For example:

  /path/to/lock/root/relative/path/to/my/project

For this file we match the "relative/path/to/my/project" against the
given match and not just the file name "project".

Change-Id: I80e2feff071b2b1a42811ba882aa8cd7b301da8f
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ListImportedProjects.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ListImportedProjects.java
index 1eb265d..c63db70 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ListImportedProjects.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ListImportedProjects.java
@@ -14,7 +14,6 @@
 
 package com.googlesource.gerrit.plugins.importer;
 
-import com.google.common.base.Strings;
 import com.google.common.collect.Maps;
 import com.google.common.io.Files;
 import com.google.gerrit.extensions.annotations.RequiresCapability;
@@ -27,6 +26,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Path;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Locale;
@@ -63,13 +63,20 @@
 
   private Collection<File> listImportFiles() {
     Collection<File> importFiles = new HashSet<>();
-    for (File f : Files.fileTreeTraverser().preOrderTraversal(projects.FS_LAYOUT.getLockRoot())) {
+    File lockRoot = projects.FS_LAYOUT.getLockRoot();
+    Path lockRootPath = lockRoot.toPath();
+    for (File f : Files.fileTreeTraverser().preOrderTraversal(lockRoot)) {
       if (f.isFile()
           && !f.getName().endsWith(".lock")
-          && (match == null || f.getName().toLowerCase(Locale.ENGLISH).contains(match))) {
+          && matches(lockRootPath.relativize(f.toPath()))) {
         importFiles.add(f);
       }
     }
     return importFiles;
   }
+
+  private boolean matches(Path p) {
+    return match == null
+        || p.toString().toLowerCase(Locale.ENGLISH).contains(match);
+  }
 }