summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-09-29 16:41:30 +0200
committerBjörn Hagemeister2014-09-29 16:41:30 +0200
commit1708868c804bd97db1adc5183fe0f6e5da681e97 (patch)
tree75a97c5345520b5686b39e18415df3cbe7c27b72
parentRemoved unnesseccary code in getUploadInfos(...) (diff)
downloadsatellite-daemon-1708868c804bd97db1adc5183fe0f6e5da681e97.tar.gz
satellite-daemon-1708868c804bd97db1adc5183fe0f6e5da681e97.tar.xz
satellite-daemon-1708868c804bd97db1adc5183fe0f6e5da681e97.zip
Adapted to changes in filetransfer class.
-rw-r--r--src/main/java/org/openslx/satellitedaemon/Globals.java10
-rw-r--r--src/main/java/org/openslx/satellitedaemon/db/MySQL.java2
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java4
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java4
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java29
5 files changed, 26 insertions, 23 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/Globals.java b/src/main/java/org/openslx/satellitedaemon/Globals.java
index 2cf594c..00d1e0a 100644
--- a/src/main/java/org/openslx/satellitedaemon/Globals.java
+++ b/src/main/java/org/openslx/satellitedaemon/Globals.java
@@ -1,9 +1,11 @@
package org.openslx.satellitedaemon;
-import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -83,8 +85,8 @@ public class Globals {
static {
try {
// Load all entries of the config file into properties
- BufferedInputStream stream = new BufferedInputStream(
- new FileInputStream("config/global.properties.example"));
+ InputStreamReader stream = new InputStreamReader(
+ new FileInputStream("config/global.properties"), StandardCharsets.UTF_8);
properties.load(stream);
stream.close();
} catch (IOException e) {
@@ -127,7 +129,7 @@ public class Globals {
log.error("Could not find the keystore for the filetransfer. Path was '" + getFiletransferKeystorePath() + "'");
return false;
} catch (IOException e) {
- log.error("IOException");
+ log.error("IOException", e);
return false;
} catch (KeyManagementException e) {
log.error("KeyManagementException");
diff --git a/src/main/java/org/openslx/satellitedaemon/db/MySQL.java b/src/main/java/org/openslx/satellitedaemon/db/MySQL.java
index b4adaf6..e225d54 100644
--- a/src/main/java/org/openslx/satellitedaemon/db/MySQL.java
+++ b/src/main/java/org/openslx/satellitedaemon/db/MySQL.java
@@ -36,7 +36,7 @@ class MySQL
Properties properties = new Properties();
try {
// using "mysql.properties.example" for testing
- final BufferedInputStream stream = new BufferedInputStream( new FileInputStream( "config/mysql.properties.example" ) );
+ final BufferedInputStream stream = new BufferedInputStream( new FileInputStream( "config/mysql.properties" ) );
properties.load( stream );
stream.close();
} catch ( FileNotFoundException e ) {
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java
index 2e92215..160e2fc 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java
@@ -8,7 +8,7 @@ import org.apache.log4j.Logger;
import org.openslx.filetransfer.Downloader;
import org.openslx.filetransfer.FileRange;
import org.openslx.filetransfer.WantRangeCallback;
-import org.openslx.imagemaster.thrift.iface.DownloadInfos;
+import org.openslx.imagemaster.thrift.iface.DownloadData;
import org.openslx.satellitedaemon.Globals;
import org.openslx.satellitedaemon.db.DbImage;
@@ -26,7 +26,7 @@ public class FileDownloadWorker implements Runnable {
for (long i = 0; i < (image.fileSize / Globals.BLOCKSIZE); i++) {
range.add((int) i);
}
- DownloadInfos downInfos = ThriftConnection.getDownloadInfos(image);
+ DownloadData downInfos = ThriftConnection.getDownloadInfos(image);
if (downInfos == null) {
log.error("The DownloadInfos returned by ThriftConnection class are null");
continue;
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
index aec589a..f8a0578 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
@@ -8,7 +8,7 @@ import java.util.UUID;
import org.apache.log4j.Logger;
import org.openslx.filetransfer.Uploader;
import org.openslx.imagemaster.thrift.iface.ImageData;
-import org.openslx.imagemaster.thrift.iface.UploadInfos;
+import org.openslx.imagemaster.thrift.iface.UploadData;
import org.openslx.satellitedaemon.Globals;
import org.openslx.satellitedaemon.db.DbImage;
@@ -43,7 +43,7 @@ public class FileUploadWorker implements Runnable
String crcPath = image.path.concat( ".crc" );
// ThriftConnection.getUploadInfos returns uploadInfo and handles ThriftAuthentication
- UploadInfos upInfos = ThriftConnection.getUploadInfos( imDat, crcPath );
+ UploadData upInfos = ThriftConnection.getUploadInfos( imDat, crcPath );
if ( upInfos == null ) {
log.error( "The UploadInfos returned by ThriftConnection Class are null" );
continue;
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java
index ab60d2f..da6c6df 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java
@@ -18,10 +18,11 @@ import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
import org.openslx.imagemaster.crcchecker.CrcFile;
import org.openslx.imagemaster.thrift.iface.AuthorizationError;
import org.openslx.imagemaster.thrift.iface.AuthorizationException;
-import org.openslx.imagemaster.thrift.iface.DownloadInfos;
+import org.openslx.imagemaster.thrift.iface.DownloadData;
import org.openslx.imagemaster.thrift.iface.ImageData;
import org.openslx.imagemaster.thrift.iface.ImageDataError;
import org.openslx.imagemaster.thrift.iface.ImageDataException;
@@ -30,7 +31,7 @@ import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException;
import org.openslx.imagemaster.thrift.iface.ServerSessionData;
import org.openslx.imagemaster.thrift.iface.UploadError;
import org.openslx.imagemaster.thrift.iface.UploadException;
-import org.openslx.imagemaster.thrift.iface.UploadInfos;
+import org.openslx.imagemaster.thrift.iface.UploadData;
import org.openslx.satellitedaemon.Globals;
import org.openslx.satellitedaemon.db.DbImage;
import org.openslx.satellitedaemon.db.DbImage.Status;
@@ -60,7 +61,7 @@ public class ThriftConnection {
*
* @return returns 'null' if there is a problem.
*/
- public static UploadInfos getUploadInfos(ImageData imDat, String filename) {
+ public static UploadData getUploadInfos(ImageData imDat, String filename) {
ImageServer.Client theClient = null;
try {
theClient = getConnection();
@@ -94,13 +95,14 @@ public class ThriftConnection {
// TODO: Mark the Image as corrupted.
} else if (e.getNumber().equals(UploadError.INVALID_CRC)) {
// The CRC sum contained errors
- crc = new CrcFile(filename);
try {
- if (!crc.isValid()) {
- // TODO: Mark CRC-file as corrupted.
- }
+ crc = new CrcFile(filename);
} catch (IOException e1) {
- log.error("IOERROR, while reading from CRC File" + filename);
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ if (!crc.isValid()) {
+ // TODO: Mark CRC-file as corrupted.
}
} else {
e.printStackTrace();
@@ -155,7 +157,7 @@ public class ThriftConnection {
*
* @return returns 'null' if there is a problem.
*/
- public static DownloadInfos getDownloadInfos(DbImage imDat) {
+ public static DownloadData getDownloadInfos(DbImage imDat) {
ImageServer.Client theClient = null;
try {
theClient = getConnection();
@@ -173,7 +175,7 @@ public class ThriftConnection {
// The image requested is not known.
// TODO: change field image_syncMode, so the image is not asked
// for again.
- // Now just changed status of image. Currently no possibility
+ // For now just changed status of image. Currently no possibility
// for creating new useful state in DB. (Offenburg)
log.info("Image not known. For skipping next time, mark as only_local.");
imDat.updateStatus(Status.only_local);
@@ -314,10 +316,9 @@ public class ThriftConnection {
TProtocol protocol = new TBinaryProtocol(transport);
newClient = new ImageServer.Client(protocol);
log.debug("ThriftConnection: Made a new Client");
- } catch (TException x) {
- // TODO: Exception handling
- log.error("ThriftConnection coudn't create new client.");
- x.printStackTrace();
+ } catch (TTransportException tte) {
+ log.error("Transport could not be opened. Couldn't create new client.");
+ tte.printStackTrace();
return null;
}
return newClient;