diff options
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java')
-rw-r--r-- | src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java | 62 |
1 files changed, 61 insertions, 1 deletions
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(); |