diff options
author | Michael Petretti | 2014-07-02 16:33:29 +0200 |
---|---|---|
committer | Michael Petretti | 2014-07-02 16:33:29 +0200 |
commit | d7110f16fa4e7253dfea581d61fc37081f6be6ba (patch) | |
tree | 45e896a2776697a1a0308b6987a1e0463b00794f /src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java | |
parent | dependencies from master-sync-shared (diff) | |
download | satellite-daemon-d7110f16fa4e7253dfea581d61fc37081f6be6ba.tar.gz satellite-daemon-d7110f16fa4e7253dfea581d61fc37081f6be6ba.tar.xz satellite-daemon-d7110f16fa4e7253dfea581d61fc37081f6be6ba.zip |
Adappted to the new Filetransfer class. Ready for testing.
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java')
-rw-r--r-- | src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java | 131 |
1 files changed, 55 insertions, 76 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java index 251e2b3..2fbc471 100644 --- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java +++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java @@ -16,15 +16,16 @@ import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; -import org.openslx.imagemaster.thrift.iface.FtpCredentials; +import org.openslx.imagemaster.thrift.iface.DownloadInfos; import org.openslx.imagemaster.thrift.iface.ImageData; -import org.openslx.imagemaster.thrift.iface.ImageDataException; import org.openslx.imagemaster.thrift.iface.ImageServer; import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException; import org.openslx.imagemaster.thrift.iface.ServerSessionData; +import org.openslx.imagemaster.thrift.iface.UploadInfos; import org.openslx.satellitedaemon.Globals; import org.openslx.satellitedaemon.Globals.PropInt; import org.openslx.satellitedaemon.Globals.PropString; +import org.openslx.satellitedaemon.db.DbImage; import org.openslx.satellitedaemon.util.EncryptWithServerIdPublicKey; /** @@ -37,13 +38,14 @@ public class ThriftConnection private static ServerSessionData sSD = null; private static Logger log = Logger.getLogger( ThriftConnection.class ); + /** * 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( ImageData imDat ) + public static UploadInfos getUploadInfos( ImageData imDat ) { ImageServer.Client theClient = null; try { @@ -85,53 +87,55 @@ 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(); + /** + * The method calls getConnection() to check if the connection is ok + * and to get the DownloadeInfos. If connection is ok, it returns ftpCredential. + * + * @return returns 'null' if there is a problem. + */ + public static DownloadInfos getDownloadInfos( DbImage imDat ) + { + ImageServer.Client theClient = null; + try { + theClient = getConnection(); + if ( theClient == null ) { + log.error( "Client was null!" ); + return null; } - return null; + + return theClient.getImage( imDat.guid, 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, @@ -141,8 +145,8 @@ public class ThriftConnection * @return returns the client if successful. */ private static ImageServer.Client getConnection() - throws UnrecoverableKeyException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, KeyStoreException, - IOException, InvalidKeyException, SignatureException + throws UnrecoverableKeyException, NoSuchAlgorithmException, CertificateException, + FileNotFoundException, KeyStoreException, IOException, InvalidKeyException, SignatureException { ImageServer.Client theClient = null; boolean isAuthenticated = false; @@ -202,7 +206,7 @@ public class ThriftConnection { ImageServer.Client newClient = null; try { - TTransport transport; // Is it really always the same IP:Port as from FTPServer? + TTransport transport; transport = new TSocket( Globals.getPropertyString( PropString.FTPSERVERIP ), Globals.getPropertyInt( PropInt.THRIFTPORT ) ); transport.open(); TProtocol protocol = new TBinaryProtocol( transport ); @@ -215,29 +219,4 @@ public class ThriftConnection } return newClient; } - - public static void finishedUpload(String ftpUser, ImageData imageDescription) { - try { - 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(); - } catch ( TException e ) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } |