From 2e8bc7cf68c916a9b3a16297eb5c1dff6f630daa Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Wed, 3 Mar 2010 13:59:20 +0000
Subject: [PATCH] LMS-1410 Refactoring in order to create
 TransferredDataSetHandler independently

SVN: 15012
---
 .../ch/systemsx/cisd/etlserver/ETLDaemon.java | 30 ++++++++++++-------
 .../systemsx/cisd/etlserver/Parameters.java   | 12 +-------
 .../cisd/etlserver/ThreadParameters.java      |  2 +-
 3 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/ETLDaemon.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/ETLDaemon.java
index 513f743ef56..19c65eaf429 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/ETLDaemon.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/ETLDaemon.java
@@ -257,18 +257,9 @@ public final class ETLDaemon
             IDataSetValidator dataSetValidator, final boolean notifySuccessfulRegistration)
     {
         final File incomingDataDirectory = threadParameters.getIncomingDataDirectory();
-        final IETLServerPlugin plugin = threadParameters.getPlugin();
-        final Properties properties = parameters.getProperties();
-        final File storeRootDir = getStoreRootDir(properties);
-        migrateStoreRootDir(storeRootDir, authorizedLimsService.getHomeDatabaseInstance());
-        plugin.getStorageProcessor().setStoreRootDirectory(storeRootDir);
-        final Properties mailProperties = parameters.getMailProperties();
-        String dssCode = PropertyParametersUtil.getDataStoreCode(properties);
         final TransferredDataSetHandler pathHandler =
-                new TransferredDataSetHandler(dssCode, plugin, authorizedLimsService,
-                        mailProperties, dataSetValidator, notifySuccessfulRegistration,
-                        threadParameters.useIsFinishedMarkerFile(), threadParameters
-                                .deleteUnidentified());
+                createDataSetHandler(parameters.getProperties(), threadParameters,
+                        authorizedLimsService, dataSetValidator, notifySuccessfulRegistration);
         final HighwaterMarkDirectoryScanningHandler directoryScanningHandler =
                 createDirectoryScanningHandler(pathHandler, highwaterMarkWatcher,
                         incomingDataDirectory, threadParameters.reprocessFaultyDatasets());
@@ -287,6 +278,23 @@ public final class ETLDaemon
                 threadParameters.getThreadName());
     }
 
+    public static TransferredDataSetHandler createDataSetHandler(final Properties properties,
+            final ThreadParameters threadParameters,
+            final IEncapsulatedOpenBISService openBISService,
+            IDataSetValidator dataSetValidator, final boolean notifySuccessfulRegistration)
+    {
+        final IETLServerPlugin plugin = threadParameters.getPlugin();
+        final File storeRootDir = getStoreRootDir(properties);
+        migrateStoreRootDir(storeRootDir, openBISService.getHomeDatabaseInstance());
+        plugin.getStorageProcessor().setStoreRootDirectory(storeRootDir);
+        final Properties mailProperties = Parameters.createMailProperties(properties);
+        String dssCode = PropertyParametersUtil.getDataStoreCode(properties);
+        boolean deleteUnidentified = threadParameters.deleteUnidentified();
+        return new TransferredDataSetHandler(dssCode, plugin, openBISService,
+                mailProperties, dataSetValidator, notifySuccessfulRegistration,
+                threadParameters.useIsFinishedMarkerFile(), deleteUnidentified);
+    }
+
     private static FileFilter createFileFilter(File incomingDataDirectory,
             boolean useIsFinishedMarkerFile, Parameters parameters)
     {
diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/Parameters.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/Parameters.java
index aa1681476b8..87e0682de09 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/Parameters.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/Parameters.java
@@ -106,9 +106,6 @@ public class Parameters
     @Option(name = "p", longName = "password", usage = "User login password")
     private String password;
 
-    /** A subset of <code>service.properties</code> that are reserved for the <i>JavaMail API</i>. */
-    private final Properties mailProperties;
-
     /**
      * The command line parser.
      */
@@ -167,7 +164,6 @@ public class Parameters
             this.serviceProperties = PropertyParametersUtil.loadServiceProperties();
             PropertyUtils.trimProperties(serviceProperties);
             this.threads = createThreadParameters(serviceProperties);
-            this.mailProperties = createMailProperties(serviceProperties);
             this.timingParameters = TimingParameters.create(serviceProperties);
             this.maintenancePlugins = createMaintenancePlugins(serviceProperties);
 
@@ -267,7 +263,7 @@ public class Parameters
         return threadParameters;
     }
 
-    private final static Properties createMailProperties(final Properties serviceProperties)
+    final static Properties createMailProperties(final Properties serviceProperties)
     {
         final Properties properties =
                 ExtendedProperties.getSubset(serviceProperties, "mail", false);
@@ -346,12 +342,6 @@ public class Parameters
         return serviceProperties;
     }
 
-    /** Returns <code>mailProperties</code>. */
-    public final Properties getMailProperties()
-    {
-        return mailProperties;
-    }
-
     /**
      * Returns the timing parameters for monitored operations.
      */
diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/ThreadParameters.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/ThreadParameters.java
index 676eabda4da..8acd5214b50 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/ThreadParameters.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/ThreadParameters.java
@@ -171,7 +171,7 @@ public final class ThreadParameters
     /**
      * Returns The directory to monitor for incoming data.
      */
-    final File getIncomingDataDirectory()
+    public final File getIncomingDataDirectory()
     {
         return incomingDataDirectory;
     }
-- 
GitLab