summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Petretti2014-06-04 15:01:27 +0200
committerMichael Petretti2014-06-04 15:01:27 +0200
commit79211fe8f5e15d326f50c90067d0bc82f1f75bda (patch)
tree6ec168291e7797323db8948e9ba80e8394fda3f5
parentMore ToDos solved. (diff)
downloadsatellite-daemon-79211fe8f5e15d326f50c90067d0bc82f1f75bda.tar.gz
satellite-daemon-79211fe8f5e15d326f50c90067d0bc82f1f75bda.tar.xz
satellite-daemon-79211fe8f5e15d326f50c90067d0bc82f1f75bda.zip
Added log messages.
-rw-r--r--src/main/java/org/openslx/satellitedaemon/db/DbImage.java4
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java16
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java31
3 files changed, 32 insertions, 19 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
index ffaa4c1..02d396a 100644
--- a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
+++ b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
@@ -36,11 +36,11 @@ public class DbImage
public static List<DbImage> getAllMarkedForUpload()
{
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" +
+ " Concat(user.loginName, '@', institution.name) AS userID, image.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)" +
- " WHERE status_isReady <> 0" );
+ " WHERE image_syncMode = 'to_be_published'" );
}
}
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
index 91571ed..6b213b1 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
@@ -32,7 +32,7 @@ public class FtpUploadWorker implements Runnable
while ( true ) {
List<DbImage> imageList = DbImage.getAllMarkedForUpload();
for ( DbImage image : imageList ) {
- // TODO: imDat should be filled by the first entry of imageList.
+ // TODO: still some fields for ImageData, which i can't fill with info from DbImage.
ImageData imDat = new ImageData( image.guid, image.rid,
image.name, System.currentTimeMillis(), System.currentTimeMillis(), image.creator, "anyThing",
true, false, "best", "theVeryBest", image.fileSize );
@@ -43,7 +43,6 @@ public class FtpUploadWorker implements Runnable
}
try {
- // ToDo: Add everything with the keyStores to config/global.properties
TrustManagerFactory trustManagerFactory = TrustManagerFactory
.getInstance( KeyManagerFactory.getDefaultAlgorithm() );
KeyStore keystore = KeyStore.getInstance( Globals.getPropertyString( PropString.KEYSTORETYPE ) );
@@ -59,23 +58,24 @@ public class FtpUploadWorker implements Runnable
if ( !ftpClient.login( ftpc.username, ftpc.password ) ) {
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( image.path );
FileInputStream fis = new FileInputStream( file );
+ ftpClient.storeFile( image.name, fis );
- // 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 {
+ } catch (IOException e) {
+ log.error("FtpUploadWorker: Error creating the FileInputStream");
+ }
+ finally {
ftpClient.disconnect();
}
} catch ( NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e ) {
+ log.debug( "FtpUploadWorker: Problem with Keystore ore FtpsClient creation." );
}
}
try {
Thread.sleep( 5 * 60 * 1000 );
} catch ( InterruptedException e ) {
- // TODO Auto-generated catch block
+ log.error( "FtpUploadWorker: Sleep interrupted" );
e.printStackTrace();
}
}
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
index e9ab3af..e7fe0b8 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
@@ -47,7 +47,7 @@ public class ThriftConnection
try {
client = getConnection();
if ( client == null ) {
- log.info( "Client was null!" );
+ log.error( "Client was null!" );
return null;
}
@@ -91,7 +91,7 @@ public class ThriftConnection
* @return returns the client if successful.
*/
private static ImageServer.Client getConnection()
- throws ServerAuthenticationException, TException, UnrecoverableKeyException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, KeyStoreException,
+ throws UnrecoverableKeyException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, KeyStoreException,
IOException, InvalidKeyException, SignatureException
{
ImageServer.Client theClient = null;
@@ -110,13 +110,25 @@ public class ThriftConnection
}
}
if ( !isAuthenticated ) {
- String toEncrypt = client.startServerAuthentication( "uni-freiburg.de" );
- // System.out.println( toEncrypt );
- EncryptWithServerIdPublicKey rse = new EncryptWithServerIdPublicKey( "serverid", "password",
- "/home/michael/satellite-daemon/config/serverid.jks" );
- byte[] byteArray = rse.encryptString( toEncrypt );
- sSD = client.serverAuthenticate(
- "uni-freiburg.de", ByteBuffer.wrap( byteArray ) );
+ log.info( "ThriftConnection: Client not yet Authenticated. Trying..." );
+ String toEncrypt;
+ try {
+ toEncrypt = client.startServerAuthentication( "uni-freiburg.de" );
+ // System.out.println( toEncrypt );
+ EncryptWithServerIdPublicKey rse = new EncryptWithServerIdPublicKey( "serverid", "password",
+ "/home/michael/satellite-daemon/config/serverid.jks" );
+ byte[] byteArray = rse.encryptString( toEncrypt );
+ sSD = client.serverAuthenticate(
+ "uni-freiburg.de", ByteBuffer.wrap( byteArray ) );
+ } catch ( ServerAuthenticationException e ) {
+ log.error( "ThriftConnection: Server Authetication was not sucessful." );
+ e.printStackTrace();
+ } catch ( TException e ) {
+ log.error( "ThriftConnection: Server Authetication was not sucessful." );
+ e.printStackTrace();
+ }
+ log.info( "is Authenticated." );
+
}
return theClient;
}
@@ -131,6 +143,7 @@ public class ThriftConnection
TProtocol protocol = new TBinaryProtocol( transport );
newClient = new ImageServer.Client( protocol );
} catch ( TException x ) {
+ log.error( "ThriftConnection coudn't create new client." );
x.printStackTrace();
return null;
}