Don't store username in Account but in AccountState
The username is just an external ID and all other external IDs are kept in AccountState. It is more consistent if the username is kept in AccountState alongside the other external IDs. This is also a preparation to make Account an AutoValue class. Then account will be non-mutable and hence a username can no longer be set on it after it was created. Change-Id: Ia7ad7b43326caea356812e48ecee9dd92da596ab Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -160,20 +160,21 @@ class BecomeAnyAccountLoginServlet extends HttpServlet {
|
|||||||
Element userlistElement = HtmlDomUtil.find(doc, "userlist");
|
Element userlistElement = HtmlDomUtil.find(doc, "userlist");
|
||||||
try (ReviewDb db = schema.open()) {
|
try (ReviewDb db = schema.open()) {
|
||||||
for (Account.Id accountId : accounts.firstNIds(100)) {
|
for (Account.Id accountId : accounts.firstNIds(100)) {
|
||||||
Account a = accountCache.get(accountId).getAccount();
|
AccountState accountState = accountCache.get(accountId);
|
||||||
|
Account account = accountState.getAccount();
|
||||||
String displayName;
|
String displayName;
|
||||||
if (a.getUserName() != null) {
|
if (accountState.getUserName() != null) {
|
||||||
displayName = a.getUserName();
|
displayName = accountState.getUserName();
|
||||||
} else if (a.getFullName() != null && !a.getFullName().isEmpty()) {
|
} else if (account.getFullName() != null && !account.getFullName().isEmpty()) {
|
||||||
displayName = a.getFullName();
|
displayName = account.getFullName();
|
||||||
} else if (a.getPreferredEmail() != null) {
|
} else if (account.getPreferredEmail() != null) {
|
||||||
displayName = a.getPreferredEmail();
|
displayName = account.getPreferredEmail();
|
||||||
} else {
|
} else {
|
||||||
displayName = accountId.toString();
|
displayName = accountId.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Element linkElement = doc.createElement("a");
|
Element linkElement = doc.createElement("a");
|
||||||
linkElement.setAttribute("href", "?account_id=" + a.getId().toString());
|
linkElement.setAttribute("href", "?account_id=" + account.getId().toString());
|
||||||
linkElement.setTextContent(displayName);
|
linkElement.setTextContent(displayName);
|
||||||
userlistElement.appendChild(linkElement);
|
userlistElement.appendChild(linkElement);
|
||||||
userlistElement.appendChild(doc.createElement("br"));
|
userlistElement.appendChild(doc.createElement("br"));
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
|
|||||||
RefNames.REFS_CONFIG,
|
RefNames.REFS_CONFIG,
|
||||||
base,
|
base,
|
||||||
commit.getId(),
|
commit.getId(),
|
||||||
user.asIdentifiedUser().getAccount());
|
user.asIdentifiedUser().state());
|
||||||
|
|
||||||
projectCache.evict(config.getProject());
|
projectCache.evict(config.getProject());
|
||||||
createGroupPermissionSyncer.syncIfNeeded();
|
createGroupPermissionSyncer.syncIfNeeded();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public final class Account {
|
|||||||
public static final String USER_NAME_PATTERN_REST = "[a-zA-Z0-9._@-]";
|
public static final String USER_NAME_PATTERN_REST = "[a-zA-Z0-9._@-]";
|
||||||
public static final String USER_NAME_PATTERN_LAST = "[a-zA-Z0-9]";
|
public static final String USER_NAME_PATTERN_LAST = "[a-zA-Z0-9]";
|
||||||
|
|
||||||
/** Regular expression that {@link #userName} must match. */
|
/** Regular expression that a username must match. */
|
||||||
public static final String USER_NAME_PATTERN =
|
public static final String USER_NAME_PATTERN =
|
||||||
"^"
|
"^"
|
||||||
+ //
|
+ //
|
||||||
@@ -176,9 +176,6 @@ public final class Account {
|
|||||||
@Column(id = 8, notNull = false)
|
@Column(id = 8, notNull = false)
|
||||||
protected String status;
|
protected String status;
|
||||||
|
|
||||||
/** <i>computed</i> the username selected from the identities. */
|
|
||||||
protected String userName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID of the user branch from which the account was read, {@code null} if the account was read
|
* ID of the user branch from which the account was read, {@code null} if the account was read
|
||||||
* from ReviewDb.
|
* from ReviewDb.
|
||||||
@@ -306,16 +303,6 @@ public final class Account {
|
|||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the computed user name for this account */
|
|
||||||
public String getUserName() {
|
|
||||||
return userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Update the computed user name property. */
|
|
||||||
public void setUserName(String userName) {
|
|
||||||
this.userName = userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
return o instanceof Account && ((Account) o).getId().equals(getId());
|
return o instanceof Account && ((Account) o).getId().equals(getId());
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ public class AccountState {
|
|||||||
private final AllUsersName allUsersName;
|
private final AllUsersName allUsersName;
|
||||||
private final Account account;
|
private final Account account;
|
||||||
private final ImmutableSet<ExternalId> externalIds;
|
private final ImmutableSet<ExternalId> externalIds;
|
||||||
|
private final Optional<String> userName;
|
||||||
private final Supplier<ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>>> projectWatches;
|
private final Supplier<ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>>> projectWatches;
|
||||||
private final Supplier<GeneralPreferencesInfo> generalPreferences;
|
private final Supplier<GeneralPreferencesInfo> generalPreferences;
|
||||||
private final Supplier<DiffPreferencesInfo> diffPreferences;
|
private final Supplier<DiffPreferencesInfo> diffPreferences;
|
||||||
@@ -174,11 +175,11 @@ public class AccountState {
|
|||||||
this.allUsersName = allUsersName;
|
this.allUsersName = allUsersName;
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.externalIds = externalIds;
|
this.externalIds = externalIds;
|
||||||
|
this.userName = ExternalId.getUserName(externalIds);
|
||||||
this.projectWatches = projectWatches;
|
this.projectWatches = projectWatches;
|
||||||
this.generalPreferences = generalPreferences;
|
this.generalPreferences = generalPreferences;
|
||||||
this.diffPreferences = diffPreferences;
|
this.diffPreferences = diffPreferences;
|
||||||
this.editPreferences = editPreferences;
|
this.editPreferences = editPreferences;
|
||||||
this.account.setUserName(ExternalId.getUserName(externalIds).orElse(null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AllUsersName getAllUsersNameForIndexing() {
|
public AllUsersName getAllUsersNameForIndexing() {
|
||||||
@@ -195,8 +196,9 @@ public class AccountState {
|
|||||||
*
|
*
|
||||||
* <p>The username is the {@link ExternalId} using the scheme {@link ExternalId#SCHEME_USERNAME}.
|
* <p>The username is the {@link ExternalId} using the scheme {@link ExternalId#SCHEME_USERNAME}.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
return account.getUserName();
|
return userName.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkPassword(String password, String username) {
|
public boolean checkPassword(String password, String username) {
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ public class AccountsUpdate {
|
|||||||
RefUpdateUtil.executeChecked(batchRefUpdate, allUsersRepo);
|
RefUpdateUtil.executeChecked(batchRefUpdate, allUsersRepo);
|
||||||
updatedAccount.getExternalIdNotes().updateCaches();
|
updatedAccount.getExternalIdNotes().updateCaches();
|
||||||
gitRefUpdated.fire(
|
gitRefUpdated.fire(
|
||||||
allUsersName, batchRefUpdate, currentUser != null ? currentUser.getAccount() : null);
|
allUsersName, batchRefUpdate, currentUser != null ? currentUser.state() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commitNewAccountConfig(
|
private void commitNewAccountConfig(
|
||||||
|
|||||||
@@ -69,15 +69,16 @@ public class InternalAccountDirectory extends AccountDirectory {
|
|||||||
for (AccountInfo info : in) {
|
for (AccountInfo info : in) {
|
||||||
Account.Id id = new Account.Id(info._accountId);
|
Account.Id id = new Account.Id(info._accountId);
|
||||||
AccountState state = accountCache.get(id);
|
AccountState state = accountCache.get(id);
|
||||||
fill(info, state.getAccount(), state.getExternalIds(), options);
|
fill(info, state, state.getExternalIds(), options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fill(
|
private void fill(
|
||||||
AccountInfo info,
|
AccountInfo info,
|
||||||
Account account,
|
AccountState accountState,
|
||||||
@Nullable Collection<ExternalId> externalIds,
|
@Nullable Collection<ExternalId> externalIds,
|
||||||
Set<FillOptions> options) {
|
Set<FillOptions> options) {
|
||||||
|
Account account = accountState.getAccount();
|
||||||
if (options.contains(FillOptions.ID)) {
|
if (options.contains(FillOptions.ID)) {
|
||||||
info._accountId = account.getId().get();
|
info._accountId = account.getId().get();
|
||||||
} else {
|
} else {
|
||||||
@@ -87,7 +88,7 @@ public class InternalAccountDirectory extends AccountDirectory {
|
|||||||
if (options.contains(FillOptions.NAME)) {
|
if (options.contains(FillOptions.NAME)) {
|
||||||
info.name = Strings.emptyToNull(account.getFullName());
|
info.name = Strings.emptyToNull(account.getFullName());
|
||||||
if (info.name == null) {
|
if (info.name == null) {
|
||||||
info.name = account.getUserName();
|
info.name = accountState.getUserName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.contains(FillOptions.EMAIL)) {
|
if (options.contains(FillOptions.EMAIL)) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
|||||||
import com.google.gerrit.server.ChangeMessagesUtil;
|
import com.google.gerrit.server.ChangeMessagesUtil;
|
||||||
import com.google.gerrit.server.ChangeUtil;
|
import com.google.gerrit.server.ChangeUtil;
|
||||||
import com.google.gerrit.server.PatchSetUtil;
|
import com.google.gerrit.server.PatchSetUtil;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.extensions.events.ChangeAbandoned;
|
import com.google.gerrit.server.extensions.events.ChangeAbandoned;
|
||||||
import com.google.gerrit.server.mail.send.AbandonedSender;
|
import com.google.gerrit.server.mail.send.AbandonedSender;
|
||||||
import com.google.gerrit.server.mail.send.ReplyToChangeSender;
|
import com.google.gerrit.server.mail.send.ReplyToChangeSender;
|
||||||
@@ -51,7 +52,7 @@ public class AbandonOp implements BatchUpdateOp {
|
|||||||
private final String msgTxt;
|
private final String msgTxt;
|
||||||
private final NotifyHandling notifyHandling;
|
private final NotifyHandling notifyHandling;
|
||||||
private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
|
private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
|
||||||
private final Account account;
|
private final AccountState accountState;
|
||||||
|
|
||||||
private Change change;
|
private Change change;
|
||||||
private PatchSet patchSet;
|
private PatchSet patchSet;
|
||||||
@@ -59,7 +60,7 @@ public class AbandonOp implements BatchUpdateOp {
|
|||||||
|
|
||||||
public interface Factory {
|
public interface Factory {
|
||||||
AbandonOp create(
|
AbandonOp create(
|
||||||
@Assisted @Nullable Account account,
|
@Assisted @Nullable AccountState accountState,
|
||||||
@Assisted @Nullable String msgTxt,
|
@Assisted @Nullable String msgTxt,
|
||||||
@Assisted NotifyHandling notifyHandling,
|
@Assisted NotifyHandling notifyHandling,
|
||||||
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify);
|
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify);
|
||||||
@@ -71,7 +72,7 @@ public class AbandonOp implements BatchUpdateOp {
|
|||||||
ChangeMessagesUtil cmUtil,
|
ChangeMessagesUtil cmUtil,
|
||||||
PatchSetUtil psUtil,
|
PatchSetUtil psUtil,
|
||||||
ChangeAbandoned changeAbandoned,
|
ChangeAbandoned changeAbandoned,
|
||||||
@Assisted @Nullable Account account,
|
@Assisted @Nullable AccountState accountState,
|
||||||
@Assisted @Nullable String msgTxt,
|
@Assisted @Nullable String msgTxt,
|
||||||
@Assisted NotifyHandling notifyHandling,
|
@Assisted NotifyHandling notifyHandling,
|
||||||
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify) {
|
@Assisted ListMultimap<RecipientType, Account.Id> accountsToNotify) {
|
||||||
@@ -80,7 +81,7 @@ public class AbandonOp implements BatchUpdateOp {
|
|||||||
this.psUtil = psUtil;
|
this.psUtil = psUtil;
|
||||||
this.changeAbandoned = changeAbandoned;
|
this.changeAbandoned = changeAbandoned;
|
||||||
|
|
||||||
this.account = account;
|
this.accountState = accountState;
|
||||||
this.msgTxt = Strings.nullToEmpty(msgTxt);
|
this.msgTxt = Strings.nullToEmpty(msgTxt);
|
||||||
this.notifyHandling = notifyHandling;
|
this.notifyHandling = notifyHandling;
|
||||||
this.accountsToNotify = accountsToNotify;
|
this.accountsToNotify = accountsToNotify;
|
||||||
@@ -124,8 +125,8 @@ public class AbandonOp implements BatchUpdateOp {
|
|||||||
public void postUpdate(Context ctx) throws OrmException {
|
public void postUpdate(Context ctx) throws OrmException {
|
||||||
try {
|
try {
|
||||||
ReplyToChangeSender cm = abandonedSenderFactory.create(ctx.getProject(), change.getId());
|
ReplyToChangeSender cm = abandonedSenderFactory.create(ctx.getProject(), change.getId());
|
||||||
if (account != null) {
|
if (accountState != null) {
|
||||||
cm.setFrom(account.getId());
|
cm.setFrom(accountState.getAccount().getId());
|
||||||
}
|
}
|
||||||
cm.setChangeMessage(message.getMessage(), ctx.getWhen());
|
cm.setChangeMessage(message.getMessage(), ctx.getWhen());
|
||||||
cm.setNotify(notifyHandling);
|
cm.setNotify(notifyHandling);
|
||||||
@@ -134,6 +135,6 @@ public class AbandonOp implements BatchUpdateOp {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Cannot email update for change " + change.getId(), e);
|
log.error("Cannot email update for change " + change.getId(), e);
|
||||||
}
|
}
|
||||||
changeAbandoned.fire(change, patchSet, account, msgTxt, ctx.getWhen(), notifyHandling);
|
changeAbandoned.fire(change, patchSet, accountState, msgTxt, ctx.getWhen(), notifyHandling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.Account;
|
|||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.update.BatchUpdate;
|
import com.google.gerrit.server.update.BatchUpdate;
|
||||||
import com.google.gerrit.server.update.UpdateException;
|
import com.google.gerrit.server.update.UpdateException;
|
||||||
@@ -63,7 +64,7 @@ public class BatchAbandon {
|
|||||||
if (changes.isEmpty()) {
|
if (changes.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Account account = user.isIdentifiedUser() ? user.asIdentifiedUser().getAccount() : null;
|
AccountState accountState = user.isIdentifiedUser() ? user.asIdentifiedUser().state() : null;
|
||||||
try (BatchUpdate u = updateFactory.create(dbProvider.get(), project, user, TimeUtil.nowTs())) {
|
try (BatchUpdate u = updateFactory.create(dbProvider.get(), project, user, TimeUtil.nowTs())) {
|
||||||
for (ChangeData change : changes) {
|
for (ChangeData change : changes) {
|
||||||
if (!project.equals(change.project())) {
|
if (!project.equals(change.project())) {
|
||||||
@@ -74,7 +75,7 @@ public class BatchAbandon {
|
|||||||
}
|
}
|
||||||
u.addOp(
|
u.addOp(
|
||||||
change.getId(),
|
change.getId(),
|
||||||
abandonOpFactory.create(account, msgTxt, notifyHandling, accountsToNotify));
|
abandonOpFactory.create(accountState, msgTxt, notifyHandling, accountsToNotify));
|
||||||
}
|
}
|
||||||
u.execute();
|
u.execute();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,9 +130,6 @@ public class SetAssigneeOp implements BatchUpdateOp {
|
|||||||
log.error("Cannot send email to new assignee of change " + change.getId(), err);
|
log.error("Cannot send email to new assignee of change " + change.getId(), err);
|
||||||
}
|
}
|
||||||
assigneeChanged.fire(
|
assigneeChanged.fire(
|
||||||
change,
|
change, ctx.getAccount(), oldAssignee != null ? oldAssignee.state() : null, ctx.getWhen());
|
||||||
ctx.getAccount(),
|
|
||||||
oldAssignee != null ? oldAssignee.getAccount() : null,
|
|
||||||
ctx.getWhen());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
|||||||
import com.google.gerrit.server.ApprovalsUtil;
|
import com.google.gerrit.server.ApprovalsUtil;
|
||||||
import com.google.gerrit.server.GerritPersonIdent;
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
import com.google.gerrit.server.account.AccountCache;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.account.Emails;
|
import com.google.gerrit.server.account.Emails;
|
||||||
import com.google.gerrit.server.change.ChangeKindCache;
|
import com.google.gerrit.server.change.ChangeKindCache;
|
||||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||||
@@ -245,8 +246,8 @@ public class EventFactory {
|
|||||||
la.label = lbl.label;
|
la.label = lbl.label;
|
||||||
la.status = lbl.status.name();
|
la.status = lbl.status.name();
|
||||||
if (lbl.appliedBy != null) {
|
if (lbl.appliedBy != null) {
|
||||||
Account a = accountCache.get(lbl.appliedBy).getAccount();
|
AccountState accountState = accountCache.get(lbl.appliedBy);
|
||||||
la.by = asAccountAttribute(a);
|
la.by = asAccountAttribute(accountState);
|
||||||
}
|
}
|
||||||
sa.labels.add(la);
|
sa.labels.add(la);
|
||||||
}
|
}
|
||||||
@@ -572,24 +573,24 @@ public class EventFactory {
|
|||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return asAccountAttribute(accountCache.get(id).getAccount());
|
return asAccountAttribute(accountCache.get(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an AuthorAttribute for the given account suitable for serialization to JSON.
|
* Create an AuthorAttribute for the given account suitable for serialization to JSON.
|
||||||
*
|
*
|
||||||
* @param account
|
* @param accountState the account state
|
||||||
* @return object suitable for serialization to JSON
|
* @return object suitable for serialization to JSON
|
||||||
*/
|
*/
|
||||||
public AccountAttribute asAccountAttribute(Account account) {
|
public AccountAttribute asAccountAttribute(AccountState accountState) {
|
||||||
if (account == null) {
|
if (accountState == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountAttribute who = new AccountAttribute();
|
AccountAttribute who = new AccountAttribute();
|
||||||
who.name = account.getFullName();
|
who.name = accountState.getAccount().getFullName();
|
||||||
who.email = account.getPreferredEmail();
|
who.email = accountState.getAccount().getPreferredEmail();
|
||||||
who.username = account.getUserName();
|
who.username = accountState.getUserName();
|
||||||
return who;
|
return who;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package com.google.gerrit.server.extensions.events;
|
|||||||
import com.google.gerrit.extensions.common.AccountInfo;
|
import com.google.gerrit.extensions.common.AccountInfo;
|
||||||
import com.google.gerrit.extensions.events.AgreementSignupListener;
|
import com.google.gerrit.extensions.events.AgreementSignupListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
public class AgreementSignup {
|
public class AgreementSignup {
|
||||||
@@ -30,11 +30,11 @@ public class AgreementSignup {
|
|||||||
this.util = util;
|
this.util = util;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fire(Account account, String agreementName) {
|
public void fire(AccountState accountState, String agreementName) {
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Event event = new Event(util.accountInfo(account), agreementName);
|
Event event = new Event(util.accountInfo(accountState), agreementName);
|
||||||
for (AgreementSignupListener l : listeners) {
|
for (AgreementSignupListener l : listeners) {
|
||||||
try {
|
try {
|
||||||
l.onAgreementSignup(event);
|
l.onAgreementSignup(event);
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import com.google.gerrit.extensions.common.AccountInfo;
|
|||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
import com.google.gerrit.extensions.events.AssigneeChangedListener;
|
import com.google.gerrit.extensions.events.AssigneeChangedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@@ -39,7 +39,8 @@ public class AssigneeChanged {
|
|||||||
this.util = util;
|
this.util = util;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fire(Change change, Account account, Account oldAssignee, Timestamp when) {
|
public void fire(
|
||||||
|
Change change, AccountState accountState, AccountState oldAssignee, Timestamp when) {
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -47,7 +48,7 @@ public class AssigneeChanged {
|
|||||||
Event event =
|
Event event =
|
||||||
new Event(
|
new Event(
|
||||||
util.changeInfo(change),
|
util.changeInfo(change),
|
||||||
util.accountInfo(account),
|
util.accountInfo(accountState),
|
||||||
util.accountInfo(oldAssignee),
|
util.accountInfo(oldAssignee),
|
||||||
when);
|
when);
|
||||||
for (AssigneeChangedListener l : listeners) {
|
for (AssigneeChangedListener l : listeners) {
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||||
import com.google.gerrit.extensions.events.ChangeAbandonedListener;
|
import com.google.gerrit.extensions.events.ChangeAbandonedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -49,7 +49,7 @@ public class ChangeAbandoned {
|
|||||||
public void fire(
|
public void fire(
|
||||||
Change change,
|
Change change,
|
||||||
PatchSet ps,
|
PatchSet ps,
|
||||||
Account abandoner,
|
AccountState abandoner,
|
||||||
String reason,
|
String reason,
|
||||||
Timestamp when,
|
Timestamp when,
|
||||||
NotifyHandling notifyHandling) {
|
NotifyHandling notifyHandling) {
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||||
import com.google.gerrit.extensions.events.ChangeMergedListener;
|
import com.google.gerrit.extensions.events.ChangeMergedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -47,7 +47,7 @@ public class ChangeMerged {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void fire(
|
public void fire(
|
||||||
Change change, PatchSet ps, Account merger, String newRevisionId, Timestamp when) {
|
Change change, PatchSet ps, AccountState merger, String newRevisionId, Timestamp when) {
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||||
import com.google.gerrit.extensions.events.ChangeRestoredListener;
|
import com.google.gerrit.extensions.events.ChangeRestoredListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -46,7 +46,8 @@ public class ChangeRestored {
|
|||||||
this.util = util;
|
this.util = util;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fire(Change change, PatchSet ps, Account restorer, String reason, Timestamp when) {
|
public void fire(
|
||||||
|
Change change, PatchSet ps, AccountState restorer, String reason, Timestamp when) {
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||||
import com.google.gerrit.extensions.events.CommentAddedListener;
|
import com.google.gerrit.extensions.events.CommentAddedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -51,7 +51,7 @@ public class CommentAdded {
|
|||||||
public void fire(
|
public void fire(
|
||||||
Change change,
|
Change change,
|
||||||
PatchSet ps,
|
PatchSet ps,
|
||||||
Account author,
|
AccountState author,
|
||||||
String comment,
|
String comment,
|
||||||
Map<String, Short> approvals,
|
Map<String, Short> approvals,
|
||||||
Map<String, Short> oldApprovals,
|
Map<String, Short> oldApprovals,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
|||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.change.ChangeJson;
|
import com.google.gerrit.server.change.ChangeJson;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -93,23 +94,26 @@ public class EventUtil {
|
|||||||
return changeJson.getRevisionInfo(cd, ps);
|
return changeJson.getRevisionInfo(cd, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountInfo accountInfo(Account a) {
|
public AccountInfo accountInfo(AccountState accountState) {
|
||||||
if (a == null || a.getId() == null) {
|
if (accountState == null || accountState.getAccount().getId() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
AccountInfo accountInfo = new AccountInfo(a.getId().get());
|
Account account = accountState.getAccount();
|
||||||
accountInfo.email = a.getPreferredEmail();
|
AccountInfo accountInfo = new AccountInfo(account.getId().get());
|
||||||
accountInfo.name = a.getFullName();
|
accountInfo.email = account.getPreferredEmail();
|
||||||
accountInfo.username = a.getUserName();
|
accountInfo.name = account.getFullName();
|
||||||
|
accountInfo.username = accountState.getUserName();
|
||||||
return accountInfo;
|
return accountInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, ApprovalInfo> approvals(
|
public Map<String, ApprovalInfo> approvals(
|
||||||
Account a, Map<String, Short> approvals, Timestamp ts) {
|
AccountState accountState, Map<String, Short> approvals, Timestamp ts) {
|
||||||
Map<String, ApprovalInfo> result = new HashMap<>();
|
Map<String, ApprovalInfo> result = new HashMap<>();
|
||||||
for (Map.Entry<String, Short> e : approvals.entrySet()) {
|
for (Map.Entry<String, Short> e : approvals.entrySet()) {
|
||||||
Integer value = e.getValue() != null ? Integer.valueOf(e.getValue()) : null;
|
Integer value = e.getValue() != null ? Integer.valueOf(e.getValue()) : null;
|
||||||
result.put(e.getKey(), ChangeJson.getApprovalInfo(a.getId(), value, null, null, ts));
|
result.put(
|
||||||
|
e.getKey(),
|
||||||
|
ChangeJson.getApprovalInfo(accountState.getAccount().getId(), value, null, null, ts));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
|||||||
import com.google.gerrit.extensions.common.AccountInfo;
|
import com.google.gerrit.extensions.common.AccountInfo;
|
||||||
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.eclipse.jgit.lib.BatchRefUpdate;
|
import org.eclipse.jgit.lib.BatchRefUpdate;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
@@ -34,10 +34,10 @@ public class GitReferenceUpdated {
|
|||||||
Project.NameKey project,
|
Project.NameKey project,
|
||||||
RefUpdate refUpdate,
|
RefUpdate refUpdate,
|
||||||
ReceiveCommand.Type type,
|
ReceiveCommand.Type type,
|
||||||
Account updater) {}
|
AccountState updater) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fire(Project.NameKey project, RefUpdate refUpdate, Account updater) {}
|
public void fire(Project.NameKey project, RefUpdate refUpdate, AccountState updater) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fire(
|
public void fire(
|
||||||
@@ -45,13 +45,14 @@ public class GitReferenceUpdated {
|
|||||||
String ref,
|
String ref,
|
||||||
ObjectId oldObjectId,
|
ObjectId oldObjectId,
|
||||||
ObjectId newObjectId,
|
ObjectId newObjectId,
|
||||||
Account updater) {}
|
AccountState updater) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fire(Project.NameKey project, ReceiveCommand cmd, Account updater) {}
|
public void fire(Project.NameKey project, ReceiveCommand cmd, AccountState updater) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fire(Project.NameKey project, BatchRefUpdate batchRefUpdate, Account updater) {}
|
public void fire(
|
||||||
|
Project.NameKey project, BatchRefUpdate batchRefUpdate, AccountState updater) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final DynamicSet<GitReferenceUpdatedListener> listeners;
|
private final DynamicSet<GitReferenceUpdatedListener> listeners;
|
||||||
@@ -69,7 +70,10 @@ public class GitReferenceUpdated {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void fire(
|
public void fire(
|
||||||
Project.NameKey project, RefUpdate refUpdate, ReceiveCommand.Type type, Account updater) {
|
Project.NameKey project,
|
||||||
|
RefUpdate refUpdate,
|
||||||
|
ReceiveCommand.Type type,
|
||||||
|
AccountState updater) {
|
||||||
fire(
|
fire(
|
||||||
project,
|
project,
|
||||||
refUpdate.getName(),
|
refUpdate.getName(),
|
||||||
@@ -79,7 +83,7 @@ public class GitReferenceUpdated {
|
|||||||
util.accountInfo(updater));
|
util.accountInfo(updater));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fire(Project.NameKey project, RefUpdate refUpdate, Account updater) {
|
public void fire(Project.NameKey project, RefUpdate refUpdate, AccountState updater) {
|
||||||
fire(
|
fire(
|
||||||
project,
|
project,
|
||||||
refUpdate.getName(),
|
refUpdate.getName(),
|
||||||
@@ -94,7 +98,7 @@ public class GitReferenceUpdated {
|
|||||||
String ref,
|
String ref,
|
||||||
ObjectId oldObjectId,
|
ObjectId oldObjectId,
|
||||||
ObjectId newObjectId,
|
ObjectId newObjectId,
|
||||||
Account updater) {
|
AccountState updater) {
|
||||||
fire(
|
fire(
|
||||||
project,
|
project,
|
||||||
ref,
|
ref,
|
||||||
@@ -104,7 +108,7 @@ public class GitReferenceUpdated {
|
|||||||
util.accountInfo(updater));
|
util.accountInfo(updater));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fire(Project.NameKey project, ReceiveCommand cmd, Account updater) {
|
public void fire(Project.NameKey project, ReceiveCommand cmd, AccountState updater) {
|
||||||
fire(
|
fire(
|
||||||
project,
|
project,
|
||||||
cmd.getRefName(),
|
cmd.getRefName(),
|
||||||
@@ -114,7 +118,7 @@ public class GitReferenceUpdated {
|
|||||||
util.accountInfo(updater));
|
util.accountInfo(updater));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fire(Project.NameKey project, BatchRefUpdate batchRefUpdate, Account updater) {
|
public void fire(Project.NameKey project, BatchRefUpdate batchRefUpdate, AccountState updater) {
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import com.google.gerrit.extensions.common.AccountInfo;
|
|||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
import com.google.gerrit.extensions.events.HashtagsEditedListener;
|
import com.google.gerrit.extensions.events.HashtagsEditedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@@ -44,7 +44,7 @@ public class HashtagsEdited {
|
|||||||
|
|
||||||
public void fire(
|
public void fire(
|
||||||
Change change,
|
Change change,
|
||||||
Account editor,
|
AccountState editor,
|
||||||
ImmutableSortedSet<String> hashtags,
|
ImmutableSortedSet<String> hashtags,
|
||||||
Set<String> added,
|
Set<String> added,
|
||||||
Set<String> removed,
|
Set<String> removed,
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import com.google.gerrit.extensions.common.AccountInfo;
|
|||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
import com.google.gerrit.extensions.events.PrivateStateChangedListener;
|
import com.google.gerrit.extensions.events.PrivateStateChangedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@@ -39,8 +39,7 @@ public class PrivateStateChanged {
|
|||||||
this.util = util;
|
this.util = util;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fire(Change change, Account account, Timestamp when) {
|
public void fire(Change change, AccountState account, Timestamp when) {
|
||||||
|
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||||
import com.google.gerrit.extensions.events.ReviewerAddedListener;
|
import com.google.gerrit.extensions.events.ReviewerAddedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -49,7 +49,11 @@ public class ReviewerAdded {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void fire(
|
public void fire(
|
||||||
Change change, PatchSet patchSet, List<Account> reviewers, Account adder, Timestamp when) {
|
Change change,
|
||||||
|
PatchSet patchSet,
|
||||||
|
List<AccountState> reviewers,
|
||||||
|
AccountState adder,
|
||||||
|
Timestamp when) {
|
||||||
if (!listeners.iterator().hasNext() || reviewers.isEmpty()) {
|
if (!listeners.iterator().hasNext() || reviewers.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||||
import com.google.gerrit.extensions.events.ReviewerDeletedListener;
|
import com.google.gerrit.extensions.events.ReviewerDeletedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -51,8 +51,8 @@ public class ReviewerDeleted {
|
|||||||
public void fire(
|
public void fire(
|
||||||
Change change,
|
Change change,
|
||||||
PatchSet patchSet,
|
PatchSet patchSet,
|
||||||
Account reviewer,
|
AccountState reviewer,
|
||||||
Account remover,
|
AccountState remover,
|
||||||
String message,
|
String message,
|
||||||
Map<String, Short> newApprovals,
|
Map<String, Short> newApprovals,
|
||||||
Map<String, Short> oldApprovals,
|
Map<String, Short> oldApprovals,
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||||
import com.google.gerrit.extensions.events.RevisionCreatedListener;
|
import com.google.gerrit.extensions.events.RevisionCreatedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -47,7 +47,11 @@ public class RevisionCreated {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void fire(
|
public void fire(
|
||||||
Change change, PatchSet patchSet, Account uploader, Timestamp when, NotifyHandling notify) {
|
Change change,
|
||||||
|
PatchSet patchSet,
|
||||||
|
AccountState uploader,
|
||||||
|
Timestamp when,
|
||||||
|
NotifyHandling notify) {
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import com.google.gerrit.extensions.common.AccountInfo;
|
|||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
import com.google.gerrit.extensions.events.TopicEditedListener;
|
import com.google.gerrit.extensions.events.TopicEditedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@@ -39,7 +39,7 @@ public class TopicEdited {
|
|||||||
this.util = util;
|
this.util = util;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fire(Change change, Account account, String oldTopicName, Timestamp when) {
|
public void fire(Change change, AccountState account, String oldTopicName, Timestamp when) {
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||||
import com.google.gerrit.extensions.events.VoteDeletedListener;
|
import com.google.gerrit.extensions.events.VoteDeletedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -51,12 +51,12 @@ public class VoteDeleted {
|
|||||||
public void fire(
|
public void fire(
|
||||||
Change change,
|
Change change,
|
||||||
PatchSet ps,
|
PatchSet ps,
|
||||||
Account reviewer,
|
AccountState reviewer,
|
||||||
Map<String, Short> approvals,
|
Map<String, Short> approvals,
|
||||||
Map<String, Short> oldApprovals,
|
Map<String, Short> oldApprovals,
|
||||||
NotifyHandling notify,
|
NotifyHandling notify,
|
||||||
String message,
|
String message,
|
||||||
Account remover,
|
AccountState remover,
|
||||||
Timestamp when) {
|
Timestamp when) {
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import com.google.gerrit.extensions.common.AccountInfo;
|
|||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
import com.google.gerrit.extensions.events.WorkInProgressStateChangedListener;
|
import com.google.gerrit.extensions.events.WorkInProgressStateChangedListener;
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@@ -40,8 +40,7 @@ public class WorkInProgressStateChanged {
|
|||||||
this.util = util;
|
this.util = util;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fire(Change change, Account account, Timestamp when) {
|
public void fire(Change change, AccountState account, Timestamp when) {
|
||||||
|
|
||||||
if (!listeners.iterator().hasNext()) {
|
if (!listeners.iterator().hasNext()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,6 +262,6 @@ public class MetaDataUpdate implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void fireGitRefUpdatedEvent(RefUpdate ru) {
|
protected void fireGitRefUpdatedEvent(RefUpdate ru) {
|
||||||
gitRefUpdated.fire(projectName, ru, author == null ? null : author.getAccount());
|
gitRefUpdated.fire(projectName, ru, author == null ? null : author.state());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
|||||||
try {
|
try {
|
||||||
ReplacePatchSetSender cm =
|
ReplacePatchSetSender cm =
|
||||||
replacePatchSetFactory.create(projectState.getNameKey(), notes.getChangeId());
|
replacePatchSetFactory.create(projectState.getNameKey(), notes.getChangeId());
|
||||||
cm.setFrom(ctx.getAccount().getId());
|
cm.setFrom(ctx.getAccount().getAccount().getId());
|
||||||
cm.setPatchSet(newPatchSet, info);
|
cm.setPatchSet(newPatchSet, info);
|
||||||
cm.setChangeMessage(msg.getMessage(), ctx.getWhen());
|
cm.setChangeMessage(msg.getMessage(), ctx.getWhen());
|
||||||
if (magicBranch != null) {
|
if (magicBranch != null) {
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp {
|
|||||||
args.changeMerged.fire(
|
args.changeMerged.fire(
|
||||||
updatedChange,
|
updatedChange,
|
||||||
mergedPatchSet,
|
mergedPatchSet,
|
||||||
args.accountCache.get(submitter.getAccountId()).getAccount(),
|
args.accountCache.get(submitter.getAccountId()),
|
||||||
args.mergeTip.getCurrentTip().name(),
|
args.mergeTip.getCurrentTip().name(),
|
||||||
ctx.getWhen());
|
ctx.getWhen());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -612,7 +612,7 @@ public class GroupsUpdate {
|
|||||||
|
|
||||||
RefUpdateUtil.executeChecked(batchRefUpdate, allUsersRepo);
|
RefUpdateUtil.executeChecked(batchRefUpdate, allUsersRepo);
|
||||||
gitRefUpdated.fire(
|
gitRefUpdated.fire(
|
||||||
allUsersName, batchRefUpdate, currentUser != null ? currentUser.getAccount() : null);
|
allUsersName, batchRefUpdate, currentUser != null ? currentUser.state() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCachesOnGroupCreation(InternalGroup createdGroup) throws IOException {
|
private void updateCachesOnGroupCreation(InternalGroup createdGroup) throws IOException {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import com.google.gerrit.extensions.auth.oauth.OAuthToken;
|
|||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.account.AccountResource;
|
import com.google.gerrit.server.account.AccountResource;
|
||||||
import com.google.gerrit.server.auth.oauth.OAuthTokenCache;
|
import com.google.gerrit.server.auth.oauth.OAuthTokenCache;
|
||||||
@@ -57,13 +56,12 @@ class GetOAuthToken implements RestReadView<AccountResource> {
|
|||||||
if (self.get() != rsrc.getUser()) {
|
if (self.get() != rsrc.getUser()) {
|
||||||
throw new AuthException("not allowed to get access token");
|
throw new AuthException("not allowed to get access token");
|
||||||
}
|
}
|
||||||
Account a = rsrc.getUser().getAccount();
|
OAuthToken accessToken = tokenCache.get(rsrc.getUser().getAccountId());
|
||||||
OAuthToken accessToken = tokenCache.get(a.getId());
|
|
||||||
if (accessToken == null) {
|
if (accessToken == null) {
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
}
|
}
|
||||||
OAuthTokenInfo accessTokenInfo = new OAuthTokenInfo();
|
OAuthTokenInfo accessTokenInfo = new OAuthTokenInfo();
|
||||||
accessTokenInfo.username = a.getUserName();
|
accessTokenInfo.username = rsrc.getUser().state().getUserName();
|
||||||
accessTokenInfo.resourceHost = getHostName(canonicalWebUrlProvider.get());
|
accessTokenInfo.resourceHost = getHostName(canonicalWebUrlProvider.get());
|
||||||
accessTokenInfo.accessToken = accessToken.getToken();
|
accessTokenInfo.accessToken = accessToken.getToken();
|
||||||
accessTokenInfo.providerId = accessToken.getProviderId();
|
accessTokenInfo.providerId = accessToken.getProviderId();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class GetUsername implements RestReadView<AccountResource> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apply(AccountResource rsrc) throws AuthException, ResourceNotFoundException {
|
public String apply(AccountResource rsrc) throws AuthException, ResourceNotFoundException {
|
||||||
String username = rsrc.getUser().getAccount().getUserName();
|
String username = rsrc.getUser().state().getUserName();
|
||||||
if (username == null) {
|
if (username == null) {
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ import com.google.gerrit.extensions.restapi.Response;
|
|||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.account.AccountResource;
|
import com.google.gerrit.server.account.AccountResource;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.extensions.events.AgreementSignup;
|
import com.google.gerrit.server.extensions.events.AgreementSignup;
|
||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
@@ -92,13 +92,13 @@ public class PutAgreement implements RestModifyView<AccountResource, AgreementIn
|
|||||||
throw new ResourceConflictException("autoverify group uuid not found");
|
throw new ResourceConflictException("autoverify group uuid not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
Account account = self.get().getAccount();
|
AccountState accountState = self.get().state();
|
||||||
try {
|
try {
|
||||||
addMembers.addMembers(uuid, ImmutableSet.of(account.getId()));
|
addMembers.addMembers(uuid, ImmutableSet.of(accountState.getAccount().getId()));
|
||||||
} catch (NoSuchGroupException e) {
|
} catch (NoSuchGroupException e) {
|
||||||
throw new ResourceConflictException("autoverify group not found");
|
throw new ResourceConflictException("autoverify group not found");
|
||||||
}
|
}
|
||||||
agreementSignup.fire(account, agreementName);
|
agreementSignup.fire(accountState, agreementName);
|
||||||
|
|
||||||
return Response.ok(agreementName);
|
return Response.ok(agreementName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.google.gerrit.reviewdb.client.Account;
|
|||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.change.AbandonOp;
|
import com.google.gerrit.server.change.AbandonOp;
|
||||||
import com.google.gerrit.server.change.ChangeJson;
|
import com.google.gerrit.server.change.ChangeJson;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
@@ -123,8 +124,8 @@ public class Abandon extends RetryingRestModifyView<ChangeResource, AbandonInput
|
|||||||
NotifyHandling notifyHandling,
|
NotifyHandling notifyHandling,
|
||||||
ListMultimap<RecipientType, Account.Id> accountsToNotify)
|
ListMultimap<RecipientType, Account.Id> accountsToNotify)
|
||||||
throws RestApiException, UpdateException {
|
throws RestApiException, UpdateException {
|
||||||
Account account = user.isIdentifiedUser() ? user.asIdentifiedUser().getAccount() : null;
|
AccountState accountState = user.isIdentifiedUser() ? user.asIdentifiedUser().state() : null;
|
||||||
AbandonOp op = abandonOpFactory.create(account, msgTxt, notifyHandling, accountsToNotify);
|
AbandonOp op = abandonOpFactory.create(accountState, msgTxt, notifyHandling, accountsToNotify);
|
||||||
try (BatchUpdate u =
|
try (BatchUpdate u =
|
||||||
updateFactory.create(dbProvider.get(), notes.getProjectName(), user, TimeUtil.nowTs())) {
|
updateFactory.create(dbProvider.get(), notes.getProjectName(), user, TimeUtil.nowTs())) {
|
||||||
u.addOp(notes.getChangeId(), op).execute();
|
u.addOp(notes.getChangeId(), op).execute();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
|||||||
import com.google.gerrit.server.ChangeMessagesUtil;
|
import com.google.gerrit.server.ChangeMessagesUtil;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.account.AccountLoader;
|
import com.google.gerrit.server.account.AccountLoader;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.extensions.events.AssigneeChanged;
|
import com.google.gerrit.server.extensions.events.AssigneeChanged;
|
||||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||||
@@ -89,7 +90,7 @@ public class DeleteAssignee
|
|||||||
|
|
||||||
private class Op implements BatchUpdateOp {
|
private class Op implements BatchUpdateOp {
|
||||||
private Change change;
|
private Change change;
|
||||||
private Account deletedAssignee;
|
private AccountState deletedAssignee;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx) throws RestApiException, OrmException {
|
public boolean updateChange(ChangeContext ctx) throws RestApiException, OrmException {
|
||||||
@@ -100,7 +101,7 @@ public class DeleteAssignee
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IdentifiedUser deletedAssigneeUser = userFactory.create(currentAssigneeId);
|
IdentifiedUser deletedAssigneeUser = userFactory.create(currentAssigneeId);
|
||||||
deletedAssignee = deletedAssigneeUser.getAccount();
|
deletedAssignee = deletedAssigneeUser.state();
|
||||||
// noteDb
|
// noteDb
|
||||||
update.removeAssignee();
|
update.removeAssignee();
|
||||||
// reviewDb
|
// reviewDb
|
||||||
@@ -110,7 +111,7 @@ public class DeleteAssignee
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Account.Id getDeletedAssignee() {
|
public Account.Id getDeletedAssignee() {
|
||||||
return deletedAssignee != null ? deletedAssignee.getId() : null;
|
return deletedAssignee != null ? deletedAssignee.getAccount().getId() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMessage(ChangeContext ctx, ChangeUpdate update, IdentifiedUser deletedAssignee)
|
private void addMessage(ChangeContext ctx, ChangeUpdate update, IdentifiedUser deletedAssignee)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class DeleteReviewer
|
|||||||
if (rsrc.isByEmail()) {
|
if (rsrc.isByEmail()) {
|
||||||
op = deleteReviewerByEmailOpFactory.create(rsrc.getReviewerByEmail(), input);
|
op = deleteReviewerByEmailOpFactory.create(rsrc.getReviewerByEmail(), input);
|
||||||
} else {
|
} else {
|
||||||
op = deleteReviewerOpFactory.create(rsrc.getReviewerUser().getAccount(), input);
|
op = deleteReviewerOpFactory.create(rsrc.getReviewerUser().state(), input);
|
||||||
}
|
}
|
||||||
bu.addOp(rsrc.getChange().getId(), op);
|
bu.addOp(rsrc.getChange().getId(), op);
|
||||||
bu.execute();
|
bu.execute();
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.google.gerrit.server.ApprovalsUtil;
|
|||||||
import com.google.gerrit.server.ChangeMessagesUtil;
|
import com.google.gerrit.server.ChangeMessagesUtil;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.PatchSetUtil;
|
import com.google.gerrit.server.PatchSetUtil;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.change.NotifyUtil;
|
import com.google.gerrit.server.change.NotifyUtil;
|
||||||
import com.google.gerrit.server.extensions.events.ReviewerDeleted;
|
import com.google.gerrit.server.extensions.events.ReviewerDeleted;
|
||||||
import com.google.gerrit.server.mail.send.DeleteReviewerSender;
|
import com.google.gerrit.server.mail.send.DeleteReviewerSender;
|
||||||
@@ -63,7 +64,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(DeleteReviewerOp.class);
|
private static final Logger log = LoggerFactory.getLogger(DeleteReviewerOp.class);
|
||||||
|
|
||||||
public interface Factory {
|
public interface Factory {
|
||||||
DeleteReviewerOp create(Account reviewerAccount, DeleteReviewerInput input);
|
DeleteReviewerOp create(AccountState reviewerAccount, DeleteReviewerInput input);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ApprovalsUtil approvalsUtil;
|
private final ApprovalsUtil approvalsUtil;
|
||||||
@@ -78,7 +79,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
|||||||
private final RemoveReviewerControl removeReviewerControl;
|
private final RemoveReviewerControl removeReviewerControl;
|
||||||
private final ProjectCache projectCache;
|
private final ProjectCache projectCache;
|
||||||
|
|
||||||
private final Account reviewer;
|
private final AccountState reviewer;
|
||||||
private final DeleteReviewerInput input;
|
private final DeleteReviewerInput input;
|
||||||
|
|
||||||
ChangeMessage changeMessage;
|
ChangeMessage changeMessage;
|
||||||
@@ -100,7 +101,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
|||||||
NotifyUtil notifyUtil,
|
NotifyUtil notifyUtil,
|
||||||
RemoveReviewerControl removeReviewerControl,
|
RemoveReviewerControl removeReviewerControl,
|
||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
@Assisted Account reviewerAccount,
|
@Assisted AccountState reviewerAccount,
|
||||||
@Assisted DeleteReviewerInput input) {
|
@Assisted DeleteReviewerInput input) {
|
||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
this.psUtil = psUtil;
|
this.psUtil = psUtil;
|
||||||
@@ -121,7 +122,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
|||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx)
|
||||||
throws AuthException, ResourceNotFoundException, OrmException, PermissionBackendException,
|
throws AuthException, ResourceNotFoundException, OrmException, PermissionBackendException,
|
||||||
IOException {
|
IOException {
|
||||||
Account.Id reviewerId = reviewer.getId();
|
Account.Id reviewerId = reviewer.getAccount().getId();
|
||||||
// Check of removing this reviewer (even if there is no vote processed by the loop below) is OK
|
// Check of removing this reviewer (even if there is no vote processed by the loop below) is OK
|
||||||
removeReviewerControl.checkRemoveReviewer(ctx.getNotes(), ctx.getUser(), reviewerId);
|
removeReviewerControl.checkRemoveReviewer(ctx.getNotes(), ctx.getUser(), reviewerId);
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
msg.append("Removed reviewer " + reviewer.getFullName());
|
msg.append("Removed reviewer " + reviewer.getAccount().getFullName());
|
||||||
StringBuilder removedVotesMsg = new StringBuilder();
|
StringBuilder removedVotesMsg = new StringBuilder();
|
||||||
removedVotesMsg.append(" with the following votes:\n\n");
|
removedVotesMsg.append(" with the following votes:\n\n");
|
||||||
List<PatchSetApproval> del = new ArrayList<>();
|
List<PatchSetApproval> del = new ArrayList<>();
|
||||||
@@ -234,14 +235,14 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
|||||||
private void emailReviewers(
|
private void emailReviewers(
|
||||||
Project.NameKey projectName, Change change, ChangeMessage changeMessage) {
|
Project.NameKey projectName, Change change, ChangeMessage changeMessage) {
|
||||||
Account.Id userId = user.get().getAccountId();
|
Account.Id userId = user.get().getAccountId();
|
||||||
if (userId.equals(reviewer.getId())) {
|
if (userId.equals(reviewer.getAccount().getId())) {
|
||||||
// The user knows they removed themselves, don't bother emailing them.
|
// The user knows they removed themselves, don't bother emailing them.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeleteReviewerSender cm = deleteReviewerSenderFactory.create(projectName, change.getId());
|
DeleteReviewerSender cm = deleteReviewerSenderFactory.create(projectName, change.getId());
|
||||||
cm.setFrom(userId);
|
cm.setFrom(userId);
|
||||||
cm.addReviewers(Collections.singleton(reviewer.getId()));
|
cm.addReviewers(Collections.singleton(reviewer.getAccount().getId()));
|
||||||
cm.setChangeMessage(changeMessage.getMessage(), changeMessage.getWrittenOn());
|
cm.setChangeMessage(changeMessage.getMessage(), changeMessage.getWrittenOn());
|
||||||
cm.setNotify(input.notify);
|
cm.setNotify(input.notify);
|
||||||
cm.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
|
cm.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.google.gerrit.server.ApprovalsUtil;
|
|||||||
import com.google.gerrit.server.ChangeMessagesUtil;
|
import com.google.gerrit.server.ChangeMessagesUtil;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.PatchSetUtil;
|
import com.google.gerrit.server.PatchSetUtil;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.change.NotifyUtil;
|
import com.google.gerrit.server.change.NotifyUtil;
|
||||||
import com.google.gerrit.server.change.ReviewerResource;
|
import com.google.gerrit.server.change.ReviewerResource;
|
||||||
import com.google.gerrit.server.change.VoteResource;
|
import com.google.gerrit.server.change.VoteResource;
|
||||||
@@ -134,7 +135,7 @@ public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteI
|
|||||||
change.getId(),
|
change.getId(),
|
||||||
new Op(
|
new Op(
|
||||||
projectCache.checkedGet(r.getChange().getProject()),
|
projectCache.checkedGet(r.getChange().getProject()),
|
||||||
r.getReviewerUser().getAccount(),
|
r.getReviewerUser().state(),
|
||||||
rsrc.getLabel(),
|
rsrc.getLabel(),
|
||||||
input));
|
input));
|
||||||
bu.execute();
|
bu.execute();
|
||||||
@@ -145,7 +146,7 @@ public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteI
|
|||||||
|
|
||||||
private class Op implements BatchUpdateOp {
|
private class Op implements BatchUpdateOp {
|
||||||
private final ProjectState projectState;
|
private final ProjectState projectState;
|
||||||
private final Account account;
|
private final AccountState accountState;
|
||||||
private final String label;
|
private final String label;
|
||||||
private final DeleteVoteInput input;
|
private final DeleteVoteInput input;
|
||||||
|
|
||||||
@@ -155,9 +156,10 @@ public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteI
|
|||||||
private Map<String, Short> newApprovals = new HashMap<>();
|
private Map<String, Short> newApprovals = new HashMap<>();
|
||||||
private Map<String, Short> oldApprovals = new HashMap<>();
|
private Map<String, Short> oldApprovals = new HashMap<>();
|
||||||
|
|
||||||
private Op(ProjectState projectState, Account account, String label, DeleteVoteInput input) {
|
private Op(
|
||||||
|
ProjectState projectState, AccountState accountState, String label, DeleteVoteInput input) {
|
||||||
this.projectState = projectState;
|
this.projectState = projectState;
|
||||||
this.account = account;
|
this.accountState = accountState;
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.input = input;
|
this.input = input;
|
||||||
}
|
}
|
||||||
@@ -173,13 +175,15 @@ public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteI
|
|||||||
boolean found = false;
|
boolean found = false;
|
||||||
LabelTypes labelTypes = projectState.getLabelTypes(ctx.getNotes(), ctx.getUser());
|
LabelTypes labelTypes = projectState.getLabelTypes(ctx.getNotes(), ctx.getUser());
|
||||||
|
|
||||||
|
Account.Id accountId = accountState.getAccount().getId();
|
||||||
|
|
||||||
for (PatchSetApproval a :
|
for (PatchSetApproval a :
|
||||||
approvalsUtil.byPatchSetUser(
|
approvalsUtil.byPatchSetUser(
|
||||||
ctx.getDb(),
|
ctx.getDb(),
|
||||||
ctx.getNotes(),
|
ctx.getNotes(),
|
||||||
ctx.getUser(),
|
ctx.getUser(),
|
||||||
psId,
|
psId,
|
||||||
account.getId(),
|
accountId,
|
||||||
ctx.getRevWalk(),
|
ctx.getRevWalk(),
|
||||||
ctx.getRepoView().getConfig())) {
|
ctx.getRepoView().getConfig())) {
|
||||||
if (labelTypes.byLabel(a.getLabelId()) == null) {
|
if (labelTypes.byLabel(a.getLabelId()) == null) {
|
||||||
@@ -207,13 +211,13 @@ public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteI
|
|||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.getUpdate(psId).removeApprovalFor(account.getId(), label);
|
ctx.getUpdate(psId).removeApprovalFor(accountId, label);
|
||||||
ctx.getDb().patchSetApprovals().upsert(Collections.singleton(deletedApproval(ctx)));
|
ctx.getDb().patchSetApprovals().upsert(Collections.singleton(deletedApproval(ctx)));
|
||||||
|
|
||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
msg.append("Removed ");
|
msg.append("Removed ");
|
||||||
LabelVote.appendTo(msg, label, checkNotNull(oldApprovals.get(label)));
|
LabelVote.appendTo(msg, label, checkNotNull(oldApprovals.get(label)));
|
||||||
msg.append(" by ").append(userFactory.create(account.getId()).getNameEmail()).append("\n");
|
msg.append(" by ").append(userFactory.create(accountId).getNameEmail()).append("\n");
|
||||||
changeMessage =
|
changeMessage =
|
||||||
ChangeMessagesUtil.newMessage(ctx, msg.toString(), ChangeMessagesUtil.TAG_DELETE_VOTE);
|
ChangeMessagesUtil.newMessage(ctx, msg.toString(), ChangeMessagesUtil.TAG_DELETE_VOTE);
|
||||||
cmUtil.addChangeMessage(ctx.getDb(), ctx.getUpdate(psId), changeMessage);
|
cmUtil.addChangeMessage(ctx.getDb(), ctx.getUpdate(psId), changeMessage);
|
||||||
@@ -226,7 +230,8 @@ public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteI
|
|||||||
// set the real user; this preserves the calling user as the NoteDb
|
// set the real user; this preserves the calling user as the NoteDb
|
||||||
// committer.
|
// committer.
|
||||||
return new PatchSetApproval(
|
return new PatchSetApproval(
|
||||||
new PatchSetApproval.Key(ps.getId(), account.getId(), new LabelId(label)),
|
new PatchSetApproval.Key(
|
||||||
|
ps.getId(), accountState.getAccount().getId(), new LabelId(label)),
|
||||||
(short) 0,
|
(short) 0,
|
||||||
ctx.getWhen());
|
ctx.getWhen());
|
||||||
}
|
}
|
||||||
@@ -254,12 +259,12 @@ public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteI
|
|||||||
voteDeleted.fire(
|
voteDeleted.fire(
|
||||||
change,
|
change,
|
||||||
ps,
|
ps,
|
||||||
account,
|
accountState,
|
||||||
newApprovals,
|
newApprovals,
|
||||||
oldApprovals,
|
oldApprovals,
|
||||||
input.notify,
|
input.notify,
|
||||||
changeMessage.getMessage(),
|
changeMessage.getMessage(),
|
||||||
user.getAccount(),
|
user.state(),
|
||||||
ctx.getWhen());
|
ctx.getWhen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -873,7 +873,7 @@ public class PostReview
|
|||||||
commentAdded.fire(
|
commentAdded.fire(
|
||||||
notes.getChange(),
|
notes.getChange(),
|
||||||
ps,
|
ps,
|
||||||
user.getAccount(),
|
user.state(),
|
||||||
message.getMessage(),
|
message.getMessage(),
|
||||||
approvals,
|
approvals,
|
||||||
oldApprovals,
|
oldApprovals,
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.google.gerrit.server.ApprovalsUtil;
|
|||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.PatchSetUtil;
|
import com.google.gerrit.server.PatchSetUtil;
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
import com.google.gerrit.server.account.AccountCache;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.extensions.events.ReviewerAdded;
|
import com.google.gerrit.server.extensions.events.ReviewerAdded;
|
||||||
import com.google.gerrit.server.mail.Address;
|
import com.google.gerrit.server.mail.Address;
|
||||||
@@ -202,11 +203,8 @@ public class PostReviewersOp implements BatchUpdateOp {
|
|||||||
notify,
|
notify,
|
||||||
accountsToNotify);
|
accountsToNotify);
|
||||||
if (!addedReviewers.isEmpty()) {
|
if (!addedReviewers.isEmpty()) {
|
||||||
List<Account> reviewers =
|
List<AccountState> reviewers =
|
||||||
addedReviewers
|
addedReviewers.stream().map(r -> accountCache.get(r.getAccountId())).collect(toList());
|
||||||
.stream()
|
|
||||||
.map(r -> accountCache.get(r.getAccountId()).getAccount())
|
|
||||||
.collect(toList());
|
|
||||||
reviewerAdded.fire(rsrc.getChange(), patchSet, reviewers, ctx.getAccount(), ctx.getWhen());
|
reviewerAdded.fire(rsrc.getChange(), patchSet, reviewers, ctx.getAccount(), ctx.getWhen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,10 +141,7 @@ public class CreateBranch implements RestModifyView<ProjectResource, BranchInput
|
|||||||
case NEW:
|
case NEW:
|
||||||
case NO_CHANGE:
|
case NO_CHANGE:
|
||||||
referenceUpdated.fire(
|
referenceUpdated.fire(
|
||||||
name.getParentKey(),
|
name.getParentKey(), u, ReceiveCommand.Type.CREATE, identifiedUser.get().state());
|
||||||
u,
|
|
||||||
ReceiveCommand.Type.CREATE,
|
|
||||||
identifiedUser.get().getAccount());
|
|
||||||
break;
|
break;
|
||||||
case LOCK_FAILURE:
|
case LOCK_FAILURE:
|
||||||
if (repo.getRefDatabase().exactRef(ref) != null) {
|
if (repo.getRefDatabase().exactRef(ref) != null) {
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
|||||||
switch (result) {
|
switch (result) {
|
||||||
case NEW:
|
case NEW:
|
||||||
referenceUpdated.fire(
|
referenceUpdated.fire(
|
||||||
project, ru, ReceiveCommand.Type.CREATE, identifiedUser.get().getAccount());
|
project, ru, ReceiveCommand.Type.CREATE, identifiedUser.get().state());
|
||||||
break;
|
break;
|
||||||
case FAST_FORWARD:
|
case FAST_FORWARD:
|
||||||
case FORCED:
|
case FORCED:
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public class CreateTag implements RestModifyView<ProjectResource, TagInput> {
|
|||||||
ref,
|
ref,
|
||||||
ObjectId.zeroId(),
|
ObjectId.zeroId(),
|
||||||
result.getObjectId(),
|
result.getObjectId(),
|
||||||
identifiedUser.get().getAccount());
|
identifiedUser.get().state());
|
||||||
try (RevWalk w = new RevWalk(repo)) {
|
try (RevWalk w = new RevWalk(repo)) {
|
||||||
return ListTags.createTagInfo(perm, result, w, resource.getProjectState(), links);
|
return ListTags.createTagInfo(perm, result, w, resource.getProjectState(), links);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,10 +157,7 @@ public class DeleteRef {
|
|||||||
case FAST_FORWARD:
|
case FAST_FORWARD:
|
||||||
case FORCED:
|
case FORCED:
|
||||||
referenceUpdated.fire(
|
referenceUpdated.fire(
|
||||||
resource.getNameKey(),
|
resource.getNameKey(), u, ReceiveCommand.Type.DELETE, identifiedUser.get().state());
|
||||||
u,
|
|
||||||
ReceiveCommand.Type.DELETE,
|
|
||||||
identifiedUser.get().getAccount());
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REJECTED_CURRENT_BRANCH:
|
case REJECTED_CURRENT_BRANCH:
|
||||||
@@ -280,6 +277,6 @@ public class DeleteRef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void postDeletion(ProjectResource project, ReceiveCommand cmd) {
|
private void postDeletion(ProjectResource project, ReceiveCommand cmd) {
|
||||||
referenceUpdated.fire(project.getNameKey(), cmd, identifiedUser.get().getAccount());
|
referenceUpdated.fire(project.getNameKey(), cmd, identifiedUser.get().state());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ import com.google.gerrit.extensions.config.FactoryModule;
|
|||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
import com.google.gerrit.server.git.validators.OnSubmitValidators;
|
import com.google.gerrit.server.git.validators.OnSubmitValidators;
|
||||||
import com.google.gerrit.server.notedb.NotesMigration;
|
import com.google.gerrit.server.notedb.NotesMigration;
|
||||||
@@ -347,9 +347,9 @@ public abstract class BatchUpdate implements AutoCloseable {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Optional<Account> getAccount() {
|
protected Optional<AccountState> getAccount() {
|
||||||
return user.isIdentifiedUser()
|
return user.isIdentifiedUser()
|
||||||
? Optional.of(user.asIdentifiedUser().getAccount())
|
? Optional.of(user.asIdentifiedUser().state())
|
||||||
: Optional.empty();
|
: Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.google.gerrit.reviewdb.client.Project;
|
|||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
@@ -122,8 +123,8 @@ public interface Context {
|
|||||||
* @see CurrentUser#asIdentifiedUser()
|
* @see CurrentUser#asIdentifiedUser()
|
||||||
* @return account.
|
* @return account.
|
||||||
*/
|
*/
|
||||||
default Account getAccount() {
|
default AccountState getAccount() {
|
||||||
return getIdentifiedUser().getAccount();
|
return getIdentifiedUser().state();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ public abstract class BaseCommand implements Command {
|
|||||||
if (user.isIdentifiedUser()) {
|
if (user.isIdentifiedUser()) {
|
||||||
final IdentifiedUser u = user.asIdentifiedUser();
|
final IdentifiedUser u = user.asIdentifiedUser();
|
||||||
m.append(" (user ");
|
m.append(" (user ");
|
||||||
m.append(u.getAccount().getUserName());
|
m.append(u.state().getUserName());
|
||||||
m.append(" account ");
|
m.append(" account ");
|
||||||
m.append(u.getAccountId());
|
m.append(u.getAccountId());
|
||||||
m.append(")");
|
m.append(")");
|
||||||
@@ -381,7 +381,7 @@ public abstract class BaseCommand implements Command {
|
|||||||
m.append(getTaskDescription());
|
m.append(getTaskDescription());
|
||||||
if (user.isIdentifiedUser()) {
|
if (user.isIdentifiedUser()) {
|
||||||
IdentifiedUser u = user.asIdentifiedUser();
|
IdentifiedUser u = user.asIdentifiedUser();
|
||||||
m.append(" (").append(u.getAccount().getUserName()).append(")");
|
m.append(" (").append(u.state().getUserName()).append(")");
|
||||||
}
|
}
|
||||||
return m.toString();
|
return m.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ class SshLog implements LifecycleListener {
|
|||||||
|
|
||||||
if (user != null && user.isIdentifiedUser()) {
|
if (user != null && user.isIdentifiedUser()) {
|
||||||
IdentifiedUser u = user.asIdentifiedUser();
|
IdentifiedUser u = user.asIdentifiedUser();
|
||||||
userName = u.getAccount().getUserName();
|
userName = u.state().getUserName();
|
||||||
accountId = "a/" + u.getAccountId().toString();
|
accountId = "a/" + u.getAccountId().toString();
|
||||||
|
|
||||||
} else if (user instanceof PeerDaemonUser) {
|
} else if (user instanceof PeerDaemonUser) {
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ final class Receive extends AbstractGitCommand {
|
|||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
msg.append("Receive error on project \"").append(projectState.getName()).append("\"");
|
msg.append("Receive error on project \"").append(projectState.getName()).append("\"");
|
||||||
msg.append(" (user ");
|
msg.append(" (user ");
|
||||||
msg.append(currentUser.getAccount().getUserName());
|
msg.append(currentUser.state().getUserName());
|
||||||
msg.append(" account ");
|
msg.append(" account ");
|
||||||
msg.append(currentUser.getAccountId());
|
msg.append(currentUser.getAccountId());
|
||||||
msg.append("): ");
|
msg.append("): ");
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ final class ShowConnections extends SshCommand {
|
|||||||
IdentifiedUser u = user.asIdentifiedUser();
|
IdentifiedUser u = user.asIdentifiedUser();
|
||||||
|
|
||||||
if (!numeric) {
|
if (!numeric) {
|
||||||
String name = u.getAccount().getUserName();
|
String name = u.state().getUserName();
|
||||||
if (name != null && !name.isEmpty()) {
|
if (name != null && !name.isEmpty()) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ final class StreamEvents extends BaseCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Stream Events (" + currentUser.getAccount().getUserName() + ")";
|
return "Stream Events (" + currentUser.state().getUserName() + ")";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,9 @@ import java.util.Optional;
|
|||||||
/** Fake implementation of {@link AccountCache} for testing. */
|
/** Fake implementation of {@link AccountCache} for testing. */
|
||||||
public class FakeAccountCache implements AccountCache {
|
public class FakeAccountCache implements AccountCache {
|
||||||
private final Map<Account.Id, AccountState> byId;
|
private final Map<Account.Id, AccountState> byId;
|
||||||
private final Map<String, AccountState> byUsername;
|
|
||||||
|
|
||||||
public FakeAccountCache() {
|
public FakeAccountCache() {
|
||||||
byId = new HashMap<>();
|
byId = new HashMap<>();
|
||||||
byUsername = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,7 +49,7 @@ public class FakeAccountCache implements AccountCache {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized Optional<AccountState> getByUsername(String username) {
|
public synchronized Optional<AccountState> getByUsername(String username) {
|
||||||
return Optional.ofNullable(byUsername.get(username));
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -64,15 +62,11 @@ public class FakeAccountCache implements AccountCache {
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void evictAllNoReindex() {
|
public synchronized void evictAllNoReindex() {
|
||||||
byId.clear();
|
byId.clear();
|
||||||
byUsername.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void put(Account account) {
|
public synchronized void put(Account account) {
|
||||||
AccountState state = newState(account);
|
AccountState state = newState(account);
|
||||||
byId.put(account.getId(), state);
|
byId.put(account.getId(), state);
|
||||||
if (account.getUserName() != null) {
|
|
||||||
byUsername.put(account.getUserName(), state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AccountState newState(Account account) {
|
private static AccountState newState(Account account) {
|
||||||
|
|||||||
Reference in New Issue
Block a user