summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationError.java3
-rw-r--r--src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationException.java30
-rw-r--r--src/main/java/org/openslx/satellitedaemon/db/MySQL.java6
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java19
4 files changed, 18 insertions, 40 deletions
diff --git a/src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationError.java b/src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationError.java
index 2fd9fcf..849989d 100644
--- a/src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationError.java
+++ b/src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationError.java
@@ -7,9 +7,6 @@
package org.openslx.imagemaster.thrift.iface;
-import java.util.Map;
-import java.util.HashMap;
-import org.apache.thrift.TEnum;
public enum AuthenticationError implements org.apache.thrift.TEnum {
GENERIC_ERROR(0),
diff --git a/src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationException.java b/src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationException.java
index 5efc66c..24883c9 100644
--- a/src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationException.java
+++ b/src/main/java/org/openslx/imagemaster/thrift/iface/AuthenticationException.java
@@ -6,31 +6,19 @@
*/
package org.openslx.imagemaster.thrift.iface;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
-
import org.apache.thrift.scheme.TupleScheme;
-import org.apache.thrift.protocol.TTupleProtocol;
-import org.apache.thrift.protocol.TProtocolException;
-import org.apache.thrift.EncodingUtils;
-import org.apache.thrift.TException;
-import org.apache.thrift.async.AsyncMethodCallback;
-import org.apache.thrift.server.AbstractNonblockingServer.*;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.EnumMap;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.EnumSet;
-import java.util.Collections;
-import java.util.BitSet;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class AuthenticationException extends TException implements org.apache.thrift.TBase<AuthenticationException, AuthenticationException._Fields>, java.io.Serializable, Cloneable, Comparable<AuthenticationException> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthenticationException");
diff --git a/src/main/java/org/openslx/satellitedaemon/db/MySQL.java b/src/main/java/org/openslx/satellitedaemon/db/MySQL.java
index c5f2fce..599cdb1 100644
--- a/src/main/java/org/openslx/satellitedaemon/db/MySQL.java
+++ b/src/main/java/org/openslx/satellitedaemon/db/MySQL.java
@@ -1,17 +1,17 @@
package org.openslx.satellitedaemon.db;
-import java.io.FileInputStream;
import java.io.BufferedInputStream;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
-import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
-
import org.apache.log4j.Logger;
import org.openslx.satellitedaemon.util.Util;
+import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
+
import fi.evident.dalesbred.Database;
/**
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 );