From d8328dc2a72a9709cccecbb05be817a9f9d190e5 Mon Sep 17 00:00:00 2001
From: brinn <brinn>
Date: Mon, 10 Oct 2011 22:14:46 +0000
Subject: [PATCH] fix: CommandQueueLister

SVN: 23263
---
 .../dss/generic/server/CommandQueueLister.java    |  4 ++--
 .../dss/generic/server/ConfigParameters.java      | 15 ++++++++++++++-
 .../generic/server/DataSetCommandExecutor.java    | 10 +++++++++-
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/CommandQueueLister.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/CommandQueueLister.java
index 2a0c14a5970..843b4c150c1 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/CommandQueueLister.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/CommandQueueLister.java
@@ -16,7 +16,6 @@
 
 package ch.systemsx.cisd.openbis.dss.generic.server;
 
-
 /**
  * A class that provides a lister for the commands in the command queue of the store.
  * 
@@ -32,6 +31,7 @@ public final class CommandQueueLister
     public static void listQueuedCommand()
     {
         final ConfigParameters configParams = DataStoreServer.getConfigParameters();
-        DataSetCommandExecutor.listQueuedCommands(configParams.getStorePath());
+        DataSetCommandExecutor.listQueuedCommands(configParams.getCommandQueueDir());
     }
+    
 }
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ConfigParameters.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ConfigParameters.java
index ae4087b6b4d..c5c0ce9d5ba 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ConfigParameters.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ConfigParameters.java
@@ -65,6 +65,8 @@ public final class ConfigParameters implements IServletPropertiesManager
 
     static final String AUTH_CACHE_EXPIRATION_TIME = "authorization-cache-expiration-time";
 
+    static final String COMMAND_QUEUE_DIR = "commandqueue-dir";
+
     static final int DEFAULT_AUTH_CACHE_EXPIRATION_TIME_MINS = 5;
 
     static final String AUTH_CACHE_CLEANUP_TIMER_PERIOD =
@@ -130,6 +132,8 @@ public final class ConfigParameters implements IServletPropertiesManager
 
     private final String webstartJarPath;
 
+    private final File commandQueueDir;
+
     /**
      * Creates an instance based on the specified properties.
      * 
@@ -138,7 +142,9 @@ public final class ConfigParameters implements IServletPropertiesManager
     ConfigParameters(final Properties properties)
     {
         this.properties = properties;
-        storePath = new File(PropertyUtils.getMandatoryProperty(properties, STOREROOT_DIR_KEY));
+        final String storeRootDir =
+                PropertyUtils.getMandatoryProperty(properties, STOREROOT_DIR_KEY);
+        storePath = new File(storeRootDir);
         dssInternalTempDir = getInternalTempDirectory(properties);
         rpcIncomingDirectory = getRpcIncomingDirectory(properties);
         port = getMandatoryIntegerProperty(properties, PORT_KEY);
@@ -146,6 +152,8 @@ public final class ConfigParameters implements IServletPropertiesManager
         downloadURL = PropertyUtils.getMandatoryProperty(properties, DOWNLOAD_URL);
         sessionTimeout = getMandatoryIntegerProperty(properties, SESSION_TIMEOUT_KEY) * 60;
         useSSL = PropertyUtils.getBoolean(properties, USE_SSL, true);
+        commandQueueDir =
+                new File(PropertyUtils.getProperty(properties, COMMAND_QUEUE_DIR, storeRootDir));
         if (useSSL == true)
         {
             keystorePath = PropertyUtils.getMandatoryProperty(properties, KEYSTORE_PATH_KEY);
@@ -237,6 +245,11 @@ public final class ConfigParameters implements IServletPropertiesManager
         return storePath;
     }
 
+    public File getCommandQueueDir()
+    {
+        return commandQueueDir;
+    }
+
     public final File getRpcIncomingDirectory()
     {
         return rpcIncomingDirectory;
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataSetCommandExecutor.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataSetCommandExecutor.java
index d0bdcaaf930..975974e66bc 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataSetCommandExecutor.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataSetCommandExecutor.java
@@ -203,7 +203,15 @@ class DataSetCommandExecutor implements IDataSetCommandExecutor
             System.out.println("Found " + commandQueue.size() + " items in command queue:");
             for (final IDataSetCommand cmd : commandQueue)
             {
-                System.out.println(cmd.getDescription());
+                try
+                {
+                    System.out.println(cmd.getDescription());
+                } catch (RuntimeException ex)
+                {
+                    System.err.printf("Error showing description of command '%s':\n", cmd
+                            .getClass().getSimpleName());
+                    ex.printStackTrace();
+                }
             }
         }
     }
-- 
GitLab