diff options
author | Steffen Ritter | 2024-07-11 17:21:28 +0200 |
---|---|---|
committer | Steffen Ritter | 2024-07-11 17:21:28 +0200 |
commit | 62330006d2defa61677c82cd4c8f95ebe8e7a7a6 (patch) | |
tree | 9b8e5be461fb2fa64f9cf543f5dcce1907c21b32 /dozentenmodulserver | |
parent | [server] Log readable name on image upload to master (diff) | |
download | tutor-module-62330006d2defa61677c82cd4c8f95ebe8e7a7a6.tar.gz tutor-module-62330006d2defa61677c82cd4c8f95ebe8e7a7a6.tar.xz tutor-module-62330006d2defa61677c82cd4c8f95ebe8e7a7a6.zip |
[server] Also log user on upload/download
Diffstat (limited to 'dozentenmodulserver')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java index 8d17fa15..3d38f99a 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/SyncTransferHandler.java @@ -27,10 +27,12 @@ import org.openslx.bwlp.thrift.iface.ImagePublishData; import org.openslx.bwlp.thrift.iface.ImageSummaryRead; import org.openslx.bwlp.thrift.iface.InvocationError; import org.openslx.bwlp.thrift.iface.TAuthorizationException; +import org.openslx.bwlp.thrift.iface.TInvalidTokenException; import org.openslx.bwlp.thrift.iface.TInvocationException; import org.openslx.bwlp.thrift.iface.TNotFoundException; import org.openslx.bwlp.thrift.iface.TTransferRejectedException; import org.openslx.bwlp.thrift.iface.TransferInformation; +import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.thrifthelper.ThriftManager; import org.openslx.util.CascadedThreadPoolExecutor; import org.openslx.util.PrioThreadFactory; @@ -128,8 +130,19 @@ public class SyncTransferHandler { TAuthorizationException, TTransferRejectedException { TransferInformation transferInfo; OutgoingDataTransfer existing = uploadsByVersionId.get(imgVersion.imageVersionId); + String user = userToken; + try { + UserInfo userInfo = ThriftManager.getMasterClient().getUserFromToken(userToken); + if (userInfo != null) { + user = userInfo.getFirstName() + " " + userInfo.getLastName() + " (" + userInfo.getUserId() + ")"; + } + } catch (TInvalidTokenException e) { + e.printStackTrace(); + } catch (TException e) { + e.printStackTrace(); + } if (existing != null) { - LOGGER.info("Client wants to upload image " + imgVersion.imageVersionId + " of '" + imgBase.imageName + "' to master" + LOGGER.info(user + " wants to upload image " + imgVersion.imageVersionId + " of '" + imgBase.imageName + "' to master" + " which is already in progess via " + existing.getId()); return existing.getId(); } @@ -187,7 +200,7 @@ public class SyncTransferHandler { OutgoingDataTransfer transfer = new OutgoingDataTransfer(transferInfo, absFile, imgVersion.imageVersionId); uploadsByVersionId.put(imgVersion.imageVersionId, transfer); uploadsByTransferId.put(transfer.getId(), transfer); - LOGGER.info("Client wants to upload image " + imgVersion.imageVersionId + " of '" + imgBase.imageName + "' to master" + LOGGER.info(user + " wants to upload image " + imgVersion.imageVersionId + " of '" + imgBase.imageName + "' to master" + ", created transfer " + transfer.getId()); heartBeatTask.fire(); return transfer.getId(); @@ -196,6 +209,17 @@ public class SyncTransferHandler { public synchronized static String requestImageDownload(String userToken, ImagePublishData image) throws TInvocationException, TAuthorizationException, TNotFoundException { TransferInformation transferInfo; + String user = userToken; + try { + UserInfo userInfo = ThriftManager.getMasterClient().getUserFromToken(userToken); + if (userInfo != null) { + user = userInfo.getFirstName() + " " + userInfo.getLastName() + " (" + userInfo.getUserId() + ")"; + } + } catch (TInvalidTokenException e) { + e.printStackTrace(); + } catch (TException e) { + e.printStackTrace(); + } // Already replicating this one? IncomingDataTransfer existing = downloads.get(image.imageVersionId); if (existing != null) @@ -242,6 +266,8 @@ public class SyncTransferHandler { localImageData != null); downloads.put(transfer.getId(), transfer); heartBeatTask.fire(); + LOGGER.info(user + " wants to download image " + image.imageVersionId + " of '" + image.imageName + "' from master" + + ", created transfer " + transfer.getId()); return transfer.getId(); } catch (FileNotFoundException e) { LOGGER.warn("Could not open " + tmpFile.getAbsolutePath()); |