AccountConfig: Extract parsing/writing of account properties into new class

AccountConfig reads/writes account properties, preferences and project
watches, but only the parsing/writing of account properties was done in
this class. Parsing/writing preferences and project watches is done in
separate classes. Make this consistent and have a separate class for
parsing/writing account properties too. This makes AccountConfig more
readable since it's now free of parsing logic.

Change-Id: I66278a65b2e583976586f9f8816d924a8fd55bdf
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-01-17 17:29:22 +01:00
parent 4f57f9a939
commit 2a6644f5b1
6 changed files with 238 additions and 172 deletions

View File

@@ -21,6 +21,7 @@ import com.google.gerrit.common.Nullable;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountConfig;
import com.google.gerrit.server.account.AccountProperties;
import com.google.gerrit.server.git.ValidationError;
import com.google.gerrit.server.mail.send.OutgoingEmailValidator;
import com.google.inject.Inject;
@@ -65,7 +66,7 @@ public class AccountValidator {
return ImmutableList.of(
String.format(
"commit '%s' has an invalid '%s' file for account '%s': %s",
newId.name(), AccountConfig.ACCOUNT_CONFIG, accountId.get(), e.getMessage()));
newId.name(), AccountProperties.ACCOUNT_CONFIG, accountId.get(), e.getMessage()));
}
if (!newAccount.isPresent()) {

View File

@@ -28,7 +28,7 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountConfig;
import com.google.gerrit.server.account.AccountProperties;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.PluginConfig;
@@ -276,7 +276,7 @@ public class MergeValidators {
changeDataFactory.create(
dbProvider.get(), destProject.getProject().getNameKey(), patchSetId.getParentKey());
try {
if (!cd.currentFilePaths().contains(AccountConfig.ACCOUNT_CONFIG)) {
if (!cd.currentFilePaths().contains(AccountProperties.ACCOUNT_CONFIG)) {
return;
}
} catch (IOException | OrmException e) {