Changed if clause to fix #4194
authorAlexander Oppermann <a.oppermann@bgbm.org>
Tue, 22 Apr 2014 08:45:42 +0000 (08:45 +0000)
committerAlexander Oppermann <a.oppermann@bgbm.org>
Tue, 22 Apr 2014 08:45:42 +0000 (08:45 +0000)
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/checklist/ChecklistDemoController.java

index af3de504a17da31eda42d3fdd1d0a32cc9b788ff..caa6e80f272f8c38e7dc13441e672658149203c3 100644 (file)
@@ -95,6 +95,9 @@ public class ChecklistDemoController extends AbstractController implements Resou
      */\r
     private static UUID indexMonitorUuid = null;\r
 \r
      */\r
     private static UUID indexMonitorUuid = null;\r
 \r
+    private final static long DAY_IN_MILLIS = 86400000;\r
+\r
+\r
 \r
        private static final Logger logger = Logger.getLogger(ChecklistDemoController.class);\r
 \r
 \r
        private static final Logger logger = Logger.getLogger(ChecklistDemoController.class);\r
 \r
@@ -227,21 +230,20 @@ public class ChecklistDemoController extends AbstractController implements Resou
         final File cacheFile = new File(new File(System.getProperty("java.io.tmpdir")), classificationUUID);\r
         final String origin = request.getRequestURL().append('?').append(request.getQueryString()).toString();\r
 \r
         final File cacheFile = new File(new File(System.getProperty("java.io.tmpdir")), classificationUUID);\r
         final String origin = request.getRequestURL().append('?').append(request.getQueryString()).toString();\r
 \r
+        Long result = null;\r
+        if(cacheFile.exists()){\r
+            result = System.currentTimeMillis() - cacheFile.lastModified();\r
+        }\r
         //if file exists return file instantly\r
         //if file exists return file instantly\r
-        if(clearCache == false && cacheFile.exists()){\r
-            //timestamp older than one day?\r
-            long result = System.currentTimeMillis() - cacheFile.lastModified();\r
-            final long day = 86400000;\r
+        //timestamp older than one day?\r
+        if(clearCache == false && result != null && result < DAY_IN_MILLIS){\r
             logger.info("result of calculation: " + result);\r
             logger.info("result of calculation: " + result);\r
-            //FIXME: if file older than one day won't trigger new export automatically\r
-//            if(result < day){\r
-                Map<String, File> modelMap = new HashMap<String, File>();\r
-                modelMap.put("file", cacheFile);\r
-                mv.addAllObjects(modelMap);\r
-                FileDownloadView fdv = new FileDownloadView("text/csv", fileName, "txt", "UTF-8");\r
-                mv.setView(fdv);\r
-                return mv;\r
-//            }\r
+            Map<String, File> modelMap = new HashMap<String, File>();\r
+            modelMap.put("file", cacheFile);\r
+            mv.addAllObjects(modelMap);\r
+            FileDownloadView fdv = new FileDownloadView("text/csv", fileName, "txt", "UTF-8");\r
+            mv.setView(fdv);\r
+            return mv;\r
         }else{//trigger progress monitor and performExport()\r
             String processLabel = "Exporting...";\r
             final String frontbaseUrl = null;\r
         }else{//trigger progress monitor and performExport()\r
             String processLabel = "Exporting...";\r
             final String frontbaseUrl = null;\r