From c290d541c1e13af56b4b95155ff545d6faa76f92 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 22 May 2014 13:45:35 +0200 Subject: Added some notes --- src/main/java/org/openslx/satellitedaemon/db/DbImage.java | 10 +++++++--- .../java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java | 10 ++++++---- .../java/org/openslx/satellitedaemon/ftp/ThriftConnection.java | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java index 9298a54..ffaa4c1 100644 --- a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java +++ b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java @@ -10,16 +10,20 @@ public class DbImage { public final String guid; + public final String name; public final int rid; public final String path; public final String creator; + public final long fileSize; - public DbImage(String guid, int rid, String path, String creator) + public DbImage(String guid, String name, int rid, String path, String creator, long fileSize) { this.guid = guid; + this.name = name; this.rid = rid; this.path = path; this.creator = creator; + this.fileSize = fileSize; } /** @@ -31,8 +35,8 @@ public class DbImage */ public static List getAllMarkedForUpload() { - return MySQL.findAll( DbImage.class, "SELECT image.GUID_imageID, image.imageVersion, image.image_path," + - " Concat(user.loginName, '@', institution.name, '.de') AS userID" + // HACK: .de required for now + return MySQL.findAll( DbImage.class, "SELECT image.GUID_imageID, image.image_name, image.imageVersion, image.image_path," + + " Concat(user.loginName, '@', institution.name) AS userID, image.filesize" + " FROM m_VLData_imageInfo image" + " INNER JOIN m_user user ON (image.image_owner = user.userID)" + " INNER JOIN m_institution institution ON (institution.institutionID = user.institution)" + diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java index d019e53..e4e4b7c 100644 --- a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java +++ b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java @@ -32,6 +32,7 @@ public class FtpUploadWorker implements Runnable List imageList = new ArrayList(); while ( true ) { imageList = DbImage.getAllMarkedForUpload(); + // TODO: Maybe use iterator ( for (DbImage image : imageList) ) while ( !imageList.isEmpty() ) { // TODO: imDat should be filled by the first entry of imageList. // imageList.get(0); @@ -40,6 +41,7 @@ public class FtpUploadWorker implements Runnable true, false, "best", "theVeryBest", 1024 ); FtpCredentials ftpc = ThriftConnection.getFtpCredentials( imDat ); + // TODO: Handle ftpc == null try { TrustManagerFactory trustManagerFactory = TrustManagerFactory @@ -47,7 +49,7 @@ public class FtpUploadWorker implements Runnable KeyStore keystore = KeyStore.getInstance( "JKS" ); keystore.load( new FileInputStream( new File( "/home/michael/satellite-daemon/config/ftpsid.jks" ) ), - "password".toCharArray() ); + "password".toCharArray() ); // TODO: define relative path, eg. "config/masterserver_cert.jks" trustManagerFactory.init( keystore ); TrustManager trustManager = trustManagerFactory.getTrustManagers()[0]; FTPSClient ftpClient = new FTPSClient( "SSL", true ); @@ -55,16 +57,16 @@ public class FtpUploadWorker implements Runnable try { ftpClient.connect( nilsIp, ftpPort ); if ( !ftpClient.login( ftpc.username, ftpc.password ) ) { - throw new ConnectException( "Could not login." ); + throw new ConnectException( "Could not login." ); // TODO: Should not throw exception, otherwise we'd exit the run() method } // System.out.println( "Connected to " + nilsIp + ":" + ftpPort // + ". Reply code: " + ftpClient.getReplyCode() ); - // TODO: Where do I find the path to the db-image? + // 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( "/path/to/File" ); FileInputStream fis = new FileInputStream( file ); - // TODO: What is the path where it should be stored? + // 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) ftpClient.storeFile( "/path/where/theImage/belongs", fis ); } finally { diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java index 054eb62..ed19a1a 100644 --- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java +++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java @@ -31,7 +31,7 @@ public class ThriftConnection { private static ImageServer.Client client = null; private static ServerSessionData sSD = null; - // TODO: All of the Strings and int's should not fall from sky. + // TODO: All of the Strings and int's should not fall from sky. (Globals config) static String nilsIp = "132.230.4.23"; static int thriftPort = 9090; @@ -45,7 +45,7 @@ public class ThriftConnection { try { client = getConnection(); - Util.notNullFatal( client, "Client is null. Maybe a Network error." ); + Util.notNullFatal( client, "Client is null. Maybe a Network error." ); // TODO: Don't call fatal, it would exit the program, just log a message and return null return client.submitImage( sSD.sessionId, imDat ); } catch ( TException e ) { -- cgit v1.2.3-55-g7522