Skip to content

Commit

Permalink
Merge changes I8ab306e8,Ib1abbb96
Browse files Browse the repository at this point in the history
* changes:
  Add AutoValue classes for Preferences
  Rename Preferences to StoredPreferences
  • Loading branch information
phiesel authored and Gerrit Code Review committed Sep 25, 2019
2 parents 2638da8 + 0d9c7e2 commit a5dd85e
Show file tree
Hide file tree
Showing 16 changed files with 1,136 additions and 602 deletions.
19 changes: 11 additions & 8 deletions java/com/google/gerrit/server/account/AccountConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
* <li>'account.config': Contains the account properties. Parsing and writing it is delegated to
* {@link AccountProperties}.
* <li>'preferences.config': Contains the preferences. Parsing and writing it is delegated to
* {@link Preferences}.
* {@link StoredPreferences}.
* <li>'account.config': Contains the project watches. Parsing and writing it is delegated to
* {@link ProjectWatches}.
* </ul>
Expand All @@ -85,7 +85,7 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
private Optional<AccountProperties> loadedAccountProperties;
private Optional<ObjectId> externalIdsRev;
private ProjectWatches projectWatches;
private Preferences preferences;
private StoredPreferences preferences;
private Optional<InternalAccountUpdate> accountUpdate = Optional.empty();
private List<ValidationError> validationErrors;

Expand Down Expand Up @@ -242,10 +242,10 @@ protected void onLoad() throws IOException, ConfigInvalidException {
projectWatches = new ProjectWatches(accountId, readConfig(ProjectWatches.WATCH_CONFIG), this);

preferences =
new Preferences(
new StoredPreferences(
accountId,
readConfig(Preferences.PREFERENCES_CONFIG),
Preferences.readDefaultConfig(allUsersName, repo),
readConfig(StoredPreferences.PREFERENCES_CONFIG),
StoredPreferences.readDefaultConfig(allUsersName, repo),
this);

projectWatches.parse();
Expand All @@ -256,8 +256,11 @@ protected void onLoad() throws IOException, ConfigInvalidException {
projectWatches = new ProjectWatches(accountId, new Config(), this);

preferences =
new Preferences(
accountId, new Config(), Preferences.readDefaultConfig(allUsersName, repo), this);
new StoredPreferences(
accountId,
new Config(),
StoredPreferences.readDefaultConfig(allUsersName, repo),
this);
}

Ref externalIdsRef = repo.exactRef(RefNames.REFS_EXTERNAL_IDS);
Expand Down Expand Up @@ -331,7 +334,7 @@ private void savePreferences() throws IOException, ConfigInvalidException {
}

saveConfig(
Preferences.PREFERENCES_CONFIG,
StoredPreferences.PREFERENCES_CONFIG,
preferences.saveGeneralPreferences(
accountUpdate.get().getGeneralPreferences(),
accountUpdate.get().getDiffPreferences(),
Expand Down
18 changes: 9 additions & 9 deletions java/com/google/gerrit/server/account/AccountState.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ public static AccountState forAccount(Account account, Collection<ExternalId> ex
private final ImmutableSet<ExternalId> externalIds;
private final Optional<String> userName;
private final ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches;
private final GeneralPreferencesInfo generalPreferences;
private final DiffPreferencesInfo diffPreferences;
private final EditPreferencesInfo editPreferences;
private final Preferences.General generalPreferences;
private final Preferences.Diff diffPreferences;
private final Preferences.Edit editPreferences;

private AccountState(
Account account,
Expand All @@ -146,9 +146,9 @@ private AccountState(
this.externalIds = externalIds;
this.userName = ExternalId.getUserName(externalIds);
this.projectWatches = projectWatches;
this.generalPreferences = generalPreferences;
this.diffPreferences = diffPreferences;
this.editPreferences = editPreferences;
this.generalPreferences = Preferences.General.fromInfo(generalPreferences);
this.diffPreferences = Preferences.Diff.fromInfo(diffPreferences);
this.editPreferences = Preferences.Edit.fromInfo(editPreferences);
}

/** Get the cached account metadata. */
Expand Down Expand Up @@ -180,17 +180,17 @@ public ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> getProjectWatches

/** The general preferences of the account. */
public GeneralPreferencesInfo getGeneralPreferences() {
return generalPreferences;
return generalPreferences.toInfo();
}

/** The diff preferences of the account. */
public DiffPreferencesInfo getDiffPreferences() {
return diffPreferences;
return diffPreferences.toInfo();
}

/** The edit preferences of the account. */
public EditPreferencesInfo getEditPreferences() {
return editPreferences;
return editPreferences.toInfo();
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions java/com/google/gerrit/server/account/AccountsUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
* 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 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
* contain a 'preferences.config' config file to store preferences (see {@link StoredPreferences})
* 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}).
*
* <p>On updating an account the account is evicted from the account cache and reindexed. The
Expand Down
Loading

0 comments on commit a5dd85e

Please sign in to comment.