From f6e13dd8004d9dbe857ffd22c242dd95523229ce Mon Sep 17 00:00:00 2001 From: Michael Petretti Date: Mon, 26 May 2014 16:23:18 +0200 Subject: Fixed most ToDo's. --- .../openslx/satellitedaemon/ftp/ThriftConnection.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 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 ed19a1a..e9ab3af 100644 --- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java +++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java @@ -10,6 +10,7 @@ import java.security.SignatureException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; +import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; @@ -20,8 +21,10 @@ import org.openslx.imagemaster.thrift.iface.ImageData; import org.openslx.imagemaster.thrift.iface.ImageServer; import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException; import org.openslx.imagemaster.thrift.iface.ServerSessionData; +import org.openslx.satellitedaemon.Globals; +import org.openslx.satellitedaemon.Globals.PropInt; +import org.openslx.satellitedaemon.Globals.PropString; import org.openslx.satellitedaemon.util.EncryptWithServerIdPublicKey; -import org.openslx.satellitedaemon.util.Util; /** * Handles the authentication with the Satellite Server and sends the FtpCredentials, which @@ -31,9 +34,7 @@ public class ThriftConnection { private static ImageServer.Client client = null; private static ServerSessionData sSD = null; - // TODO: All of the Strings and int's should not fall from sky. (Globals config) - static String nilsIp = "132.230.4.23"; - static int thriftPort = 9090; + private static Logger log = Logger.getLogger( ThriftConnection.class ); /** * The method calls getConnection() to check if the connection is ok, @@ -45,7 +46,10 @@ public class ThriftConnection { try { client = getConnection(); - Util.notNullFatal( client, "Client is null. Maybe a Network error." ); // TODO: Don't call fatal, it would exit the program, just log a message and return null + if ( client == null ) { + log.info( "Client was null!" ); + return null; + } return client.submitImage( sSD.sessionId, imDat ); } catch ( TException e ) { @@ -121,8 +125,8 @@ public class ThriftConnection { ImageServer.Client newClient = null; try { - TTransport transport; - transport = new TSocket( nilsIp, thriftPort ); // Nils IP + TTransport transport; // Is it really always the same IP:Port as from FTPServer? + transport = new TSocket( Globals.getPropertyString( PropString.FTPSERVERIP ), Globals.getPropertyInt( PropInt.FTPPORT ) ); transport.open(); TProtocol protocol = new TBinaryProtocol( transport ); newClient = new ImageServer.Client( protocol ); -- cgit v1.2.3-55-g7522