Rename PreferencesConfig/WatchConfig to Preferences/ProjectWatches

We use the naming pattern *Config mostly for subclasses of
VersionedMetaData. Since PreferencesConfig/WatchConfig are no subclasses
of VersionedMetaData the "Config" suffix may be confusing, especially in
contrast to AccountConfig which *is* a subclass of VersionedMetaData.

Change-Id: Ib24ef1358ec3cae31d817caf6e2af8c8da2623f8
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-01-17 16:37:48 +01:00
parent 1915fce081
commit 4c7c61defd
37 changed files with 107 additions and 105 deletions

View File

@@ -35,7 +35,7 @@ import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy;
import com.google.gerrit.extensions.client.InheritableBoolean;
import com.google.gerrit.extensions.client.ReviewerState;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.mail.Address;
import com.google.gerrit.server.mail.send.EmailHeader;
import com.google.gerrit.server.mail.send.EmailHeader.AddressList;

View File

@@ -27,8 +27,8 @@ import com.google.gerrit.extensions.client.EditPreferencesInfo;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import com.google.gerrit.server.account.externalids.ExternalIds;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ValidationError;
@@ -88,12 +88,12 @@ import org.eclipse.jgit.revwalk.RevSort;
* doesn't exist).
*
* <p>The preferences are stored in a 'preferences.config' config file. Parsing and updating it is
* implemented by {@link PreferencesConfig} and this class delegates the handling of preferences to
* {@link PreferencesConfig}.
* implemented by {@link Preferences} and this class delegates the handling of preferences to {@link
* Preferences}.
*
* <p>The project watches are stored in a 'watch.config' config file. Parsing and updating it is
* implemented by {@link WatchConfig} and this class delegates the handling of project watches to
* {@link WatchConfig}.
* implemented by {@link ProjectWatches} and this class delegates the handling of project watches to
* {@link ProjectWatches}.
*
* <p>By default preferences and project watches are lazily parsed on need. Eager parsing can be
* requested by {@link #setEagerParsing(boolean)}.
@@ -112,8 +112,8 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
private Optional<Account> loadedAccount;
private Optional<ObjectId> externalIdsRev;
private WatchConfig watchConfig;
private PreferencesConfig prefConfig;
private ProjectWatches projectWatches;
private Preferences preferences;
private Optional<InternalAccountUpdate> accountUpdate = Optional.empty();
private Timestamp registeredOn;
private boolean eagerParsing;
@@ -183,7 +183,7 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
*/
public ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> getProjectWatches() {
checkLoaded();
return watchConfig.getProjectWatches();
return projectWatches.getProjectWatches();
}
/**
@@ -193,7 +193,7 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
*/
public GeneralPreferencesInfo getGeneralPreferences() {
checkLoaded();
return prefConfig.getGeneralPreferences();
return preferences.getGeneralPreferences();
}
/**
@@ -203,7 +203,7 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
*/
public DiffPreferencesInfo getDiffPreferences() {
checkLoaded();
return prefConfig.getDiffPreferences();
return preferences.getDiffPreferences();
}
/**
@@ -213,7 +213,7 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
*/
public EditPreferencesInfo getEditPreferences() {
checkLoaded();
return prefConfig.getEditPreferences();
return preferences.getEditPreferences();
}
/**
@@ -281,27 +281,26 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
Config accountConfig = readConfig(ACCOUNT_CONFIG);
loadedAccount = Optional.of(parse(accountConfig, revision.name()));
watchConfig = new WatchConfig(accountId, readConfig(WatchConfig.WATCH_CONFIG), this);
projectWatches = new ProjectWatches(accountId, readConfig(ProjectWatches.WATCH_CONFIG), this);
prefConfig =
new PreferencesConfig(
preferences =
new Preferences(
accountId,
readConfig(PreferencesConfig.PREFERENCES_CONFIG),
PreferencesConfig.readDefaultConfig(repo),
readConfig(Preferences.PREFERENCES_CONFIG),
Preferences.readDefaultConfig(repo),
this);
if (eagerParsing) {
watchConfig.parse();
prefConfig.parse();
projectWatches.parse();
preferences.parse();
}
} else {
loadedAccount = Optional.empty();
watchConfig = new WatchConfig(accountId, new Config(), this);
projectWatches = new ProjectWatches(accountId, new Config(), this);
prefConfig =
new PreferencesConfig(
accountId, new Config(), PreferencesConfig.readDefaultConfig(repo), this);
preferences =
new Preferences(accountId, new Config(), Preferences.readDefaultConfig(repo), this);
}
Ref externalIdsRef = repo.exactRef(RefNames.REFS_EXTERNAL_IDS);
@@ -383,14 +382,14 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
if (accountUpdate.isPresent()
&& (!accountUpdate.get().getDeletedProjectWatches().isEmpty()
|| !accountUpdate.get().getUpdatedProjectWatches().isEmpty())) {
Map<ProjectWatchKey, Set<NotifyType>> projectWatches =
new HashMap<>(watchConfig.getProjectWatches());
accountUpdate.get().getDeletedProjectWatches().forEach(pw -> projectWatches.remove(pw));
Map<ProjectWatchKey, Set<NotifyType>> newProjectWatches =
new HashMap<>(projectWatches.getProjectWatches());
accountUpdate.get().getDeletedProjectWatches().forEach(pw -> newProjectWatches.remove(pw));
accountUpdate
.get()
.getUpdatedProjectWatches()
.forEach((pw, nt) -> projectWatches.put(pw, nt));
saveConfig(WatchConfig.WATCH_CONFIG, watchConfig.save(projectWatches));
.forEach((pw, nt) -> newProjectWatches.put(pw, nt));
saveConfig(ProjectWatches.WATCH_CONFIG, projectWatches.save(newProjectWatches));
}
}
@@ -403,8 +402,8 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
}
saveConfig(
PreferencesConfig.PREFERENCES_CONFIG,
prefConfig.saveGeneralPreferences(
Preferences.PREFERENCES_CONFIG,
preferences.saveGeneralPreferences(
accountUpdate.get().getGeneralPreferences(),
accountUpdate.get().getDiffPreferences(),
accountUpdate.get().getEditPreferences()));

View File

@@ -31,8 +31,8 @@ import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.CurrentUser.PropertyKey;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIdNotes;
import com.google.gerrit.server.account.externalids.ExternalIds;

View File

@@ -83,8 +83,8 @@ import org.eclipse.jgit.lib.Repository;
* The timestamp of the first commit on a user branch denotes the registration date. The initial
* commit on the user branch may be empty (since having an 'account.config' is optional). See {@link
* AccountConfig} for details of the 'account.config' file format. In addition the user branch can
* contain a 'preferences.config' config file to store preferences (see {@link PreferencesConfig})
* and a 'watch.config' config file to store project watches (see {@link WatchConfig}). External IDs
* contain a 'preferences.config' config file to store preferences (see {@link Preferences}) and a
* 'watch.config' config file to store project watches (see {@link ProjectWatches}). External IDs
* are stored separately in the {@code refs/meta/external-ids} notes branch (see {@link
* ExternalIdNotes}).
*

View File

@@ -22,8 +22,8 @@ import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.client.EditPreferencesInfo;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import com.google.gerrit.server.account.externalids.DuplicateExternalIdKeyException;
import com.google.gerrit.server.account.externalids.ExternalId;
import java.util.Collection;

View File

@@ -85,8 +85,8 @@ import org.slf4j.LoggerFactory;
*
* <p>The preferences are lazily parsed.
*/
public class PreferencesConfig {
private static final Logger log = LoggerFactory.getLogger(PreferencesConfig.class);
public class Preferences {
private static final Logger log = LoggerFactory.getLogger(Preferences.class);
public static final String PREFERENCES_CONFIG = "preferences.config";
@@ -99,7 +99,7 @@ public class PreferencesConfig {
private DiffPreferencesInfo diffPreferences;
private EditPreferencesInfo editPreferences;
public PreferencesConfig(
public Preferences(
Account.Id accountId,
Config cfg,
Config defaultCfg,

View File

@@ -76,11 +76,11 @@ import org.eclipse.jgit.lib.Config;
*
* <p>The project watches are lazily parsed.
*/
public class WatchConfig {
public class ProjectWatches {
@AutoValue
public abstract static class ProjectWatchKey {
public static ProjectWatchKey create(Project.NameKey project, @Nullable String filter) {
return new AutoValue_WatchConfig_ProjectWatchKey(project, Strings.emptyToNull(filter));
return new AutoValue_ProjectWatches_ProjectWatchKey(project, Strings.emptyToNull(filter));
}
public abstract Project.NameKey project();
@@ -111,7 +111,8 @@ public class WatchConfig {
private ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches;
public WatchConfig(Account.Id accountId, Config cfg, ValidationError.Sink validationErrorSink) {
public ProjectWatches(
Account.Id accountId, Config cfg, ValidationError.Sink validationErrorSink) {
this.accountId = checkNotNull(accountId, "accountId");
this.cfg = checkNotNull(cfg, "cfg");
this.validationErrorSink = checkNotNull(validationErrorSink, "validationErrorSink");
@@ -256,7 +257,7 @@ public class WatchConfig {
}
public static NotifyValue create(@Nullable String filter, Collection<NotifyType> notifyTypes) {
return new AutoValue_WatchConfig_NotifyValue(
return new AutoValue_ProjectWatches_NotifyValue(
Strings.emptyToNull(filter), Sets.immutableEnumSet(notifyTypes));
}

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.server.git;
import com.google.common.base.Strings;
import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.mail.Address;
import java.util.EnumSet;
import java.util.HashSet;

View File

@@ -47,7 +47,7 @@ import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.config.ConfigUtil;
import com.google.gerrit.server.config.PluginConfig;
import com.google.gerrit.server.mail.Address;

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.server.mail.send;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;

View File

@@ -30,7 +30,7 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.StarredChangesUtil;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.mail.send.ProjectWatch.Watchers;
import com.google.gerrit.server.notedb.ReviewerStateInternal;
import com.google.gerrit.server.patch.PatchList;

View File

@@ -28,7 +28,7 @@ import com.google.gerrit.reviewdb.client.Patch;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RobotComment;
import com.google.gerrit.server.CommentsUtil;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.mail.MailUtil;
import com.google.gerrit.server.mail.receive.Protocol;

View File

@@ -20,7 +20,7 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.mail.send.ProjectWatch.Watchers;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.RefPermission;

View File

@@ -19,7 +19,7 @@ import com.google.gerrit.extensions.api.changes.RecipientType;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.mail.Address;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.server.mail.send;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;

View File

@@ -24,7 +24,7 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;

View File

@@ -19,7 +19,7 @@ import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.RecipientType;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.mail.Address;
import com.google.gerrit.server.mail.send.ProjectWatch.Watchers;
import com.google.gwtorm.server.OrmException;

View File

@@ -26,8 +26,8 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import com.google.gerrit.server.git.NotifyConfig;
import com.google.gerrit.server.mail.Address;
import com.google.gerrit.server.project.ProjectState;

View File

@@ -20,7 +20,7 @@ import com.google.gerrit.extensions.api.changes.RecipientType;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.server.mail.send;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.server.mail.send;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;

View File

@@ -20,7 +20,7 @@ import com.google.gerrit.index.query.Predicate;
import com.google.gerrit.index.query.QueryBuilder;
import com.google.gerrit.index.query.QueryParseException;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

View File

@@ -26,7 +26,7 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;

View File

@@ -26,8 +26,8 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.Accounts;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;

View File

@@ -21,9 +21,9 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.account.WatchConfig;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -124,6 +124,8 @@ public class PostWatchedProjects
private static String format(String project, String filter) {
return project
+ (filter != null && !WatchConfig.FILTER_ALL.equals(filter) ? " and filter " + filter : "");
+ (filter != null && !ProjectWatches.FILTER_ALL.equals(filter)
? " and filter " + filter
: "");
}
}

View File

@@ -26,7 +26,7 @@ import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.account.PreferencesConfig;
import com.google.gerrit.server.account.Preferences;
import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -68,7 +68,7 @@ public class SetPreferences implements RestModifyView<AccountResource, GeneralPr
}
checkDownloadScheme(input.downloadScheme);
PreferencesConfig.validateMy(input.my);
Preferences.validateMy(input.my);
Account.Id id = rsrc.getUser().getAccountId();
accountsUpdate

View File

@@ -18,7 +18,7 @@ import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.account.PreferencesConfig;
import com.google.gerrit.server.account.Preferences;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.git.GitRepositoryManager;
@@ -44,7 +44,7 @@ public class GetDiffPreferences implements RestReadView<ConfigResource> {
public DiffPreferencesInfo apply(ConfigResource configResource)
throws BadRequestException, ResourceConflictException, IOException, ConfigInvalidException {
try (Repository git = gitManager.openRepository(allUsersName)) {
return PreferencesConfig.readDefaultDiffPreferences(git);
return Preferences.readDefaultDiffPreferences(git);
}
}
}

View File

@@ -18,7 +18,7 @@ import com.google.gerrit.extensions.client.EditPreferencesInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.account.PreferencesConfig;
import com.google.gerrit.server.account.Preferences;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.git.GitRepositoryManager;
@@ -43,7 +43,7 @@ public class GetEditPreferences implements RestReadView<ConfigResource> {
public EditPreferencesInfo apply(ConfigResource configResource)
throws BadRequestException, ResourceConflictException, IOException, ConfigInvalidException {
try (Repository git = gitManager.openRepository(allUsersName)) {
return PreferencesConfig.readDefaultEditPreferences(git);
return Preferences.readDefaultEditPreferences(git);
}
}
}

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.server.restapi.config;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.account.PreferencesConfig;
import com.google.gerrit.server.account.Preferences;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.git.GitRepositoryManager;
@@ -41,7 +41,7 @@ public class GetPreferences implements RestReadView<ConfigResource> {
public GeneralPreferencesInfo apply(ConfigResource rsrc)
throws IOException, ConfigInvalidException {
try (Repository git = gitMgr.openRepository(allUsersName)) {
return PreferencesConfig.readDefaultGeneralPreferences(git);
return Preferences.readDefaultGeneralPreferences(git);
}
}
}

View File

@@ -22,7 +22,7 @@ import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.PreferencesConfig;
import com.google.gerrit.server.account.Preferences;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.git.MetaDataUpdate;
@@ -65,7 +65,7 @@ public class SetDiffPreferences implements RestModifyView<ConfigResource, DiffPr
}
try (MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName)) {
DiffPreferencesInfo updatedPrefs = PreferencesConfig.updateDefaultDiffPreferences(md, input);
DiffPreferencesInfo updatedPrefs = Preferences.updateDefaultDiffPreferences(md, input);
accountCache.evictAllNoReindex();
return updatedPrefs;
}

View File

@@ -22,7 +22,7 @@ import com.google.gerrit.extensions.client.EditPreferencesInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.PreferencesConfig;
import com.google.gerrit.server.account.Preferences;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.git.MetaDataUpdate;
@@ -65,7 +65,7 @@ public class SetEditPreferences implements RestModifyView<ConfigResource, EditPr
}
try (MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName)) {
EditPreferencesInfo updatedPrefs = PreferencesConfig.updateDefaultEditPreferences(md, input);
EditPreferencesInfo updatedPrefs = Preferences.updateDefaultEditPreferences(md, input);
accountCache.evictAllNoReindex();
return updatedPrefs;
}

View File

@@ -22,7 +22,7 @@ import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.PreferencesConfig;
import com.google.gerrit.server.account.Preferences;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.git.MetaDataUpdate;
@@ -60,10 +60,9 @@ public class SetPreferences implements RestModifyView<ConfigResource, GeneralPre
if (!hasSetFields(input)) {
throw new BadRequestException("unsupported option");
}
PreferencesConfig.validateMy(input.my);
Preferences.validateMy(input.my);
try (MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName)) {
GeneralPreferencesInfo updatedPrefs =
PreferencesConfig.updateDefaultGeneralPreferences(md, input);
GeneralPreferencesInfo updatedPrefs = Preferences.updateDefaultGeneralPreferences(md, input);
accountCache.evictAllNoReindex();
return updatedPrefs;
}

View File

@@ -26,8 +26,8 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.account.AccountConfig;
import com.google.gerrit.server.account.InternalAccountUpdate;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
import com.google.gerrit.server.git.GitRepositoryManager;

View File

@@ -94,8 +94,8 @@ import com.google.gerrit.server.account.AccountConfig;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.account.Emails;
import com.google.gerrit.server.account.WatchConfig;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIdNotes;
import com.google.gerrit.server.account.externalids.ExternalIds;
@@ -1322,37 +1322,38 @@ public class AccountIT extends AbstractDaemonTest {
Config wc = new Config();
wc.setString(
WatchConfig.PROJECT,
ProjectWatches.PROJECT,
project.get(),
WatchConfig.KEY_NOTIFY,
WatchConfig.NotifyValue.create(null, EnumSet.of(NotifyType.ALL_COMMENTS)).toString());
ProjectWatches.KEY_NOTIFY,
ProjectWatches.NotifyValue.create(null, EnumSet.of(NotifyType.ALL_COMMENTS)).toString());
PushOneCommit push =
pushFactory.create(
db,
admin.getIdent(),
allUsersRepo,
"Add project watch",
WatchConfig.WATCH_CONFIG,
ProjectWatches.WATCH_CONFIG,
wc.toText());
push.to(RefNames.REFS_USERS_SELF).assertOkStatus();
accountIndexedCounter.assertReindexOf(admin);
String invalidNotifyValue = "]invalid[";
wc.setString(WatchConfig.PROJECT, project.get(), WatchConfig.KEY_NOTIFY, invalidNotifyValue);
wc.setString(
ProjectWatches.PROJECT, project.get(), ProjectWatches.KEY_NOTIFY, invalidNotifyValue);
push =
pushFactory.create(
db,
admin.getIdent(),
allUsersRepo,
"Add invalid project watch",
WatchConfig.WATCH_CONFIG,
ProjectWatches.WATCH_CONFIG,
wc.toText());
PushOneCommit.Result r = push.to(RefNames.REFS_USERS_SELF);
r.assertErrorStatus("invalid account configuration");
r.assertMessage(
String.format(
"%s: Invalid project watch of account %d for project %s: %s",
WatchConfig.WATCH_CONFIG, admin.getId().get(), project.get(), invalidNotifyValue));
ProjectWatches.WATCH_CONFIG, admin.getId().get(), project.get(), invalidNotifyValue));
}
@Test

View File

@@ -21,11 +21,11 @@ import static com.google.gerrit.extensions.api.changes.NotifyHandling.OWNER;
import static com.google.gerrit.extensions.api.changes.NotifyHandling.OWNER_REVIEWERS;
import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy.CC_ON_OWN_COMMENTS;
import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy.ENABLED;
import static com.google.gerrit.server.account.WatchConfig.NotifyType.ABANDONED_CHANGES;
import static com.google.gerrit.server.account.WatchConfig.NotifyType.ALL_COMMENTS;
import static com.google.gerrit.server.account.WatchConfig.NotifyType.NEW_CHANGES;
import static com.google.gerrit.server.account.WatchConfig.NotifyType.NEW_PATCHSETS;
import static com.google.gerrit.server.account.WatchConfig.NotifyType.SUBMITTED_CHANGES;
import static com.google.gerrit.server.account.ProjectWatches.NotifyType.ABANDONED_CHANGES;
import static com.google.gerrit.server.account.ProjectWatches.NotifyType.ALL_COMMENTS;
import static com.google.gerrit.server.account.ProjectWatches.NotifyType.NEW_CHANGES;
import static com.google.gerrit.server.account.ProjectWatches.NotifyType.NEW_PATCHSETS;
import static com.google.gerrit.server.account.ProjectWatches.NotifyType.SUBMITTED_CHANGES;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import com.google.common.collect.ImmutableList;

View File

@@ -28,7 +28,7 @@ import com.google.gerrit.extensions.api.changes.StarsInput;
import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.git.NotifyConfig;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.mail.Address;

View File

@@ -19,9 +19,9 @@ import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableSet;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.account.WatchConfig.NotifyType;
import com.google.gerrit.server.account.WatchConfig.NotifyValue;
import com.google.gerrit.server.account.WatchConfig.ProjectWatchKey;
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
import com.google.gerrit.server.account.ProjectWatches.NotifyValue;
import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey;
import com.google.gerrit.server.git.ValidationError;
import java.util.ArrayList;
import java.util.EnumSet;
@@ -54,7 +54,7 @@ public class WatchConfigTest implements ValidationError.Sink {
+ " notify = [NEW_PATCHSETS]\n"
+ " notify = * [NEW_PATCHSETS, ALL_COMMENTS]\n");
Map<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches =
WatchConfig.parse(new Account.Id(1000000), cfg, this);
ProjectWatches.parse(new Account.Id(1000000), cfg, this);
assertThat(validationErrors).isEmpty();
@@ -87,7 +87,7 @@ public class WatchConfigTest implements ValidationError.Sink {
+ "[project \"otherProject\"]\n"
+ " notify = [NEW_PATCHSETS]\n");
WatchConfig.parse(new Account.Id(1000000), cfg, this);
ProjectWatches.parse(new Account.Id(1000000), cfg, this);
assertThat(validationErrors).hasSize(1);
assertThat(validationErrors.get(0).getMessage())
.isEqualTo(