diff options
author | Simon Rettberg | 2015-07-15 18:33:09 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-07-15 18:33:09 +0200 |
commit | f8e26464cf99ff402eda61d006308cd8adbcb0b0 (patch) | |
tree | b84e452af18f629668b918473003356ae04b4c0b /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java | |
parent | [client] always retry thrift call automatically on first failure (diff) | |
download | tutor-module-f8e26464cf99ff402eda61d006308cd8adbcb0b0.tar.gz tutor-module-f8e26464cf99ff402eda61d006308cd8adbcb0b0.tar.xz tutor-module-f8e26464cf99ff402eda61d006308cd8adbcb0b0.zip |
[server] Fix SQL pooling issue, implement upload
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java index c357c292..44746fe2 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java @@ -10,6 +10,7 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import org.apache.log4j.Logger; import org.openslx.bwlp.sat.util.Constants; import org.openslx.bwlp.sat.util.Formatter; import org.openslx.bwlp.thrift.iface.TTransferRejectedException; @@ -21,6 +22,8 @@ import org.openslx.filetransfer.Uploader; public class FileServer implements IncomingEvent { + private static final Logger LOGGER = Logger.getLogger(FileServer.class); + /** * Listener for incoming unencrypted connections */ @@ -69,7 +72,7 @@ public class FileServer implements IncomingEvent { } public String createNewUserUpload(UserInfo owner, long fileSize, List<ByteBuffer> sha1Sums) - throws TTransferRejectedException, FileNotFoundException { + throws TTransferRejectedException { Iterator<ActiveUpload> it = uploads.values().iterator(); int activeUploads = 0; while (it.hasNext()) { @@ -88,8 +91,15 @@ public class FileServer implements IncomingEvent { do { destinationFile = Formatter.getTempImageName(); } while (destinationFile.exists()); + destinationFile.getParentFile().mkdirs(); // TODO: Pass image - ActiveUpload upload = new ActiveUpload(owner, null, destinationFile, fileSize, sha1Sums); + ActiveUpload upload; + try { + upload = new ActiveUpload(owner, null, destinationFile, fileSize, sha1Sums); + } catch (FileNotFoundException e) { + LOGGER.error("Could not open destination file for writing", e); + throw new TTransferRejectedException("Destination file not writable!"); + } String key = UUID.randomUUID().toString(); uploads.put(key, upload); return key; |