SEBSERV-404

This commit is contained in:
anhefti 2023-03-22 13:27:03 +01:00
parent 45464762bc
commit a838c96c3a
4 changed files with 30 additions and 4 deletions

View file

@ -155,6 +155,9 @@ public class SEBExamConfigImportPopup {
.withHeader( .withHeader(
API.IMPORT_PASSWORD_ATTR_NAME, API.IMPORT_PASSWORD_ATTR_NAME,
form.getFieldValue(API.IMPORT_PASSWORD_ATTR_NAME)) form.getFieldValue(API.IMPORT_PASSWORD_ATTR_NAME))
.withHeader(
API.IMPORT_FILE_ATTR_NAME,
fileUpload.getFileName())
.withBody(inputStream); .withBody(inputStream);
if (newConfig) { if (newConfig) {

View file

@ -62,9 +62,10 @@ public interface UserActivityLogDAO extends
/** Create a user activity log entry for the current user of activity type IMPORT /** 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 * @param entity the Entity
* @return Result of the Entity or referring to an Error if happened */ * @return Result of the Entity or referring to an Error if happened */
<E extends Entity> Result<E> logImport(E entity); <E extends Entity> Result<E> logImport(String uploadFileName, E entity);
/** Create a user activity log entry for the current user of activity type EXPORT /** Create a user activity log entry for the current user of activity type EXPORT
* *

View file

@ -144,8 +144,16 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO {
@Override @Override
@Transactional @Transactional
public <E extends Entity> Result<E> logImport(final E entity) { public <E extends Entity> Result<E> logImport(final String uploadFileName, final E entity) {
if (StringUtils.isBlank(uploadFileName)) {
return log(UserLogActivityType.IMPORT, entity); return log(UserLogActivityType.IMPORT, entity);
} else {
return log(
this.userService.getCurrentUser(),
UserLogActivityType.IMPORT,
entity,
toMessage("Imported from file: " + uploadFileName, entity));
}
} }
@Override @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) { private String toMessage(final Entity entity) {
if (entity == null) { if (entity == null) {
return Constants.EMPTY_NOTE; return Constants.EMPTY_NOTE;

View file

@ -334,6 +334,12 @@ public class ConfigurationNodeController extends EntityController<ConfigurationN
final Configuration config = doImport final Configuration config = doImport
.getOrThrow(); .getOrThrow();
// user log
this.configurationNodeDAO.byPK(config.configurationNodeId)
.onSuccess(node -> this.userActivityLogDAO.logImport(
request.getHeader(API.IMPORT_FILE_ATTR_NAME),
node));
return this.configurationDAO return this.configurationDAO
.saveToHistory(config.configurationNodeId) .saveToHistory(config.configurationNodeId)
.getOrThrow(); .getOrThrow();
@ -360,7 +366,11 @@ public class ConfigurationNodeController extends EntityController<ConfigurationN
.getFollowupConfiguration(modelId) .getFollowupConfiguration(modelId)
.getOrThrow(); .getOrThrow();
final Result<Configuration> doImport = doImport(password, request, newConfig); final Result<Configuration> doImport = doImport(password, request, newConfig)
.onSuccess(node -> this.userActivityLogDAO.logImport(
request.getHeader(API.IMPORT_FILE_ATTR_NAME),
node));
if (doImport.hasError()) { if (doImport.hasError()) {
// rollback of the existing values // rollback of the existing values
this.configurationDAO.undo(newConfig.configurationNodeId); this.configurationDAO.undo(newConfig.configurationNodeId);