From 06ec8c88556b02782c7b91a233de91eaf4a1439d Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 09 Jun 2009 12:28:05 +0000
Subject: [PATCH] Fix for issue 3550 (Consider making the control panel able to manage remote servers)

---
 opends/src/guitools/org/opends/guitools/controlpanel/task/RebuildIndexTask.java |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/task/RebuildIndexTask.java b/opends/src/guitools/org/opends/guitools/controlpanel/task/RebuildIndexTask.java
index b85b9b0..a2ccac5 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/task/RebuildIndexTask.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/task/RebuildIndexTask.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2009 Sun Microsystems, Inc.
  */
 
 package org.opends.guitools.controlpanel.task;
@@ -50,6 +50,7 @@
 import org.opends.server.admin.client.ldap.LDAPManagementContext;
 import org.opends.server.admin.std.client.LocalDBBackendCfgClient;
 import org.opends.server.admin.std.client.RootCfgClient;
+import org.opends.server.tools.RebuildIndex;
 import org.opends.server.types.OpenDsException;
 import org.opends.server.util.cli.CommandBuilder;
 
@@ -109,7 +110,7 @@
       Collection<Message> incompatibilityReasons)
   {
     boolean canLaunch = true;
-    if (state == State.RUNNING)
+    if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
     {
       // All the operations are incompatible if they apply to this
       // backend.
@@ -137,8 +138,9 @@
     {
       boolean mustDisable = false;
       boolean mustEnable = false;
+      boolean isLocal = getInfo().getServerDescriptor().isLocal();
       String backendName = backendSet.iterator().next();
-      if (isServerRunning())
+      if (isServerRunning() && isLocal)
       {
         for (BackendDescriptor backend :
           getInfo().getServerDescriptor().getBackends())
@@ -188,8 +190,16 @@
           }
         });
 
-        returnCode = executeCommandLine(getCommandLinePath("rebuild-index"),
-            args);
+        if (isLocal)
+        {
+          returnCode = executeCommandLine(getCommandLinePath("rebuild-index"),
+              args);
+        }
+        else
+        {
+          returnCode = RebuildIndex.mainRebuildIndex(args, false,
+              outPrintStream, errorPrintStream);
+        }
 
         if (returnCode != 0)
         {
@@ -258,6 +268,13 @@
       }
     }
 
+    boolean isLocal = getInfo().getServerDescriptor().isLocal();
+    if (!isLocal)
+    {
+      args.addAll(getConnectionCommandLineArguments());
+      args.addAll(getConfigCommandLineArguments());
+    }
+
     return args;
   }
 

--
Gitblit v1.10.0