summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Kempin <ekempin@google.com>2017-01-27 15:12:00 +0100
committerDavid Pursehouse <dpursehouse@collab.net>2017-03-17 22:12:48 +0900
commitdecdaaad056f7bd0dc502f7a425bc8d81dcef546 (patch)
treec9cda037e40d3e935644765ea089a48167523235
parentaa93fdfe071b0223722dd1e978e1687a064ca950 (diff)
WatchConfig.Accessor: Add method to delete all watches of an account
The new method allows to delete all project watches of an account as an atomic operation. We need this method to finish the migration of the project watches to NoteDb on gerrit-review. Change-Id: I6e4b50dc99913641bc9d39bab60a6bc5b2f2f073 Signed-off-by: Edwin Kempin <ekempin@google.com>
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/account/WatchConfig.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/WatchConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/WatchConfig.java
index a3cd0c92c4..f24ef2eb16 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/account/WatchConfig.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/WatchConfig.java
@@ -148,6 +148,19 @@ public class WatchConfig extends VersionedMetaData
}
}
+ public synchronized void deleteAllProjectWatches(Account.Id accountId)
+ throws IOException, ConfigInvalidException {
+ WatchConfig watchConfig = read(accountId);
+ boolean commit = false;
+ if (!watchConfig.getProjectWatches().isEmpty()) {
+ watchConfig.getProjectWatches().clear();
+ commit = true;
+ }
+ if (commit) {
+ commit(watchConfig);
+ }
+ }
+
private WatchConfig read(Account.Id accountId)
throws IOException, ConfigInvalidException {
try (Repository git = repoManager.openRepository(allUsersName)) {