From 7e584b107ad3ee69c2117333f882d69cd4b1aac8 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Fri, 29 May 2015 07:42:09 +0000
Subject: [PATCH] OPENDJ-2044 CR-7087 Replication Setup GUI

---
 opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/Installer.java |   36 +++++++++---------------------------
 1 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/Installer.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/Installer.java
index 2fd9479..978fa58 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/Installer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/Installer.java
@@ -126,7 +126,6 @@
 import org.opends.quicksetup.util.FileManager;
 import org.opends.quicksetup.util.IncompatibleVersionException;
 import org.opends.quicksetup.util.Utils;
-import org.opends.server.config.ConfigConstants;
 import org.opends.server.tools.BackendTypeHelper;
 import org.opends.server.tools.BackendTypeHelper.BackendTypeUIAdapter;
 import org.opends.server.util.CertificateManager;
@@ -1556,11 +1555,9 @@
 
     // The keys are the backend IDs and the values the list of base DNs.
     final Map<String, Set<String>> hmBackendSuffix = new HashMap<>();
-    final Map<String, BackendTypeUIAdapter> backendTypes = new HashMap<>();
-    final Set<SuffixDescriptor> suffixes = getUserData().getSuffixesToReplicateOptions().getSuffixes();
-
-    populateBackendsToCreate(hmBackendSuffix, suffixes, backendTypes);
-    createReplicatedBackends(hmBackendSuffix, backendTypes);
+    final SuffixesToReplicateOptions suffixData = getUserData().getSuffixesToReplicateOptions();
+    populateBackendsToCreate(hmBackendSuffix, suffixData.getSuffixes());
+    createReplicatedBackends(hmBackendSuffix, suffixData.getSuffixBackendTypes());
     notifyListeners(getFormattedDoneWithLineBreak());
     checkAbort();
   }
@@ -1570,8 +1567,7 @@
    * configuration of the other server. The algorithm consists on putting the
    * remote servers in a list and pick the backend as they appear on the list.
    */
-  private void populateBackendsToCreate(Map<String, Set<String>> hmBackendSuffix, Set<SuffixDescriptor> suffixes,
-      Map<String, BackendTypeUIAdapter> backendTypes)
+  private void populateBackendsToCreate(Map<String, Set<String>> hmBackendSuffix, Set<SuffixDescriptor> suffixes)
   {
     Set<ServerDescriptor> serverList = getServerListFromSuffixes(suffixes);
     for (SuffixDescriptor suffix : suffixes)
@@ -1581,7 +1577,6 @@
       {
         final String backendNameKey = getOrAddBackend(hmBackendSuffix, replica.getBackendName());
         hmBackendSuffix.get(backendNameKey).add(suffix.getDN());
-        backendTypes.put(backendNameKey, getBackendType(replica.getObjectClasses()));
       }
     }
   }
@@ -1614,20 +1609,6 @@
     return null;
   }
 
-  private BackendTypeUIAdapter getBackendType(Set<String> objectClasses)
-  {
-    for (String objectClass : objectClasses)
-    {
-      BackendTypeUIAdapter adapter =
-          BackendTypeHelper.getBackendTypeAdapter(objectClass.replace(ConfigConstants.NAME_PREFIX_CFG, ""));
-      if (adapter != null)
-      {
-        return adapter;
-      }
-    }
-    return null;
-  }
-
   private String getOrAddBackend(Map<String, Set<String>> hmBackendSuffix, String backendName)
   {
     for (String storedBackend : hmBackendSuffix.keySet())
@@ -3509,6 +3490,7 @@
    * @throws UserDataException
    *           if the data provided by the user is not valid.
    */
+  @SuppressWarnings("unchecked")
   private void updateUserDataForSuffixesOptionsPanel(QuickSetup qs) throws UserDataException
   {
     List<LocalizableMessage> errorMsgs = new ArrayList<>();
@@ -3530,10 +3512,10 @@
         }
         qs.displayFieldInvalid(FieldName.SUFFIXES_TO_REPLICATE, false);
         Set<SuffixDescriptor> available = getUserData().getSuffixesToReplicateOptions().getAvailableSuffixes();
-
-        SuffixesToReplicateOptions options =
-            new SuffixesToReplicateOptions(SuffixesToReplicateOptions.Type.REPLICATE_WITH_EXISTING_SUFFIXES, available,
-                chosen);
+        Map<String, BackendTypeUIAdapter> suffixesBackendTypes =
+            (Map<String, BackendTypeUIAdapter>) qs.getFieldValue(FieldName.SUFFIXES_TO_REPLICATE_BACKEND_TYPE);
+        SuffixesToReplicateOptions options = new SuffixesToReplicateOptions(
+            SuffixesToReplicateOptions.Type.REPLICATE_WITH_EXISTING_SUFFIXES, available, chosen, suffixesBackendTypes);
         getUserData().setSuffixesToReplicateOptions(options);
       }
       getUserData().setRemoteWithNoReplicationPort(getRemoteWithNoReplicationPort(getUserData()));

--
Gitblit v1.10.0