Support to enable/disable the RTC integration per project

It can now be configured per project whether the RTC integration is
enabled or not. To enable the RTC integration for a project the
project must have the following entry in its `project.config` file in
the `refs/meta/config` branch:

```
  [plugin "its-rtc"]
    enabled = true
```

If `plugin.its-rtc.enabled` is not specified in the `project.config` file
the value is inherited from the parent project. If it is also not set
on any parent project the RTC integration is disabled for this
project.

By setting `plugin.its-rtc.enabled` to true in the `project.config` of the
`All-Projects` project the RTC integration can be enabled by default
for all projects. During the initialization of the plugin you are asked
if the RTC integration should be enabled by default for all projects
and if yes this setting in the `project.config` of the `All-Projects`
project is done automatically.``

Change-Id: If24cb7f9cf9f62aff9eeb376aff0e6a4724ed020
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/rtc/InitRTC.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/rtc/InitRTC.java
index e818bec..149fea0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/rtc/InitRTC.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/rtc/InitRTC.java
@@ -13,46 +13,45 @@
 // limitations under the License.
 package com.googlesource.gerrit.plugins.hooks.rtc;
 
-import java.io.IOException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import com.google.gerrit.extensions.annotations.PluginName;
-import com.google.gerrit.pgm.init.InitStep;
+import com.google.gerrit.pgm.init.AllProjectsConfig;
 import com.google.gerrit.pgm.init.Section;
-import com.google.gerrit.pgm.init.Section.Factory;
 import com.google.gerrit.pgm.util.ConsoleUI;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
+
 import com.googlesource.gerrit.plugins.hooks.its.InitIts;
 import com.googlesource.gerrit.plugins.hooks.rtc.network.RTCClient;
 import com.googlesource.gerrit.plugins.hooks.validation.ItsAssociationPolicy;
 
+import org.eclipse.jgit.errors.ConfigInvalidException;
+
+import java.io.IOException;
+
 /** Initialize the GitRepositoryManager configuration section. */
 @Singleton
-class InitRTC extends InitIts implements InitStep {
-  private static final Logger log = LoggerFactory.getLogger(InitRTC.class);
+class InitRTC extends InitIts {
   private static final String COMMENT_LINK_SECTION = "commentLink";
   private final String pluginName;
-  private final ConsoleUI ui;
   private Section rtc;
   private Section rtcComment;
-  private Factory sections;
+  private Section.Factory sections;
   private String rtcUrl;
   private String rtcUsername;
   private String rtcPassword;
 
-
   @Inject
-  InitRTC(final @PluginName String pluginName, final ConsoleUI ui,
-      final Section.Factory sections) {
+  InitRTC(@PluginName String pluginName, ConsoleUI ui, Section.Factory sections,
+      AllProjectsConfig allProjectsConfig) {
+    super(pluginName, "IBM Rational Team Concert", ui,
+        allProjectsConfig);
     this.pluginName = pluginName;
-    this.ui = ui;
     this.sections = sections;
   }
 
-  public void run() {
+  public void postRun() throws IOException, ConfigInvalidException {
+    super.postRun();
+
     this.rtc = sections.get(pluginName, null);
     this.rtcComment =
         sections.get(COMMENT_LINK_SECTION, pluginName);
@@ -67,7 +66,7 @@
         sslVerify = enterSSLVerify(rtc);
       }
     } while (rtcUrl != null
-        && (isConnectivityRequested(ui, rtcUrl) && !isRTCConnectSuccessful(rtcUrl, sslVerify)));
+        && (isConnectivityRequested(rtcUrl) && !isRTCConnectSuccessful(rtcUrl, sslVerify)));
 
     if (rtcUrl == null) {
       return;
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 24c82c3..d012405 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -16,6 +16,28 @@
 configuration that allows to configure the RTC issue syntax and formatting all the references
 rendered in Gerrit as hyperlinks to the corresponding issue target URL in RTC.
 
+It can be configured per project whether the RTC integration is
+enabled or not. To enable the RTC integration for a project the
+project must have the following entry in its `project.config` file in
+the `refs/meta/config` branch:
+
+```
+  [plugin "its-rtc"]
+    enabled = true
+```
+
+If `plugin.its-rtc.enabled` is not specified in the `project.config` file
+the value is inherited from the parent project. If it is also not set
+on any parent project the RTC integration is disabled for this
+project.
+
+By setting `plugin.its-rtc.enabled` to true in the `project.config` of the
+`All-Projects` project the RTC integration can be enabled by default
+for all projects. During the initialization of the plugin you are asked
+if the RTC integration should be enabled by default for all projects
+and if yes this setting in the `project.config` of the `All-Projects`
+project is done automatically.
+
 Comment links
 ----------------
 
@@ -140,6 +162,11 @@
 
 **Gerrit init example:**
 
+    *** IBM Rational Team Concert Integration
+    ***
+
+    By default enabled for all projects [Y/n]?
+
     *** IBM Rational Team Concert connectivity
 	***