forked from gchq/stroom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gchqgh-3358 Fix audit events for user prefs screen
- Loading branch information
Showing
36 changed files
with
655 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...nfig-global-impl/src/main/java/stroom/config/global/impl/UserPreferencesResourceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package stroom.config.global.impl; | ||
|
||
import stroom.config.global.shared.UserPreferencesResource; | ||
import stroom.event.logging.api.StroomEventLoggingService; | ||
import stroom.event.logging.api.StroomEventLoggingUtil; | ||
import stroom.event.logging.rs.api.AutoLogged; | ||
import stroom.event.logging.rs.api.AutoLogged.OperationType; | ||
import stroom.ui.config.shared.UserPreferences; | ||
|
||
import event.logging.ComplexLoggedOutcome; | ||
import event.logging.UpdateEventAction; | ||
|
||
import java.util.Objects; | ||
import javax.inject.Inject; | ||
import javax.inject.Provider; | ||
|
||
@AutoLogged | ||
public class UserPreferencesResourceImpl implements UserPreferencesResource { | ||
|
||
private final Provider<UserPreferencesService> preferencesServiceProvider; | ||
private final Provider<StroomEventLoggingService> stroomEventLoggingServiceProvider; | ||
|
||
@Inject | ||
UserPreferencesResourceImpl(final Provider<UserPreferencesService> preferencesServiceProvider, | ||
final Provider<StroomEventLoggingService> stroomEventLoggingServiceProvider) { | ||
|
||
this.preferencesServiceProvider = Objects.requireNonNull(preferencesServiceProvider); | ||
this.stroomEventLoggingServiceProvider = stroomEventLoggingServiceProvider; | ||
} | ||
|
||
@Override | ||
public UserPreferences fetch() { | ||
return preferencesServiceProvider.get().fetch(); | ||
} | ||
|
||
@AutoLogged(OperationType.MANUALLY_LOGGED) | ||
@Override | ||
public boolean update(final UserPreferences userPreferences) { | ||
final UserPreferencesService userPreferencesService = preferencesServiceProvider.get(); | ||
final UserPreferences beforePreferences = userPreferencesService.fetch(); | ||
|
||
final StroomEventLoggingService stroomEventLoggingService = stroomEventLoggingServiceProvider.get(); | ||
final boolean result = stroomEventLoggingService.loggedWorkBuilder() | ||
.withTypeId(StroomEventLoggingUtil.buildTypeId(this, "update")) | ||
.withDescription("Updating own user preferences") | ||
.withDefaultEventAction(UpdateEventAction.builder() | ||
.withBefore(stroomEventLoggingService.convertToMulti(beforePreferences)) | ||
.withAfter(stroomEventLoggingService.convertToMulti(userPreferences)) | ||
.build()) | ||
.withComplexLoggedResult(updateEventAction -> { | ||
final boolean didUpdate = userPreferencesService.update(userPreferences) > 0; | ||
|
||
if (didUpdate) { | ||
return ComplexLoggedOutcome.success(didUpdate, updateEventAction); | ||
} else { | ||
return ComplexLoggedOutcome.failure( | ||
didUpdate, updateEventAction, "No rows updated"); | ||
} | ||
}) | ||
.getResultAndLog(); | ||
|
||
return result; | ||
} | ||
|
||
@Override | ||
public UserPreferences setDefaultUserPreferences(final UserPreferences userPreferences) { | ||
return preferencesServiceProvider.get().setDefaultUserPreferences(userPreferences); | ||
} | ||
|
||
@AutoLogged(OperationType.UPDATE) | ||
@Override | ||
public UserPreferences resetToDefaultUserPreferences() { | ||
preferencesServiceProvider.get().delete(); | ||
return preferencesServiceProvider.get().fetch(); | ||
} | ||
} |
43 changes: 0 additions & 43 deletions
43
...-global-impl/src/main/java/stroom/config/global/impl/UserUserPreferencesResourceImpl.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.