← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20920: Data value async import, docs

 

------------------------------------------------------------
revno: 20920
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-02 00:14:38 -0500
message:
  Data value async import, docs
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.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-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java	2015-11-02 04:51:15 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueSetController.java	2015-11-02 05:14:38 +0000
@@ -50,6 +50,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -205,7 +206,20 @@
             renderService.toXml( response.getOutputStream(), summary );
         }
     }
-    
+
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
+    /**
+     * Starts an asynchronous import task.
+     * 
+     * @param importOptions the ImportOptions.
+     * @param format the resource representation format.
+     * @param request the HttpRequest.
+     * @param response the HttpResponse.
+     * @throws IOException
+     */
     private void startAsyncImport( ImportOptions importOptions, String format, HttpServletRequest request, HttpServletResponse response )
         throws IOException
     {
@@ -218,6 +232,14 @@
         response.setStatus( HttpServletResponse.SC_ACCEPTED );
     }
     
+    /**
+     * Writes the input stream to a temporary file, and returns a new input
+     * stream connected to the file.
+     * 
+     * @param in the InputStream.
+     * @return an InputStream.
+     * @throws IOException
+     */
     private InputStream saveTmp( InputStream in )
         throws IOException
     {
@@ -230,6 +252,6 @@
             IOUtils.copy( in, out );
         }
         
-        return new FileInputStream( tmpFile );
+        return new BufferedInputStream( new FileInputStream( tmpFile ) );
     }
 }