summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
diff options
context:
space:
mode:
authorMichael Petretti2014-05-20 14:22:43 +0200
committerMichael Petretti2014-05-20 14:22:43 +0200
commitf918a80aa668899912ca37cf82d3794728b05c14 (patch)
treede549d721fe51d34a7b05d36dfbf9af978197b16 /src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
parentAdded the new FtpUploadWorker-Class (diff)
downloadsatellite-daemon-f918a80aa668899912ca37cf82d3794728b05c14.tar.gz
satellite-daemon-f918a80aa668899912ca37cf82d3794728b05c14.tar.xz
satellite-daemon-f918a80aa668899912ca37cf82d3794728b05c14.zip
Finished UploadWorker and added some comments.
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java')
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java89
1 files changed, 51 insertions, 38 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
index 810a496..054eb62 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
@@ -35,6 +35,57 @@ public class ThriftConnection
static String nilsIp = "132.230.4.23";
static int thriftPort = 9090;
+ /**
+ * The method calls getConnection() to check if the connection is ok,
+ * if so, it returns ftpCredential.
+ *
+ * @return returns 'null' if there is a problem.
+ */
+ public static FtpCredentials getFtpCredentials( ImageData imDat )
+ {
+ try {
+ client = getConnection();
+ Util.notNullFatal( client, "Client is null. Maybe a Network error." );
+
+ return client.submitImage( sSD.sessionId, imDat );
+ } 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,
+ * newClient() establishes one. Also it does the Authentication if not done
+ * yet.
+ *
+ * @return returns the client if successful.
+ */
private static ImageServer.Client getConnection()
throws ServerAuthenticationException, TException, UnrecoverableKeyException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, KeyStoreException,
IOException, InvalidKeyException, SignatureException
@@ -82,42 +133,4 @@ public class ThriftConnection
return newClient;
}
- public static FtpCredentials getFtpCredentials(ImageData imDat)
-
- {
- try {
- client = getConnection();
- Util.notNullFatal( client, "Client is null. Maybe a Network error." );
-
- return client.submitImage( sSD.sessionId, imDat );
- } 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;
- }
}