Solver V1: Check for file/directory existence before operations

Only move the old config file if it exists. Trying to move the file if
it does not exist results in an exception being thrown and then the
subsequent call to create the default site config file does not get
executed. This is most likely the root cause of there being no default
site config which was worked around in change I217d6479.

Also, only create the default site config file if it does not already
exist. Attempting to create the file if it exists will not cause the
file to be overwritten, but results in an unnecessary exception being
thrown and logged.

Change-Id: I7d3c7d49bcca14009a9252d2cb82d3ccaf685cf8
diff --git a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/solver/version/ b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/solver/version/
index 800f01b..ebcec00 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/solver/version/
+++ b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/solver/version/
@@ -62,10 +62,15 @@
       Path oldFile = etcDir.resolve(pluginName + FILE_EXT);
       Path newFile = pluginDataDir.resolve(pluginName + FILE_EXT);
       Path siteDir = pluginDataDir.resolve(SITE_DIR);
+      Path defaultSiteFile = siteDir.resolve(DEFAULT_SITE_NAME + FILE_EXT);
-      Files.move(oldFile, newFile);
-      Files.createFile(siteDir.resolve(DEFAULT_SITE_NAME + FILE_EXT));
+      if (oldFile.toFile().exists()) {
+        Files.move(oldFile, newFile);
+      }
+      if (!defaultSiteFile.toFile().exists()) {
+        Files.createFile(defaultSiteFile);
+      }
     } catch (IOException ex) {
       LOGGER.error("Failed to initialize plugin configuration", ex);