From 31c54276a7d4f979010a0bdc3bbcf9de8b5b9ecc Mon Sep 17 00:00:00 2001 From: Michael Petretti Date: Mon, 7 Jul 2014 17:11:19 +0200 Subject: In the middle of Debuging and Testing. --- .../satellitedaemon/ftp/ThriftConnection.java | 69 ++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 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 2fbc471..5b4dbcd 100644 --- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java +++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java @@ -16,6 +16,7 @@ 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.crcchecker.CRCFile; import org.openslx.imagemaster.thrift.iface.DownloadInfos; import org.openslx.imagemaster.thrift.iface.ImageData; import org.openslx.imagemaster.thrift.iface.ImageServer; @@ -37,14 +38,73 @@ public class ThriftConnection private static ImageServer.Client client = null; private static ServerSessionData sSD = null; private static Logger log = Logger.getLogger( ThriftConnection.class ); + private static CRCFile crc = null; - /** + * Method for getting UploadeInfos + * + * !! on the first Call !! + * + * when the CRCsum need to be transfered. * The method calls getConnection() to check if the connection is ok - * and to get the ServerSessionData. If connection is ok, it returns ftpCredential. + * and to get the ServerSessionData. If connection is ok, it calls + * submitImage with CRCsum in List. * * @return returns 'null' if there is a problem. */ + public static UploadInfos getUploadInfos( ImageData imDat, String filename ) + { + ImageServer.Client theClient = null; + try { + theClient = getConnection(); + if ( theClient == null ) { + log.error( "Client was null!" ); + return null; + } + // .submitImage needs the List from CRCFile.getCRCs() only + // on the first time called. null afterwards. + log.info( "First call of submitImage following..." ); + crc = new CRCFile(filename); + log.info( "Made CRCFile from " + filename ); + return theClient.submitImage( sSD.sessionId, imDat, crc.getCrcSums() ); + } 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; + } + + /** + * Method for getting UploadeInfos when CRCsum was already transfered on first call. + * The method calls getConnection() to check if the connection is ok + * and to get the ServerSessionData. If connection is ok, it calls + * submitImage with sSD.sessionId, imDat and !!null!! + * @return returns 'null' if there is a problem. + */ public static UploadInfos getUploadInfos( ImageData imDat ) { ImageServer.Client theClient = null; @@ -54,8 +114,9 @@ public class ThriftConnection log.error( "Client was null!" ); return null; } - - return theClient.submitImage( sSD.sessionId, imDat ); + // .submitImage needs the List from CRCFile.getCRCs() only + // on the first time called. null afterwards. + return theClient.submitImage( sSD.sessionId, imDat, crc.getCrcSums()); } catch ( TException e ) { // TODO Auto-generated catch block e.printStackTrace(); -- cgit v1.2.3-55-g7522