From f8e26464cf99ff402eda61d006308cd8adbcb0b0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 15 Jul 2015 18:33:09 +0200 Subject: [server] Fix SQL pooling issue, implement upload --- .../java/org/openslx/bwlp/sat/fileserv/FileServer.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/FileServer.java') 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 sha1Sums) - throws TTransferRejectedException, FileNotFoundException { + throws TTransferRejectedException { Iterator 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; -- cgit v1.2.3-55-g7522