From f918a80aa668899912ca37cf82d3794728b05c14 Mon Sep 17 00:00:00 2001 From: Michael Petretti Date: Tue, 20 May 2014 14:22:43 +0200 Subject: Finished UploadWorker and added some comments. --- .../satellitedaemon/ftp/ThriftConnection.java | 89 +++++++++++++--------- 1 file changed, 51 insertions(+), 38 deletions(-) (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 810a496..054eb62 100644 --- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java +++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java @@ -35,6 +35,57 @@ public class ThriftConnection static String nilsIp = "132.230.4.23"; static int thriftPort = 9090; + /** + * The method calls getConnection() to check if the connection is ok, + * if so, it returns ftpCredential. + * + * @return returns 'null' if there is a problem. + */ + public static FtpCredentials getFtpCredentials( ImageData imDat ) + { + try { + client = getConnection(); + Util.notNullFatal( client, "Client is null. Maybe a Network error." ); + + return client.submitImage( sSD.sessionId, imDat ); + } 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, + * newClient() establishes one. Also it does the Authentication if not done + * yet. + * + * @return returns the client if successful. + */ private static ImageServer.Client getConnection() throws ServerAuthenticationException, TException, UnrecoverableKeyException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, KeyStoreException, IOException, InvalidKeyException, SignatureException @@ -82,42 +133,4 @@ public class ThriftConnection return newClient; } - public static FtpCredentials getFtpCredentials(ImageData imDat) - - { - try { - client = getConnection(); - Util.notNullFatal( client, "Client is null. Maybe a Network error." ); - - return client.submitImage( sSD.sessionId, imDat ); - } 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; - } } -- cgit v1.2.3-55-g7522