diff options
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java')
-rw-r--r-- | src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java index 73ec705..91571ed 100644 --- a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java +++ b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java @@ -3,14 +3,11 @@ package org.openslx.satellitedaemon.ftp; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.net.ConnectException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; -import java.util.ArrayList; import java.util.List; -import java.util.UUID; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.TrustManager; @@ -32,16 +29,13 @@ public class FtpUploadWorker implements Runnable @Override public void run() { - List<DbImage> imageList = new ArrayList<DbImage>(); while ( true ) { - imageList = DbImage.getAllMarkedForUpload(); - // TODO: Maybe use iterator ( for (DbImage image : imageList) ) - while ( !imageList.isEmpty() ) { + List<DbImage> imageList = DbImage.getAllMarkedForUpload(); + for ( DbImage image : imageList ) { // TODO: imDat should be filled by the first entry of imageList. - // imageList.get(0); - ImageData imDat = new ImageData( UUID.randomUUID().toString(), 113, - "TestImage", System.currentTimeMillis(), System.currentTimeMillis(), "me", "anyThing", - true, false, "best", "theVeryBest", 1024 ); + ImageData imDat = new ImageData( image.guid, image.rid, + image.name, System.currentTimeMillis(), System.currentTimeMillis(), image.creator, "anyThing", + true, false, "best", "theVeryBest", image.fileSize ); FtpCredentials ftpc = ThriftConnection.getFtpCredentials( imDat ); if ( ftpc == null ) { @@ -66,7 +60,7 @@ public class FtpUploadWorker implements Runnable log.error( "FTP problem. Coundn't log in!" ); } // TODO: Where do I find the path to the db-image? <-- in DbImage. It's relative, base path should come from config/???.properties (global static config class, see masterserver's Globals class) - File file = new File( imageList.get( 0 ).path ); + File file = new File( image.path ); FileInputStream fis = new FileInputStream( file ); // TODO: What is the path where it should be stored? <-- Should be set in the FtpCredentials you get via Thrift, but doesn't really matter, Server can decide to ignore the name and pick own (talk to Nils) @@ -77,7 +71,6 @@ public class FtpUploadWorker implements Runnable } } catch ( NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e ) { } - imageList.remove( 0 ); } try { Thread.sleep( 5 * 60 * 1000 ); |