001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2008-2009 Sun Microsystems, Inc.
025 *      Portions Copyright 2014-2015 ForgeRock AS
026 */
027package org.opends.guitools.controlpanel.task;
028
029import static org.opends.messages.AdminToolMessages.*;
030import static org.opends.messages.ConfigMessages.*;
031
032import java.util.ArrayList;
033import java.util.Collection;
034import java.util.HashMap;
035import java.util.HashSet;
036import java.util.LinkedList;
037import java.util.List;
038import java.util.Map;
039import java.util.Set;
040import java.util.SortedSet;
041import java.util.TreeSet;
042import java.util.concurrent.atomic.AtomicReference;
043
044import javax.naming.ldap.InitialLdapContext;
045import javax.swing.SwingUtilities;
046
047import org.forgerock.i18n.LocalizableMessage;
048import org.forgerock.opendj.config.server.ConfigException;
049import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
050import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
051import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
052import org.opends.guitools.controlpanel.ui.ColorAndFontConstants;
053import org.opends.guitools.controlpanel.ui.ProgressDialog;
054import org.opends.guitools.controlpanel.util.ConfigReader;
055import org.opends.guitools.controlpanel.util.Utilities;
056import org.opends.server.admin.client.ManagementContext;
057import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
058import org.opends.server.admin.client.ldap.LDAPManagementContext;
059import org.opends.server.admin.server.ServerManagementContext;
060import org.opends.server.admin.std.client.PluggableBackendCfgClient;
061import org.opends.server.admin.std.client.ReplicationDomainCfgClient;
062import org.opends.server.admin.std.client.ReplicationSynchronizationProviderCfgClient;
063import org.opends.server.admin.std.client.RootCfgClient;
064import org.opends.server.admin.std.server.ReplicationDomainCfg;
065import org.opends.server.admin.std.server.ReplicationSynchronizationProviderCfg;
066import org.opends.server.admin.std.server.RootCfg;
067import org.opends.server.config.ConfigConstants;
068import org.opends.server.config.ConfigEntry;
069import org.opends.server.config.DNConfigAttribute;
070import org.opends.server.core.DirectoryServer;
071import org.opends.server.types.DN;
072import org.opends.server.types.OpenDsException;
073
074/** The task used to delete a set of base DNs or backends. */
075public class DeleteBaseDNAndBackendTask extends Task
076{
077  private Set<String> backendSet;
078  private Map<String, Set<BaseDNDescriptor>> baseDNsToDelete = new HashMap<>();
079  private ArrayList<BackendDescriptor> backendsToDelete = new ArrayList<>();
080
081  /**
082   * Constructor of the task.
083   * @param info the control panel information.
084   * @param dlg the progress dialog where the task progress will be displayed.
085   * @param backendsToDelete the backends to delete.
086   * @param baseDNsToDelete the base DNs to delete.
087   */
088  public DeleteBaseDNAndBackendTask(ControlPanelInfo info, ProgressDialog dlg,
089      Collection<BackendDescriptor> backendsToDelete,
090      Collection<BaseDNDescriptor> baseDNsToDelete)
091  {
092    super(info, dlg);
093    backendSet = new HashSet<>();
094    for (BackendDescriptor backend : backendsToDelete)
095    {
096      backendSet.add(backend.getBackendID());
097    }
098    for (BaseDNDescriptor baseDN : baseDNsToDelete)
099    {
100      backendSet.add(baseDN.getBackend().getBackendID());
101    }
102    for (BaseDNDescriptor baseDN : baseDNsToDelete)
103    {
104      String backendID = baseDN.getBackend().getBackendID();
105      Set<BaseDNDescriptor> set = this.baseDNsToDelete.get(backendID);
106      if (set == null)
107      {
108        set = new HashSet<>();
109        this.baseDNsToDelete.put(backendID, set);
110      }
111      set.add(baseDN);
112    }
113    ArrayList<String> indirectBackendsToDelete = new ArrayList<>();
114    for (Set<BaseDNDescriptor> set : this.baseDNsToDelete.values())
115    {
116      BackendDescriptor backend = set.iterator().next().getBackend();
117      if (set.size() == backend.getBaseDns().size())
118      {
119        // All of the suffixes must be deleted.
120        indirectBackendsToDelete.add(backend.getBackendID());
121        this.backendsToDelete.add(backend);
122      }
123    }
124    for (String backendID : indirectBackendsToDelete)
125    {
126      this.baseDNsToDelete.remove(backendID);
127    }
128    this.backendsToDelete.addAll(backendsToDelete);
129  }
130
131  @Override
132  public Type getType()
133  {
134    return !baseDNsToDelete.isEmpty() ? Type.DELETE_BASEDN : Type.DELETE_BACKEND;
135  }
136
137  @Override
138  public Set<String> getBackends()
139  {
140    return backendSet;
141  }
142
143  @Override
144  public LocalizableMessage getTaskDescription()
145  {
146    StringBuilder sb = new StringBuilder();
147
148    if (!baseDNsToDelete.isEmpty())
149    {
150      ArrayList<String> dns = new ArrayList<>();
151      for (Set<BaseDNDescriptor> set : baseDNsToDelete.values())
152      {
153        for (BaseDNDescriptor baseDN : set)
154        {
155          dns.add(baseDN.getDn().toString());
156        }
157      }
158      if (dns.size() == 1)
159      {
160        String dn = dns.iterator().next();
161        sb.append(INFO_CTRL_PANEL_DELETE_BASE_DN_DESCRIPTION.get(dn));
162      }
163      else
164      {
165        ArrayList<String> quotedDns = new ArrayList<>();
166        for (String dn : dns)
167        {
168          quotedDns.add("'"+dn+"'");
169        }
170        sb.append(INFO_CTRL_PANEL_DELETE_BASE_DNS_DESCRIPTION.get(
171        Utilities.getStringFromCollection(quotedDns, ", ")));
172      }
173    }
174
175    if (!backendsToDelete.isEmpty())
176    {
177      if (sb.length() > 0)
178      {
179        sb.append("  ");
180      }
181      if (backendsToDelete.size() == 1)
182      {
183        sb.append(INFO_CTRL_PANEL_DELETE_BACKEND_DESCRIPTION.get(
184            backendsToDelete.iterator().next().getBackendID()));
185      }
186      else
187      {
188        ArrayList<String> ids = new ArrayList<>();
189        for (BackendDescriptor backend : backendsToDelete)
190        {
191          ids.add(backend.getBackendID());
192        }
193        sb.append(INFO_CTRL_PANEL_DELETE_BACKENDS_DESCRIPTION.get(
194        Utilities.getStringFromCollection(ids, ", ")));
195      }
196    }
197    return LocalizableMessage.raw(sb.toString());
198  }
199
200  @Override
201  public boolean canLaunch(Task taskToBeLaunched,
202      Collection<LocalizableMessage> incompatibilityReasons)
203  {
204    boolean canLaunch = true;
205    if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
206    {
207      // All the operations are incompatible if they apply to this
208      // backend for safety.  This is a short operation so the limitation
209      // has not a lot of impact.
210      Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends());
211      backends.retainAll(getBackends());
212      if (!backends.isEmpty())
213      {
214        incompatibilityReasons.add(
215            getIncompatibilityMessage(this, taskToBeLaunched));
216        canLaunch = false;
217      }
218    }
219    return canLaunch;
220  }
221
222  /**
223   * Update the configuration in the server.
224   * @throws OpenDsException if an error occurs.
225   */
226  private void updateConfiguration() throws OpenDsException, ConfigException
227  {
228    boolean configHandlerUpdated = false;
229    final int totalNumber = baseDNsToDelete.size() + backendsToDelete.size();
230    int numberDeleted = 0;
231    try
232    {
233      if (!isServerRunning())
234      {
235        configHandlerUpdated = true;
236        getInfo().stopPooling();
237        if (getInfo().mustDeregisterConfig())
238        {
239          DirectoryServer.deregisterBaseDN(DN.valueOf("cn=config"));
240        }
241        DirectoryServer.getInstance().initializeConfiguration(
242            org.opends.server.extensions.ConfigFileHandler.class.getName(),
243            ConfigReader.configFile);
244        getInfo().setMustDeregisterConfig(true);
245      }
246      boolean isFirst = true;
247      for (final Set<BaseDNDescriptor> baseDNs : baseDNsToDelete.values())
248      {
249        if (!isFirst)
250        {
251          SwingUtilities.invokeLater(new Runnable()
252          {
253            @Override
254            public void run()
255            {
256              getProgressDialog().appendProgressHtml("<br><br>");
257            }
258          });
259        }
260        isFirst = false;
261
262        for (BaseDNDescriptor baseDN : baseDNs)
263        {
264          disableReplicationIfRequired(baseDN);
265        }
266
267        if (isServerRunning())
268        {
269          SwingUtilities.invokeLater(new Runnable()
270          {
271            @Override
272            public void run()
273            {
274              List<String> args =
275                getObfuscatedCommandLineArguments(
276                    getDSConfigCommandLineArguments(baseDNs));
277              args.removeAll(getConfigCommandLineArguments());
278              printEquivalentCommandLine(getConfigCommandLinePath(), args,
279                  INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_BASE_DN.get());
280            }
281          });
282        }
283        SwingUtilities.invokeLater(new Runnable()
284        {
285          @Override
286          public void run()
287          {
288            if (baseDNs.size() == 1)
289            {
290              String dn = baseDNs.iterator().next().getDn().toString();
291              getProgressDialog().appendProgressHtml(
292                  Utilities.getProgressWithPoints(
293                      INFO_CTRL_PANEL_DELETING_BASE_DN.get(dn),
294                      ColorAndFontConstants.progressFont));
295            }
296            else
297            {
298              ArrayList<String> dns = new ArrayList<>();
299              for (BaseDNDescriptor baseDN : baseDNs)
300              {
301                dns.add("'" + baseDN.getDn() + "'");
302              }
303              getProgressDialog().appendProgressHtml(
304                  Utilities.getProgressWithPoints(
305                      INFO_CTRL_PANEL_DELETING_BASE_DNS.get(
306                      Utilities.getStringFromCollection(dns, ", ")),
307                      ColorAndFontConstants.progressFont));
308            }
309          }
310        });
311        if (isServerRunning())
312        {
313          deleteBaseDNs(getInfo().getDirContext(), baseDNs);
314        }
315        else
316        {
317          deleteBaseDNs(baseDNs);
318        }
319        numberDeleted ++;
320        final int fNumberDeleted = numberDeleted;
321        SwingUtilities.invokeLater(new Runnable()
322        {
323          @Override
324          public void run()
325          {
326            getProgressDialog().getProgressBar().setIndeterminate(false);
327            getProgressDialog().getProgressBar().setValue(
328                (fNumberDeleted * 100) / totalNumber);
329            getProgressDialog().appendProgressHtml(
330                Utilities.getProgressDone(ColorAndFontConstants.progressFont));
331          }
332        });
333      }
334      for (final BackendDescriptor backend : backendsToDelete)
335      {
336        if (!isFirst)
337        {
338          SwingUtilities.invokeLater(new Runnable()
339          {
340            @Override
341            public void run()
342            {
343              getProgressDialog().appendProgressHtml("<br><br>");
344            }
345          });
346        }
347        for (BaseDNDescriptor baseDN : backend.getBaseDns())
348        {
349          disableReplicationIfRequired(baseDN);
350        }
351        isFirst = false;
352        if (isServerRunning())
353        {
354          SwingUtilities.invokeLater(new Runnable()
355          {
356            @Override
357            public void run()
358            {
359              List<String> args =
360                getObfuscatedCommandLineArguments(
361                    getDSConfigCommandLineArguments(backend));
362              args.removeAll(getConfigCommandLineArguments());
363              printEquivalentCommandLine(getConfigCommandLinePath(), args,
364                  INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_BACKEND.get());
365            }
366          });
367        }
368        SwingUtilities.invokeLater(new Runnable()
369        {
370          @Override
371          public void run()
372          {
373            getProgressDialog().appendProgressHtml(
374                  Utilities.getProgressWithPoints(
375                      INFO_CTRL_PANEL_DELETING_BACKEND.get(
376                          backend.getBackendID()),
377                      ColorAndFontConstants.progressFont));
378          }
379        });
380        if (isServerRunning())
381        {
382          deleteBackend(getInfo().getDirContext(), backend);
383        }
384        else
385        {
386          deleteBackend(backend);
387        }
388        numberDeleted ++;
389        final int fNumberDeleted = numberDeleted;
390        SwingUtilities.invokeLater(new Runnable()
391        {
392          @Override
393          public void run()
394          {
395            getProgressDialog().getProgressBar().setIndeterminate(false);
396            getProgressDialog().getProgressBar().setValue(
397                (fNumberDeleted * 100) / totalNumber);
398            getProgressDialog().appendProgressHtml(
399                Utilities.getProgressDone(ColorAndFontConstants.progressFont));
400          }
401        });
402      }
403    }
404    finally
405    {
406      if (configHandlerUpdated)
407      {
408        DirectoryServer.getInstance().initializeConfiguration(
409            ConfigReader.configClassName, ConfigReader.configFile);
410        getInfo().startPooling();
411      }
412    }
413  }
414
415  /**
416   * Returns the DN in the configuration for a given backend.
417   * @param backend the backend.
418   * @return the backend configuration entry DN.
419   */
420  private String getDN(BackendDescriptor backend)
421  {
422    return Utilities.getRDNString("ds-cfg-backend-id",
423        backend.getBackendID())+",cn=Backends,cn=config";
424  }
425
426  /**
427   * Deletes a set of base DNs.  The code assumes that the server is not running
428   * and that the configuration file can be edited.
429   * @param baseDNs the list of base DNs.
430   * @throws OpenDsException if an error occurs.
431   */
432  private void deleteBaseDNs(Set<BaseDNDescriptor> baseDNs)
433  throws OpenDsException, ConfigException
434  {
435    BackendDescriptor backend = baseDNs.iterator().next().getBackend();
436
437    SortedSet<DN> oldBaseDNs = new TreeSet<>();
438    for (BaseDNDescriptor baseDN : backend.getBaseDns())
439    {
440      oldBaseDNs.add(baseDN.getDn());
441    }
442    LinkedList<DN> newBaseDNs = new LinkedList<>(oldBaseDNs);
443    ArrayList<DN> dnsToRemove = new ArrayList<>();
444    for (BaseDNDescriptor baseDN : baseDNs)
445    {
446      dnsToRemove.add(baseDN.getDn());
447    }
448    newBaseDNs.removeAll(dnsToRemove);
449
450    String backendName = backend.getBackendID();
451    String dn = Utilities.getRDNString("ds-cfg-backend-id", backendName)+
452    ",cn=Backends,cn=config";
453    ConfigEntry configEntry =
454      DirectoryServer.getConfigHandler().getConfigEntry(DN.valueOf(dn));
455
456    DNConfigAttribute baseDNAttr =
457      new DNConfigAttribute(
458          ConfigConstants.ATTR_BACKEND_BASE_DN,
459          INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BASE_DNS.get(),
460          true, true, false, newBaseDNs);
461    configEntry.putConfigAttribute(baseDNAttr);
462    DirectoryServer.getConfigHandler().writeUpdatedConfig();
463  }
464
465  /**
466   * Deletes a set of base DNs.  The code assumes that the server is running
467   * and that the provided connection is active.
468   * @param baseDNs the list of base DNs.
469   * @param ctx the connection to the server.
470   * @throws OpenDsException if an error occurs.
471   */
472  private void deleteBaseDNs(InitialLdapContext ctx,
473      Set<BaseDNDescriptor> baseDNs) throws OpenDsException
474  {
475    ManagementContext mCtx = LDAPManagementContext.createFromContext(
476        JNDIDirContextAdaptor.adapt(ctx));
477    RootCfgClient root = mCtx.getRootConfiguration();
478    PluggableBackendCfgClient backend =
479      (PluggableBackendCfgClient)root.getBackend(
480          baseDNs.iterator().next().getBackend().getBackendID());
481    SortedSet<DN> oldBaseDNs = backend.getBaseDN();
482    SortedSet<DN> newBaseDNs = new TreeSet<>(oldBaseDNs);
483    ArrayList<DN> dnsToRemove = new ArrayList<>();
484    for (BaseDNDescriptor baseDN : baseDNs)
485    {
486      dnsToRemove.add(baseDN.getDn());
487    }
488    newBaseDNs.removeAll(dnsToRemove);
489    backend.setBaseDN(newBaseDNs);
490    backend.commit();
491  }
492
493  /**
494   * Deletes a backend.  The code assumes that the server is not running
495   * and that the configuration file can be edited.
496   * @param backend the backend to be deleted.
497   * @throws OpenDsException if an error occurs.
498   */
499  private void deleteBackend(BackendDescriptor backend) throws OpenDsException, ConfigException
500  {
501    String dn = getDN(backend);
502    Utilities.deleteConfigSubtree(
503        DirectoryServer.getConfigHandler(), DN.valueOf(dn));
504  }
505
506  /**
507   * Deletes a backend.  The code assumes that the server is running
508   * and that the provided connection is active.
509   * @param backend the backend to be deleted.
510   * @param ctx the connection to the server.
511   * @throws OpenDsException if an error occurs.
512   */
513  private void deleteBackend(InitialLdapContext ctx,
514      BackendDescriptor backend) throws OpenDsException
515  {
516    ManagementContext mCtx = LDAPManagementContext.createFromContext(
517        JNDIDirContextAdaptor.adapt(ctx));
518    RootCfgClient root = mCtx.getRootConfiguration();
519    root.removeBackend(backend.getBackendID());
520    root.commit();
521  }
522
523  @Override
524  protected String getCommandLinePath()
525  {
526    return null;
527  }
528
529  @Override
530  protected ArrayList<String> getCommandLineArguments()
531  {
532    return new ArrayList<>();
533  }
534
535  /**
536   * Returns the path of the command line to be used.
537   *
538   * @return the path of the command line to be used
539   */
540  private String getConfigCommandLinePath()
541  {
542    if (isServerRunning())
543    {
544      return getCommandLinePath("dsconfig");
545    }
546    return null;
547  }
548
549  @Override
550  public void runTask()
551  {
552    state = State.RUNNING;
553    lastException = null;
554
555    try
556    {
557      updateConfiguration();
558      state = State.FINISHED_SUCCESSFULLY;
559    }
560    catch (Throwable t)
561    {
562      lastException = t;
563      state = State.FINISHED_WITH_ERROR;
564    }
565  }
566
567  /**
568   * Return the dsconfig arguments required to delete a set of base DNs.
569   * @param baseDNs the base DNs to be deleted.
570   * @return the dsconfig arguments required to delete a set of base DNs.
571   */
572  private ArrayList<String> getDSConfigCommandLineArguments(
573      Set<BaseDNDescriptor> baseDNs)
574  {
575    ArrayList<String> args = new ArrayList<>();
576    if (isServerRunning())
577    {
578      args.add("set-backend-prop");
579      args.add("--backend-name");
580      args.add(baseDNs.iterator().next().getBackend().getBackendID());
581      args.add("--remove");
582      for (BaseDNDescriptor baseDN : baseDNs)
583      {
584        args.add("base-dn:" + baseDN.getDn());
585      }
586      args.addAll(getConnectionCommandLineArguments());
587      args.add("--no-prompt");
588    }
589    return args;
590  }
591
592  /**
593   * Return the dsconfig arguments required to delete a backend.
594   * @param backend the backend to be deleted.
595   * @return the dsconfig arguments required to delete a backend.
596   */
597  private ArrayList<String> getDSConfigCommandLineArguments(
598      BackendDescriptor backend)
599  {
600    ArrayList<String> args = new ArrayList<>();
601    args.add("delete-backend");
602    args.add("--backend-name");
603    args.add(backend.getBackendID());
604
605    args.addAll(getConnectionCommandLineArguments());
606    args.add("--no-prompt");
607    return args;
608  }
609
610  /**
611   * Disables replication if required: if the deleted base DN is replicated,
612   * update the replication configuration to remove any reference to it.
613   * @param baseDN the base DN that is going to be removed.
614   * @throws OpenDsException if an error occurs.
615   */
616  private void disableReplicationIfRequired(final BaseDNDescriptor baseDN)
617  throws OpenDsException, ConfigException
618  {
619    if (baseDN.getType() == BaseDNDescriptor.Type.REPLICATED)
620    {
621      final AtomicReference<String> domainName = new AtomicReference<>();
622
623      try
624      {
625        if (isServerRunning())
626        {
627          InitialLdapContext ctx = getInfo().getDirContext();
628          ManagementContext mCtx = LDAPManagementContext.createFromContext(
629              JNDIDirContextAdaptor.adapt(ctx));
630          RootCfgClient root = mCtx.getRootConfiguration();
631          ReplicationSynchronizationProviderCfgClient sync = null;
632          try
633          {
634            sync = (ReplicationSynchronizationProviderCfgClient)
635            root.getSynchronizationProvider("Multimaster Synchronization");
636          }
637          catch (OpenDsException oe)
638          {
639            // Ignore this one
640          }
641          if (sync != null)
642          {
643            String[] domains = sync.listReplicationDomains();
644            if (domains != null)
645            {
646              for (String dName : domains)
647              {
648                ReplicationDomainCfgClient domain = sync.getReplicationDomain(dName);
649                if (baseDN.getDn().equals(domain.getBaseDN()))
650                {
651                  domainName.set(dName);
652                  sync.removeReplicationDomain(dName);
653                  sync.commit();
654                  break;
655                }
656              }
657            }
658          }
659        }
660        else
661        {
662          RootCfg root =
663            ServerManagementContext.getInstance().getRootConfiguration();
664          ReplicationSynchronizationProviderCfg sync = null;
665          try
666          {
667            sync = (ReplicationSynchronizationProviderCfg)
668            root.getSynchronizationProvider("Multimaster Synchronization");
669          }
670          catch (ConfigException oe)
671          {
672            // Ignore this one
673          }
674          if (sync != null)
675          {
676            String[] domains = sync.listReplicationDomains();
677            if (domains != null)
678            {
679              for (String dName : domains)
680              {
681                ReplicationDomainCfg domain = sync.getReplicationDomain(dName);
682                DN dn = domain.getBaseDN();
683                if (dn.equals(baseDN.getDn()))
684                {
685                  domainName.set(dName);
686                  DN entryDN = domain.dn();
687                  Utilities.deleteConfigSubtree(
688                      DirectoryServer.getConfigHandler(), entryDN);
689                  break;
690                }
691              }
692            }
693          }
694        }
695      }
696      finally
697      {
698        // This is not super clean, but this way we calculate the domain name only once.
699        if (isServerRunning() && domainName.get() != null)
700        {
701          SwingUtilities.invokeLater(new Runnable()
702          {
703            @Override
704            public void run()
705            {
706              List<String> args =
707                getObfuscatedCommandLineArguments(
708                    getCommandLineArgumentsToDisableReplication(domainName.get()));
709              args.removeAll(getConfigCommandLineArguments());
710              args.add(getNoPropertiesFileArgument());
711              printEquivalentCommandLine(getConfigCommandLinePath(), args,
712                  INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_DOMAIN.get(baseDN.getDn()));
713              }
714          });
715        }
716        SwingUtilities.invokeLater(new Runnable()
717        {
718          @Override
719          public void run()
720          {
721            getProgressDialog().appendProgressHtml(
722                Utilities.getProgressWithPoints(
723                    INFO_CTRL_PANEL_DELETING_DOMAIN.get(baseDN.getDn()),
724                    ColorAndFontConstants.progressFont));
725          }
726        });
727      }
728      SwingUtilities.invokeLater(new Runnable()
729      {
730        @Override
731        public void run()
732        {
733          getProgressDialog().appendProgressHtml(
734              Utilities.getProgressDone(ColorAndFontConstants.progressFont)+
735              "<br>");
736        }
737      });
738    }
739  }
740
741  /**
742   * Return the dsconfig arguments required to delete a replication domain.
743   * @param domainName the name of the domain to be deleted.
744   * @return the dsconfig arguments required to delete a replication domain.
745   */
746  private ArrayList<String> getCommandLineArgumentsToDisableReplication(
747      String domainName)
748  {
749    ArrayList<String> args = new ArrayList<>();
750    args.add("delete-replication-domain");
751    args.add("--provider-name");
752    args.add("Multimaster Synchronization");
753    args.add("--domain-name");
754    args.add(domainName);
755    args.addAll(getConnectionCommandLineArguments());
756    args.add("--no-prompt");
757    return args;
758  }
759}
760