SEBSERV-404
This commit is contained in:
parent
45464762bc
commit
a838c96c3a
4 changed files with 30 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 */
|
||||
<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
|
||||
*
|
||||
|
|
|
@ -144,8 +144,16 @@ public class UserActivityLogDAOImpl implements UserActivityLogDAO {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public <E extends Entity> Result<E> logImport(final E entity) {
|
||||
return log(UserLogActivityType.IMPORT, entity);
|
||||
public <E extends Entity> Result<E> 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;
|
||||
|
|
|
@ -334,6 +334,12 @@ public class ConfigurationNodeController extends EntityController<ConfigurationN
|
|||
final Configuration config = doImport
|
||||
.getOrThrow();
|
||||
|
||||
// user log
|
||||
this.configurationNodeDAO.byPK(config.configurationNodeId)
|
||||
.onSuccess(node -> 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<ConfigurationN
|
|||
.getFollowupConfiguration(modelId)
|
||||
.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()) {
|
||||
// rollback of the existing values
|
||||
this.configurationDAO.undo(newConfig.configurationNodeId);
|
||||
|
|
Loading…
Reference in a new issue