From 54e1cee8f30772ceccc67d76994d14bc78a4a059 Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Tue, 21 Aug 2007 06:39:58 +0000
Subject: [PATCH] Code Review: createMoveAndProcess() refactored to improve
 readability

SVN: 1430
---
 .../cisd/datamover/MonitorStarter.java        | 50 +++++++++----------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/MonitorStarter.java b/datamover/source/java/ch/systemsx/cisd/datamover/MonitorStarter.java
index fcedd2b7b06..739aec3c49b 100644
--- a/datamover/source/java/ch/systemsx/cisd/datamover/MonitorStarter.java
+++ b/datamover/source/java/ch/systemsx/cisd/datamover/MonitorStarter.java
@@ -96,16 +96,39 @@ public class MonitorStarter
     private IPathHandler createIncomingMovingPathHandler(String sourceHost, File manualInterventionDir,
             RegexFileFilter manualInterventionFilter, RegexFileFilter cleansingFilter)
     {
-        IPathHandler moveFromIncoming = createPathMoverToLocal(sourceHost, inProgressDir);
         IPathHandler processMoved =
                 createProcessMovedFile(readyToMoveDir, tempDir, parameters.tryGetExtraCopyStore(), factory);
-        IPathHandler moveAndProcess = createMoveAndProcess(moveFromIncoming, inProgressDir, processMoved);
+        IPathHandler moveAndProcess = createMoveAndProcess(sourceHost, processMoved);
         IPathHandler manualInterventionMover = createPathMoverToLocal(sourceHost, manualInterventionDir);
         CleansingPathHandlerDecorator cleansingOrMover =
                 new CleansingPathHandlerDecorator(cleansingFilter, moveAndProcess);
         return new GatePathHandlerDecorator(manualInterventionFilter, cleansingOrMover, manualInterventionMover);
     }
 
+    private IPathHandler createMoveAndProcess(String sourceHost, final IPathHandler processMoved)
+    {
+        final IPathHandler moveFromIncoming = createPathMoverToLocal(sourceHost, inProgressDir);
+        IPathHandler moveAndProcess = new IPathHandler()
+            {
+                public boolean handle(File path)
+                {
+                    boolean ok = moveFromIncoming.handle(path);
+                    if (ok)
+                    {
+                        // create path in destination directory
+                        File movedFile = new File(inProgressDir, path.getName());
+                        File markFile = new File(inProgressDir, Constants.IS_FINISHED_PREFIX + path.getName());
+                        assert movedFile.exists();
+                        assert markFile.exists();
+                        markFile.delete(); // process even if mark file could not be deleted
+                        ok = processMoved.handle(movedFile);
+                    }
+                    return ok;
+                }
+            };
+        return moveAndProcess;
+    }
+
     private static IPathHandler createProcessMovedFile(File destDirectory, File tempDir,
             FileStore extraCopyStoreOrNull, IFileSysOperationsFactory factory)
     {
@@ -159,29 +182,6 @@ public class MonitorStarter
             };
     }
 
-    private static IPathHandler createMoveAndProcess(final IPathHandler moveFromIncoming, final File destinationDir,
-            final IPathHandler processMovedFile)
-    {
-        return new IPathHandler()
-            {
-                public boolean handle(File path)
-                {
-                    boolean ok = moveFromIncoming.handle(path);
-                    if (ok)
-                    {
-                        // create path in destination directory
-                        File movedFile = new File(destinationDir, path.getName());
-                        File markFile = new File(destinationDir, Constants.IS_FINISHED_PREFIX + path.getName());
-                        assert movedFile.exists();
-                        assert markFile.exists();
-                        markFile.delete(); // process even if mark file could not be deleted
-                        ok = processMovedFile.handle(movedFile);
-                    }
-                    return ok;
-                }
-            };
-    }
-
     private IPathHandler createPathMoverToLocal(String sourceHost, final File localDestDir)
     {
         if (parameters.getTreatIncomingAsRemote())
-- 
GitLab