diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigImportPopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigImportPopup.java index 3d19b6d2..185773d8 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigImportPopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigImportPopup.java @@ -155,6 +155,9 @@ public class SEBExamConfigImportPopup { .withHeader( API.IMPORT_PASSWORD_ATTR_NAME, form.getFieldValue(API.IMPORT_PASSWORD_ATTR_NAME)) + .withHeader( + API.IMPORT_FILE_ATTR_NAME, + fileUpload.getFileName()) .withBody(inputStream); if (newConfig) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/UserActivityLogDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/UserActivityLogDAO.java index 6c7c4dc3..3f05d40e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/UserActivityLogDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/UserActivityLogDAO.java @@ -62,9 +62,10 @@ public interface UserActivityLogDAO extends /** Create a user activity log entry for the current user of activity type IMPORT * + * @param uploadFileName The file name of imported file * @param entity the Entity * @return Result of the Entity or referring to an Error if happened */ - Result logImport(E entity); + Result logImport(String uploadFileName, E entity); /** Create a user activity log entry for the current user of activity type EXPORT * diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserActivityLogDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserActivityLogDAOImpl.java index b772188d..f5a02b33 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserActivityLogDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserActivityLogDAOImpl.java @@ -144,8 +144,16 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO { @Override @Transactional - public Result logImport(final E entity) { - return log(UserLogActivityType.IMPORT, entity); + public Result logImport(final String uploadFileName, final E entity) { + if (StringUtils.isBlank(uploadFileName)) { + return log(UserLogActivityType.IMPORT, entity); + } else { + return log( + this.userService.getCurrentUser(), + UserLogActivityType.IMPORT, + entity, + toMessage("Imported from file: " + uploadFileName, entity)); + } } @Override @@ -632,6 +640,10 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO { }); } + private String toMessage(final String addition, final Entity entity) { + return addition + Constants.CARRIAGE_RETURN + toMessage(entity); + } + private String toMessage(final Entity entity) { if (entity == null) { return Constants.EMPTY_NOTE; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java index 1c60003a..d426bda4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationNodeController.java @@ -334,6 +334,12 @@ public class ConfigurationNodeController extends EntityController this.userActivityLogDAO.logImport( + request.getHeader(API.IMPORT_FILE_ATTR_NAME), + node)); + return this.configurationDAO .saveToHistory(config.configurationNodeId) .getOrThrow(); @@ -360,7 +366,11 @@ public class ConfigurationNodeController extends EntityController doImport = doImport(password, request, newConfig); + final Result doImport = doImport(password, request, newConfig) + .onSuccess(node -> this.userActivityLogDAO.logImport( + request.getHeader(API.IMPORT_FILE_ATTR_NAME), + node)); + if (doImport.hasError()) { // rollback of the existing values this.configurationDAO.undo(newConfig.configurationNodeId);