summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
diff options
context:
space:
mode:
authorMichael Petretti2014-07-07 17:11:19 +0200
committerMichael Petretti2014-07-07 17:11:19 +0200
commit31c54276a7d4f979010a0bdc3bbcf9de8b5b9ecc (patch)
tree7c6bc3b668d515ae5249667416079a00465dd9bb /src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
parentAdappted to the new Filetransfer class. Ready for testing. (diff)
downloadsatellite-daemon-31c54276a7d4f979010a0bdc3bbcf9de8b5b9ecc.tar.gz
satellite-daemon-31c54276a7d4f979010a0bdc3bbcf9de8b5b9ecc.tar.xz
satellite-daemon-31c54276a7d4f979010a0bdc3bbcf9de8b5b9ecc.zip
In the middle of Debuging and Testing.
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java')
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java69
1 files changed, 65 insertions, 4 deletions
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<Integer>.
*
* @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<Integer> 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<Integer> 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();