本文整理汇总了Java中com.google.gerrit.extensions.client.GeneralPreferencesInfo类的典型用法代码示例。如果您正苦于以下问题:Java GeneralPreferencesInfo类的具体用法?Java GeneralPreferencesInfo怎么用?Java GeneralPreferencesInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeneralPreferencesInfo类属于com.google.gerrit.extensions.client包,在下文中一共展示了GeneralPreferencesInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MagicBranchInput
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
MagicBranchInput(
IdentifiedUser user,
ReceiveCommand cmd,
LabelTypes labelTypes,
NotesMigration notesMigration) {
this.cmd = cmd;
this.draft = cmd.getRefName().startsWith(MagicBranch.NEW_DRAFT_CHANGE);
this.publish = cmd.getRefName().startsWith(MagicBranch.NEW_PUBLISH_CHANGE);
this.labelTypes = labelTypes;
this.notesMigration = notesMigration;
GeneralPreferencesInfo prefs = user.getAccount().getGeneralPreferencesInfo();
this.defaultPublishComments =
prefs != null
? firstNonNull(
user.getAccount().getGeneralPreferencesInfo().publishCommentsOnPush, false)
: false;
}
示例2: apply
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
@Override
public GeneralPreferencesInfo apply(AccountResource rsrc, GeneralPreferencesInfo i)
throws AuthException, BadRequestException, IOException, ConfigInvalidException,
PermissionBackendException {
if (self.get() != rsrc.getUser()) {
permissionBackend.user(self).check(GlobalPermission.MODIFY_ACCOUNT);
}
checkDownloadScheme(i.downloadScheme);
Account.Id id = rsrc.getUser().getAccountId();
GeneralPreferencesInfo n = loader.merge(id, i);
n.changeTable = i.changeTable;
n.my = i.my;
n.urlAliases = i.urlAliases;
writeToGit(id, n);
return cache.get(id).getAccount().getGeneralPreferencesInfo();
}
示例3: writeToGit
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
private void writeToGit(Account.Id id, GeneralPreferencesInfo i)
throws RepositoryNotFoundException, IOException, ConfigInvalidException {
VersionedAccountPreferences prefs;
try (MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName)) {
prefs = VersionedAccountPreferences.forUser(id);
prefs.load(md);
storeSection(
prefs.getConfig(),
UserConfigSections.GENERAL,
null,
i,
loader.readDefaultsFromGit(md.getRepository(), null));
storeMyChangeTableColumns(prefs, i.changeTable);
storeMyMenus(prefs, i.my);
storeUrlAliases(prefs, i.urlAliases);
prefs.commit(md);
cache.evict(id);
}
}
示例4: read
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
private GeneralPreferencesInfo read(Account.Id id, GeneralPreferencesInfo in)
throws IOException, ConfigInvalidException, RepositoryNotFoundException {
try (Repository allUsers = gitMgr.openRepository(allUsersName)) {
// Load all users default prefs
VersionedAccountPreferences dp = VersionedAccountPreferences.forDefault();
dp.load(allUsers);
// Load user prefs
VersionedAccountPreferences p = VersionedAccountPreferences.forUser(id);
p.load(allUsers);
GeneralPreferencesInfo r =
loadSection(
p.getConfig(),
UserConfigSections.GENERAL,
null,
new GeneralPreferencesInfo(),
readDefaultsFromGit(dp.getConfig(), in),
in);
loadChangeTableColumns(r, p, dp);
return loadMyMenusAndUrlAliases(r, p, dp);
}
}
示例5: updateDefaults
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
private GeneralPreferencesInfo updateDefaults(GeneralPreferencesInfo input) {
GeneralPreferencesInfo result = GeneralPreferencesInfo.defaults();
try {
for (Field field : input.getClass().getDeclaredFields()) {
if (skipField(field)) {
continue;
}
Object newVal = field.get(input);
if (newVal != null) {
field.set(result, newVal);
}
}
} catch (IllegalAccessException e) {
log.error("Cannot get default general preferences from " + allUsersName.get(), e);
return GeneralPreferencesInfo.defaults();
}
return result;
}
示例6: loadMyMenusAndUrlAliases
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
public GeneralPreferencesInfo loadMyMenusAndUrlAliases(
GeneralPreferencesInfo r, VersionedAccountPreferences v, VersionedAccountPreferences d) {
r.my = my(v);
if (r.my.isEmpty() && !v.isDefaults()) {
r.my = my(d);
}
if (r.my.isEmpty()) {
r.my.add(new MenuItem("Changes", "#/dashboard/self", null));
r.my.add(new MenuItem("Draft Comments", "#/q/has:draft", null));
r.my.add(new MenuItem("Edits", "#/q/has:edit", null));
r.my.add(new MenuItem("Watched Changes", "#/q/is:watched+is:open", null));
r.my.add(new MenuItem("Starred Changes", "#/q/is:starred", null));
r.my.add(new MenuItem("Groups", "#/groups/self", null));
}
r.urlAliases = urlAliases(v);
if (r.urlAliases == null && !v.isDefaults()) {
r.urlAliases = urlAliases(d);
}
return r;
}
示例7: load
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
@Override
public Optional<AccountState> load(Account.Id who) throws Exception {
Account account = accounts.get(who);
if (account == null) {
return Optional.empty();
}
try {
account.setGeneralPreferences(loader.load(who));
} catch (IOException | ConfigInvalidException e) {
log.warn("Cannot load GeneralPreferences for " + who + " (using default)", e);
account.setGeneralPreferences(GeneralPreferencesInfo.defaults());
}
return Optional.of(
new AccountState(
allUsersName,
account,
externalIds.byAccount(who),
watchConfig.get().getProjectWatches(who)));
}
示例8: writeToGit
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
private GeneralPreferencesInfo writeToGit(GeneralPreferencesInfo i)
throws RepositoryNotFoundException, IOException, ConfigInvalidException {
try (MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName)) {
VersionedAccountPreferences p = VersionedAccountPreferences.forDefault();
p.load(md);
storeSection(
p.getConfig(), UserConfigSections.GENERAL, null, i, GeneralPreferencesInfo.defaults());
com.google.gerrit.server.account.SetPreferences.storeMyMenus(p, i.my);
com.google.gerrit.server.account.SetPreferences.storeUrlAliases(p, i.urlAliases);
p.commit(md);
accountCache.evictAllNoReindex();
GeneralPreferencesInfo r =
loadSection(
p.getConfig(),
UserConfigSections.GENERAL,
null,
new GeneralPreferencesInfo(),
GeneralPreferencesInfo.defaults(),
null);
return loader.loadMyMenusAndUrlAliases(r, p, null);
}
}
示例9: readFromGit
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
static GeneralPreferencesInfo readFromGit(
GitRepositoryManager gitMgr,
GeneralPreferencesLoader loader,
AllUsersName allUsersName,
GeneralPreferencesInfo in)
throws IOException, ConfigInvalidException, RepositoryNotFoundException {
try (Repository git = gitMgr.openRepository(allUsersName)) {
VersionedAccountPreferences p = VersionedAccountPreferences.forDefault();
p.load(git);
GeneralPreferencesInfo r =
loadSection(
p.getConfig(),
UserConfigSections.GENERAL,
null,
new GeneralPreferencesInfo(),
GeneralPreferencesInfo.defaults(),
in);
// TODO(davido): Maintain cache of default values in AllUsers repository
return loader.loadMyMenusAndUrlAliases(r, p, null);
}
}
示例10: createDefault
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
public static GeneralPreferences createDefault() {
GeneralPreferencesInfo d = GeneralPreferencesInfo.defaults();
GeneralPreferences p = createObject().cast();
p.changesPerPage(d.changesPerPage);
p.showSiteHeader(d.showSiteHeader);
p.useFlashClipboard(d.useFlashClipboard);
p.downloadScheme(d.downloadScheme);
p.downloadCommand(d.downloadCommand);
p.dateFormat(d.getDateFormat());
p.timeFormat(d.getTimeFormat());
p.highlightAssigneeInChangeTable(d.highlightAssigneeInChangeTable);
p.relativeDateInChangeTable(d.relativeDateInChangeTable);
p.sizeBarInChangeTable(d.sizeBarInChangeTable);
p.legacycidInChangeTable(d.legacycidInChangeTable);
p.muteCommonPathPrefixes(d.muteCommonPathPrefixes);
p.signedOffBy(d.signedOffBy);
p.emailFormat(d.emailFormat);
p.reviewCategoryStrategy(d.getReviewCategoryStrategy());
p.diffView(d.getDiffView());
p.emailStrategy(d.emailStrategy);
p.defaultBaseForMerges(d.defaultBaseForMerges);
return p;
}
示例11: publishCommentsOnPushWithPreference
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
@Test
public void publishCommentsOnPushWithPreference() throws Exception {
PushOneCommit.Result r = createChange();
addDraft(r.getChangeId(), r.getCommit().name(), newDraft(FILE_NAME, 1, "comment1"));
r = amendChange(r.getChangeId());
assertThat(getPublishedComments(r.getChangeId())).isEmpty();
GeneralPreferencesInfo prefs = gApi.accounts().id(admin.id.get()).getPreferences();
prefs.publishCommentsOnPush = true;
gApi.accounts().id(admin.id.get()).setPreferences(prefs);
r = amendChange(r.getChangeId());
assertThat(getPublishedComments(r.getChangeId()).stream().map(c -> c.message))
.containsExactly("comment1");
}
示例12: getPreferencesWithConfiguredDefaults
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
@Test
public void getPreferencesWithConfiguredDefaults() throws Exception {
GeneralPreferencesInfo d = GeneralPreferencesInfo.defaults();
int newChangesPerPage = d.changesPerPage * 2;
GeneralPreferencesInfo update = new GeneralPreferencesInfo();
update.changesPerPage = newChangesPerPage;
gApi.config().server().setDefaultPreferences(update);
GeneralPreferencesInfo o = gApi.accounts().id(user42.getId().toString()).getPreferences();
// assert configured defaults
assertThat(o.changesPerPage).isEqualTo(newChangesPerPage);
// assert hard-coded defaults
assertPrefs(o, d, "my", "changeTable", "changesPerPage");
}
示例13: userReceivesPlaintextEmail
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
@Test
public void userReceivesPlaintextEmail() throws Exception {
// Set user preference to receive only plaintext content
GeneralPreferencesInfo i = new GeneralPreferencesInfo();
i.emailFormat = EmailFormat.PLAINTEXT;
gApi.accounts().id(admin.getId().toString()).setPreferences(i);
// Create change as admin and review as user
PushOneCommit.Result r = createChange();
setApiUser(user);
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.recommend());
// Check that admin has received only plaintext content
assertThat(sender.getMessages()).hasSize(1);
FakeEmailSender.Message m = sender.getMessages().get(0);
assertThat(m.body()).isNotNull();
assertThat(m.htmlBody()).isNull();
assertMailReplyTo(m, admin.email);
assertMailReplyTo(m, user.email);
// Reset user preference
setApiUser(admin);
i.emailFormat = EmailFormat.HTML_PLAINTEXT;
gApi.accounts().id(admin.getId().toString()).setPreferences(i);
}
示例14: GitDownloadCommand
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
GitDownloadCommand(
@GerritServerConfig Config cfg,
DownloadConfig downloadConfig,
GeneralPreferencesInfo.DownloadCommand cmd,
GitRepositoryManager repoManager) {
this.commandAllowed = downloadConfig.getDownloadCommands().contains(cmd);
this.repoManager = repoManager;
this.checkForHiddenChangeRefs =
cfg.getBoolean(DOWNLOAD, KEY_CHECK_FOR_HIDDEN_CHANGE_REFS, false);
}
示例15: setEmailStrategy
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; //导入依赖的package包/类
protected void setEmailStrategy(TestAccount account, EmailStrategy strategy, boolean record)
throws Exception {
if (record) {
accountsModifyingEmailStrategy.add(account);
}
setApiUser(account);
GeneralPreferencesInfo prefs = gApi.accounts().self().getPreferences();
prefs.emailStrategy = strategy;
gApi.accounts().self().setPreferences(prefs);
}