← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 86: Rollbacked changes to SaveDocumentAction.java

 

------------------------------------------------------------
revno: 86
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Thu 2009-03-19 14:02:31 +0100
message:
  Rollbacked changes to SaveDocumentAction.java
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java	2009-03-19 12:56:27 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/document/action/SaveDocumentAction.java	2009-03-19 13:02:31 +0000
@@ -1,17 +1,12 @@
 package org.hisp.dhis.reporting.document.action;
 
-import java.io.BufferedInputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.document.Document;
 import org.hisp.dhis.document.DocumentService;
 import org.hisp.dhis.external.location.LocationManager;
-import org.hisp.dhis.system.util.StreamUtils;
 
 import com.opensymphony.xwork.Action;
 
@@ -96,31 +91,15 @@
         if ( !external )
         {
             log.info( "Uploading file: '" + fileName + "', content-type: '" + contentType + "'" );
-            
-            InputStream in = null;
-            
-            OutputStream out = null;
-            
-            try
-            {
-                in = new BufferedInputStream( new FileInputStream( file ) );
-                
-                out = locationManager.getOutputStream( fileName, DocumentService.DIR );
 
-                int b = 0;
-                
-                while ( ( b = in.read() ) != -1 )
-                {
-                    out.write( b );
-                }                
+            File destination = locationManager.getFileForWriting( fileName, DocumentService.DIR );
+            
+            boolean fileMoved = file.renameTo( destination );
+            
+            if ( !fileMoved )
+            {
+                throw new RuntimeException( "File was not uploaded" );
             }
-            catch ( Exception ex )
-            {
-                StreamUtils.closeInputStream( in );
-                StreamUtils.closeOutputStream( out );
-                
-                throw ex;
-            }            
             
             url = fileName;
         }



--

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.