From 4eadd87af796b9b670fc69cad792579202bc48c5 Mon Sep 17 00:00:00 2001 From: Michael Petretti Date: Thu, 19 Jun 2014 17:26:19 +0200 Subject: More debugging plus FtpDownloadWorker added. --- .../satellitedaemon/ftp/ThriftConnection.java | 62 +++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java') diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java index a2c990f..251e2b3 100644 --- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java +++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java @@ -84,6 +84,54 @@ public class ThriftConnection } return null; } + + /** + * The method calls getConnection() to check if the connection is ok + * and to get the ServerSessionData. If connection is ok, it returns ftpCredential. + * + * @return returns 'null' if there is a problem. + */ + public static FtpCredentials getFtpCredentials( String uUID ) + { + ImageServer.Client theClient = null; + try { + theClient = getConnection(); + if ( theClient == null ) { + log.error( "Client was null!" ); + return null; + } + + return theClient.getImage( uUID, sSD.sessionId ); + } catch ( TException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch ( UnrecoverableKeyException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch ( InvalidKeyException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch ( NoSuchAlgorithmException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch ( CertificateException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch ( FileNotFoundException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch ( KeyStoreException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch ( SignatureException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch ( IOException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } /** * This method checks if there is already a working connection. If not, @@ -170,7 +218,19 @@ public class ThriftConnection public static void finishedUpload(String ftpUser, ImageData imageDescription) { try { - client.finshedUpload( ftpUser, imageDescription ); + client.finishedUpload( ftpUser, imageDescription ); + } catch ( ImageDataException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch ( TException e ) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void finishedDownload(String ftpUser) { + try { + client.finishedDownload( ftpUser ); } catch ( ImageDataException e ) { // TODO Auto-generated catch block e.printStackTrace(); -- cgit v1.2.3-55-g7522