[jasper-library-upgrade] Improvements in temporal file deletion
authorCarlos Aristu <carlos.aristu@openbravo.com>
Thu, 21 May 2015 10:04:24 +0200
changeset 26756 70d08d47878a
parent 26755 6d5c5043d245
child 26757 a1fbec4aff43
[jasper-library-upgrade] Improvements in temporal file deletion
src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java
--- a/src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java	Wed May 20 19:06:43 2015 +0200
+++ b/src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java	Thu May 21 10:04:24 2015 +0200
@@ -506,9 +506,13 @@
       e.printStackTrace();
     } finally {
       try {
-        for (Iterator<Report> iterator = reports.iterator(); iterator.hasNext();) {
-          Report report = iterator.next();
-          if (report.outputType.equals(OutputTypeEnum.ARCHIVE)) {
+        os.close();
+        response.flushBuffer();
+      } catch (IOException e) {
+        log4j.error(e.getMessage(), e);
+      } finally {
+        try {
+          for (Report report : reports) {
             // Delete temporal reports generated for the returned report in case they have been
             // attached also
             File file = new File(report.getTargetLocation());
@@ -516,11 +520,9 @@
               file.delete();
             }
           }
+        } catch (IOException e) {
+          log4j.error("Error deleting temporal reports", e);
         }
-        os.close();
-        response.flushBuffer();
-      } catch (IOException e) {
-        log4j.error(e.getMessage(), e);
       }
     }
   }