← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4903: Minor fix

 

------------------------------------------------------------
revno: 4903
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-10-12 10:34:07 +0200
message:
  Minor fix
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/exp/ExportDataMartAction.java


--
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-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java	2011-10-06 15:39:08 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java	2011-10-12 08:34:07 +0000
@@ -45,6 +45,7 @@
 {
     public static final String CONTENT_TYPE_PDF = "application/pdf";
     public static final String CONTENT_TYPE_ZIP = "application/zip";
+    public static final String CONTENT_TYPE_GZIP = "application/gzip";
     public static final String CONTENT_TYPE_JSON = "application/json";
     public static final String CONTENT_TYPE_HTML = "text/html";
     public static final String CONTENT_TYPE_TEXT = "text/plain";

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/exp/ExportDataMartAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/exp/ExportDataMartAction.java	2011-10-12 07:51:57 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/exp/ExportDataMartAction.java	2011-10-12 08:34:07 +0000
@@ -27,7 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.text.DateFormat;
@@ -45,9 +44,9 @@
 import org.hisp.dhis.importexport.synchronous.ExportPivotViewService;
 import org.hisp.dhis.importexport.synchronous.ExportPivotViewService.RequestType;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.StreamUtils;
 import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.util.ContextUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -206,7 +205,8 @@
                 {
                     paramError = BAD_ENDDATE;
                 }
-            } catch ( java.text.ParseException ex )
+            } 
+            catch ( java.text.ParseException ex )
             {
                 paramError = ex.getMessage();
             }
@@ -221,7 +221,7 @@
 
         // timestamp filename
         SimpleDateFormat format = new SimpleDateFormat( "_yyyy_MM_dd_HHmm_ss" );
-        String fileName = requestType + format.format(Calendar.getInstance().getTime()) + ".csv.gz";
+        String filename = requestType + format.format(Calendar.getInstance().getTime()) + ".csv.gz";
 
         PeriodType pType = PeriodType.getPeriodTypeByName( periodType );
         
@@ -232,10 +232,8 @@
         int count = exportPivotViewService.count( requestType, pType, start, end,
                 dataSourceLevel, dataSourceRoot);
 
-        response.setContentType( "application/gzip");
-        response.addHeader( "Content-Disposition", "attachment; filename=\""+fileName+"\"" );
-        response.addHeader( "Cache-Control", "no-cache" );
-        response.addHeader( "Expires", DateUtils.getExpiredHttpDateString() );
+        ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_GZIP, true, filename, true );
+
         // write number of rows to custom header
         response.addHeader( "X-Number-Of-Rows", String.valueOf( count ) );