continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From batkin...@apache.org
Subject svn commit: r1671645 - /continuum/trunk/continuum-purge/continuum-purge-master/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java
Date Mon, 06 Apr 2015 18:59:47 GMT
Author: batkinson
Date: Mon Apr  6 18:59:46 2015
New Revision: 1671645

URL: http://svn.apache.org/r1671645
Log:
Pulled directory executor creation out of controller and into factory.

Modified:
    continuum/trunk/continuum-purge/continuum-purge-master/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java

Modified: continuum/trunk/continuum-purge/continuum-purge-master/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/continuum-purge-master/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java?rev=1671645&r1=1671644&r2=1671645&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/continuum-purge-master/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java
(original)
+++ continuum/trunk/continuum-purge/continuum-purge-master/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java
Mon Apr  6 18:59:46 2015
@@ -67,20 +67,32 @@ public class DirectoryPurgeController
         throws ContinuumPurgeExecutorException
     {
         DirectoryPurgeConfiguration dirPurge = (DirectoryPurgeConfiguration) purgeConfig;
+        purgeExecutor = new DirectoryPurgeExecutorFactoryImpl().create( dirPurge.isDeleteAll(),
dirPurge.getDaysOlder(),
+                                                                        dirPurge.getRetentionCount(),
+                                                                        dirPurge.getDirectoryType()
);
+    }
+}
 
-        if ( dirPurge.isDeleteAll() )
-        {
-            purgeExecutor = new CleanAllPurgeExecutor( dirPurge.getDirectoryType() );
-        }
-        else if ( dirPurge.getDaysOlder() > 0 )
+interface DirectoryPurgeExecutorFactory
+{
+    ContinuumPurgeExecutor create( boolean deleteAll, int daysOld, int retentionCount, String
dirType );
+}
+
+class DirectoryPurgeExecutorFactoryImpl
+    implements DirectoryPurgeExecutorFactory
+{
+    public ContinuumPurgeExecutor create( boolean deleteAll, int daysOld, int retentionCount,
String dirType )
+    {
+        if ( deleteAll )
         {
-            purgeExecutor = new DaysOldDirectoryPurgeExecutor( dirPurge.getDaysOlder(), dirPurge.getRetentionCount(),
-                                                               dirPurge.getDirectoryType()
);
+            return new CleanAllPurgeExecutor( dirType );
         }
-        else
+
+        if ( daysOld > 0 )
         {
-            purgeExecutor = new RetentionCountDirectoryPurgeExecutor( dirPurge.getRetentionCount(),
-                                                                      dirPurge.getDirectoryType()
);
+            return new DaysOldDirectoryPurgeExecutor( daysOld, retentionCount, dirType );
         }
+
+        return new RetentionCountDirectoryPurgeExecutor( retentionCount, dirType );
     }
 }



Mime
View raw message