Do plugin configuration in a plugin section in gerrit.config

Plugins should not introduce new sections in the gerrit.config file,
but define their configuration parameters in a plugin subsection.

So instead of having

  [avatar]
    url = ...

the configuration must now be

  [plugin "<plugin-name>"]
    url = ...

Since we just created the project newly to fix the project name, it's
a good opportunity to change the configuration as well.

Change-Id: Icba8d50185bd542e5a3900e8a19b48284ba46212
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/avatars/external/ExternalUrlAvatarProvider.java b/src/main/java/com/googlesource/gerrit/plugins/avatars/external/ExternalUrlAvatarProvider.java
index cdabba5..093aacd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/avatars/external/ExternalUrlAvatarProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/avatars/external/ExternalUrlAvatarProvider.java
@@ -16,15 +16,16 @@
 
 import com.google.gerrit.common.Nullable;
 import com.google.gerrit.extensions.annotations.Listen;
+import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.restapi.Url;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.avatar.AvatarProvider;
 import com.google.gerrit.server.config.CanonicalWebUrl;
-import com.google.gerrit.server.config.GerritServerConfig;
+import com.google.gerrit.server.config.PluginConfig;
+import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 
-import org.eclipse.jgit.lib.Config;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,26 +35,30 @@
 
   private static final String REPLACE_MARKER = "%s";
 
+  private final String pluginName;
   private final boolean ssl;
   private String externalAvatarUrl;
   private String avatarChangeUrl;
   private String sizeParameter;
 
   @Inject
-  ExternalUrlAvatarProvider(@CanonicalWebUrl @Nullable String canonicalUrl,
-      @GerritServerConfig Config cfg) {
-    externalAvatarUrl = cfg.getString("avatar", null, "url");
-    avatarChangeUrl = cfg.getString("avatar", null, "changeUrl");
-    sizeParameter = cfg.getString("avatar", null, "sizeParameter");
+  ExternalUrlAvatarProvider(PluginConfigFactory cfgFactory,
+      @PluginName String pluginName,
+      @CanonicalWebUrl @Nullable String canonicalUrl) {
+    this.pluginName = pluginName;
+    PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName);
+    externalAvatarUrl = cfg.getString("url");
+    avatarChangeUrl = cfg.getString("changeUrl");
+    sizeParameter = cfg.getString("sizeParameter");
     ssl = canonicalUrl != null && canonicalUrl.startsWith("https://");
   }
 
   @Override
   public String getUrl(IdentifiedUser forUser, int imageSize) {
-
     if (externalAvatarUrl == null) {
       Logger log = LoggerFactory.getLogger(ExternalUrlAvatarProvider.class);
-      log.warn("Avatar URL is not configured, cannot show avatars. Please configure avatar.url in etc/gerrit.config");
+      log.warn("Avatar URL is not configured, cannot show avatars. Please configure plugin."
+          + pluginName + ".url in etc/gerrit.config");
       return null;
     }
 
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 9344499..507c83f 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -1,24 +1,30 @@
-External URL Avatar Plugin Configuration
-========================================
+Configuration
+=============
 
-
-Options:
-
-* `avatar.url` - the location of avatar images containing `%s`, which
-  will then be replaced by the `username`. Required.
-* `avatar.changeUrl` - the URL shown in Gerrit's user settings to tell
-  the user, where the avatar can be changed. Optional.
-* `avatar.sizeParameter` - URL parameter with `${size}` placeholder to
-  forward the preferred image size to the avatar provider. Optional.
-
-Example (to be added to `etc/gerrit.config`):
+The configuration of the @PLUGIN@ plugin is done in the `gerrit.config`
+file.
 
 ```
-    [avatar]
-        url = http://example.org/avatars/%s.jpg
-        changeUrl = http://example.org/account.html
-        sizeParameter = s=${size}x${size}
+  [plugin "@PLUGIN@"]
+    url = http://example.org/avatars/%s.jpg
+    changeUrl = http://example.org/account.html
+    sizeParameter = s=${size}x${size}
 ```
 
+<a id="url">
+`plugin.@PLUGIN@.url`
+:	The location of avatar images containing `%s`, which will then be
+	replaced by the `username`. Required.
+
+<a id="changeUrl">
+`plugin.@PLUGIN@.changeUrl`
+:	The URL shown in Gerrit's user settings to tell the user, where the
+	avatar can be changed. Optional.
+
+<a id="sizeParameter">
+`plugin.@PLUGIN@.sizeParameter`
+:	URL parameter with `${size}` placeholder to forward the preferred
+	image size to the avatar provider. Optional.
+
 Please note that `http://` URLs will be automatically rewritten to
 `https://`, if `gerrit.canonicalWebUrl` uses HTTPS.