summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Petretti2014-06-19 15:11:07 +0200
committerMichael Petretti2014-06-19 15:11:07 +0200
commit5a017c3b1ce7c65728ac354ebc138838e9db3320 (patch)
tree3ee98690b3e029cc8e76a335b5c30e0d96c533ae
parentsmall changes (diff)
downloadsatellite-daemon-5a017c3b1ce7c65728ac354ebc138838e9db3320.tar.gz
satellite-daemon-5a017c3b1ce7c65728ac354ebc138838e9db3320.tar.xz
satellite-daemon-5a017c3b1ce7c65728ac354ebc138838e9db3320.zip
Finished Debug for Uploads.
-rw-r--r--src/main/java/org/openslx/satellitedaemon/Globals.java12
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java4
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java17
3 files changed, 27 insertions, 6 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/Globals.java b/src/main/java/org/openslx/satellitedaemon/Globals.java
index f120abc..3bfd5cb 100644
--- a/src/main/java/org/openslx/satellitedaemon/Globals.java
+++ b/src/main/java/org/openslx/satellitedaemon/Globals.java
@@ -20,12 +20,12 @@ public class Globals
*/
public static enum PropInt
{
- FTPPORT // More int's? Add them separated with ","
+ FTPPORT, THRIFTPORT // More int's? Add them separated with ","
}
public static enum PropString
{ // More strings's? Add them separated with ","
- FTPSERVERIP, KEYSTORETYPE, FTPSKEYSTOREPATH, FTPSKEYSTOREPWD, THRIFTORGANIZATIONNAME,
+ FTPSERVERIP, KEYSTORETYPE, FTPSKEYSTOREPATH, FTPSKEYSTOREPWD, THRIFTORGANIZATIONNAME,
RNDSTRINGENCRYPTALIAS, RNDSTRINGENCRYPTPASSWORD, RNDSTRINGENCRYPTPATH
}
@@ -51,6 +51,9 @@ public class Globals
case FTPPORT:
result = properties.getProperty( "ftp_port" );
break;
+ case THRIFTPORT:
+ result = properties.getProperty( "ThriftPort" );
+ break;
default:
result = "0";
break;
@@ -100,6 +103,7 @@ public class Globals
public static boolean propertiesValid()
{
if ( Globals.getPropertyInt( PropInt.FTPPORT ) == 0
+ || Globals.getPropertyInt( PropInt.THRIFTPORT ) == 0
|| Globals.getPropertyString( PropString.FTPSERVERIP ).isEmpty()
|| Globals.getPropertyString( PropString.FTPSERVERIP ) == null
|| Globals.getPropertyString( PropString.KEYSTORETYPE ).isEmpty()
@@ -107,7 +111,7 @@ public class Globals
|| Globals.getPropertyString( PropString.FTPSKEYSTOREPATH ).isEmpty()
|| Globals.getPropertyString( PropString.FTPSKEYSTOREPATH ) == null
|| Globals.getPropertyString( PropString.FTPSKEYSTOREPWD ).isEmpty()
- || Globals.getPropertyString( PropString.FTPSKEYSTOREPWD ) == null
+ || Globals.getPropertyString( PropString.FTPSKEYSTOREPWD ) == null
|| Globals.getPropertyString( PropString.THRIFTORGANIZATIONNAME ).isEmpty()
|| Globals.getPropertyString( PropString.THRIFTORGANIZATIONNAME ) == null
|| Globals.getPropertyString( PropString.RNDSTRINGENCRYPTALIAS ).isEmpty()
@@ -115,7 +119,7 @@ public class Globals
|| Globals.getPropertyString( PropString.RNDSTRINGENCRYPTPASSWORD ).isEmpty()
|| Globals.getPropertyString( PropString.RNDSTRINGENCRYPTPASSWORD ) == null
|| Globals.getPropertyString( PropString.RNDSTRINGENCRYPTPATH ).isEmpty()
- || Globals.getPropertyString( PropString.RNDSTRINGENCRYPTPATH ) == null) {
+ || Globals.getPropertyString( PropString.RNDSTRINGENCRYPTPATH ) == null ) {
return false;
}
else {
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
index 8174787..80e4d1a 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
@@ -13,6 +13,7 @@ import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
+import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPSClient;
import org.apache.log4j.Logger;
import org.openslx.imagemaster.thrift.iface.FtpCredentials;
@@ -61,13 +62,16 @@ public class FtpUploadWorker implements Runnable
}
File file = new File( image.path );
FileInputStream fis = new FileInputStream( file );
+ ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
ftpClient.storeFile( image.name, fis );
+ ThriftConnection.finishedUpload( ftpc.username, imDat );
} catch (IOException e) {
log.error("FtpUploadWorker: Error creating the FileInputStream");
}
finally {
ftpClient.disconnect();
+ log.info( "FtpUploadWorker: ftpClient disconnected" );
}
} catch ( NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e ) {
log.debug( "FtpUploadWorker: Problem with Keystore ore FtpsClient creation." );
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
index 0b22389..a2c990f 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
@@ -18,6 +18,7 @@ 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.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;
@@ -138,7 +139,7 @@ public class ThriftConnection
e.printStackTrace();
return null;
} catch ( TException e ) {
- log.error( "ThriftConnection: TExeption: Server Authetication was not sucessful." );
+ log.error( "ThriftConnection: TException: Server Authetication was not sucessful." );
e.printStackTrace();
return null;
}
@@ -154,7 +155,7 @@ public class ThriftConnection
ImageServer.Client newClient = null;
try {
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 = new TSocket( Globals.getPropertyString( PropString.FTPSERVERIP ), Globals.getPropertyInt( PropInt.THRIFTPORT ) );
transport.open();
TProtocol protocol = new TBinaryProtocol( transport );
newClient = new ImageServer.Client( protocol );
@@ -166,5 +167,17 @@ public class ThriftConnection
}
return newClient;
}
+
+ public static void finishedUpload(String ftpUser, ImageData imageDescription) {
+ try {
+ client.finshedUpload( ftpUser, imageDescription );
+ } catch ( ImageDataException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch ( TException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}