← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2379: Excel reporting - Fixed bug when generating excel file output running forever.

 

------------------------------------------------------------
revno: 2379
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2010-12-15 14:52:20 +0700
message:
  Excel reporting - Fixed bug when generating excel file output running forever.
modified:
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/action/DownloadFileAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportNormalAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/action/DownloadFileAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/action/DownloadFileAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/action/DownloadFileAction.java	2010-12-15 07:52:20 +0000
@@ -27,6 +27,9 @@
 
 package org.hisp.dhis.reportexcel.action;
 
+import static org.apache.commons.io.FilenameUtils.getExtension;
+import static org.apache.commons.lang.StringUtils.isBlank;
+
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -44,6 +47,8 @@
 public class DownloadFileAction
     implements Action
 {
+    private static final String PREFIX_OUTPUT_STREAM = "application/";
+    
     // -------------------------------------------
     // Dependency
     // -------------------------------------------
@@ -95,6 +100,11 @@
         File output = new File( selectionManager.getDownloadFilePath() );
 
         fileName = output.getName();
+        
+        if ( isBlank( outputFormat ) )
+        {
+            outputFormat = PREFIX_OUTPUT_STREAM + getExtension( fileName );
+        }
 
         inputStream = new BufferedInputStream( new FileInputStream( output ) );
 

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportNormalAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportNormalAction.java	2010-09-16 07:33:22 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportNormalAction.java	2010-12-15 07:52:20 +0000
@@ -44,7 +44,6 @@
 public class GenerateReportNormalAction
     extends GenerateReportSupport
 {
-
     @Override
     public String execute()
         throws Exception

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java	2010-12-15 07:52:20 +0000
@@ -41,7 +41,6 @@
  */
 public class FileUtils
 {
-
     public static List<String> getListFileName( File directory, String extentions )
     {
         List<String> result = new ArrayList<String>();

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml	2010-12-15 05:44:19 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml	2010-12-15 07:52:20 +0000
@@ -26,7 +26,7 @@
 				<param name="contentType">${outputFormat}</param>
 				<param name="inputName">inputStream</param>
 				<param name="contentDisposition">filename="${fileName}"</param>
-				<param name="bufferSize">1024</param>
+				<param name="bufferSize">10240</param>
 			</result>
 		</action>