Remove usages of System.currentTimeMillis() from gerrit-reviewdb
Unlike pure server code, reviewdb.client is used from GWT, so we cannot just use joda's DateTimeUtils.currentTimeMillis(). Instead, just introduce arguments where necessary. Passing TimeUtil.nowTs() is a bit cumbersome but usually short enough to type. Change-Id: I87ef09b0920bc36851bca893a2a37348ffc6bf3a
This commit is contained in:
@@ -30,8 +30,10 @@ import com.google.gerrit.server.account.AccountByEmailCache;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.ssh.SshKeyCache;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.SchemaFactory;
|
||||
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.KeyPair;
|
||||
@@ -77,7 +79,7 @@ public class AccountCreator {
|
||||
db.accountExternalIds().insert(Collections.singleton(extMailto));
|
||||
}
|
||||
|
||||
Account a = new Account(id);
|
||||
Account a = new Account(id, TimeUtil.nowTs());
|
||||
a.setFullName(fullName);
|
||||
a.setPreferredEmail(email);
|
||||
db.accounts().insert(Collections.singleton(a));
|
||||
|
@@ -66,6 +66,7 @@ import com.google.gwtorm.client.KeyUtil;
|
||||
|
||||
import org.eclipse.jgit.diff.Edit;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -523,9 +524,10 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
||||
throw new RuntimeException("unexpected file id " + file);
|
||||
}
|
||||
|
||||
final PatchLineComment newComment =
|
||||
new PatchLineComment(new PatchLineComment.Key(parentKey, null),
|
||||
line, Gerrit.getUserAccount().getId(), null);
|
||||
final PatchLineComment newComment = new PatchLineComment(
|
||||
new PatchLineComment.Key(parentKey, null), line,
|
||||
Gerrit.getUserAccount().getId(), null,
|
||||
new Timestamp(System.currentTimeMillis()));
|
||||
newComment.setSide(side);
|
||||
newComment.setMessage("");
|
||||
|
||||
@@ -969,7 +971,8 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
||||
PatchLineComment newComment =
|
||||
new PatchLineComment(new PatchLineComment.Key(comment.getKey()
|
||||
.getParentKey(), null), comment.getLine(), Gerrit
|
||||
.getUserAccount().getId(), comment.getKey().get());
|
||||
.getUserAccount().getId(), comment.getKey().get(),
|
||||
new Timestamp(System.currentTimeMillis()));
|
||||
newComment.setSide(comment.getSide());
|
||||
return newComment;
|
||||
}
|
||||
|
@@ -42,6 +42,7 @@ import com.google.gerrit.server.account.Realm;
|
||||
import com.google.gerrit.server.contact.ContactStore;
|
||||
import com.google.gerrit.server.mail.EmailTokenVerifier;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
||||
import com.google.gwtjsonrpc.common.VoidResult;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
@@ -139,7 +140,7 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||
if (useContactInfo) {
|
||||
if (ContactInformation.hasAddress(info)
|
||||
|| (me.isContactFiled() && ContactInformation.hasData(info))) {
|
||||
me.setContactFiled();
|
||||
me.setContactFiled(TimeUtil.nowTs());
|
||||
}
|
||||
if (ContactInformation.hasData(info)) {
|
||||
try {
|
||||
@@ -198,8 +199,8 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||
if (m == null) {
|
||||
m = new AccountGroupMember(key);
|
||||
db.accountGroupMembersAudit().insert(
|
||||
Collections.singleton(
|
||||
new AccountGroupMemberAudit(m, account.getId())));
|
||||
Collections.singleton(new AccountGroupMemberAudit(
|
||||
m, account.getId(), TimeUtil.nowTs())));
|
||||
db.accountGroupMembers().insert(Collections.singleton(m));
|
||||
accountCache.evict(m.getAccountId());
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -91,8 +92,9 @@ class SaveDraft extends Handler<PatchLineComment> {
|
||||
}
|
||||
|
||||
final PatchLineComment nc =
|
||||
new PatchLineComment(new PatchLineComment.Key(patchKey, ChangeUtil
|
||||
.messageUUID(db)), comment.getLine(), me, comment.getParentUuid());
|
||||
new PatchLineComment(new PatchLineComment.Key(patchKey,
|
||||
ChangeUtil.messageUUID(db)), comment.getLine(), me,
|
||||
comment.getParentUuid(), TimeUtil.nowTs());
|
||||
nc.setSide(comment.getSide());
|
||||
nc.setMessage(comment.getMessage());
|
||||
nc.setRange(comment.getRange());
|
||||
@@ -104,7 +106,7 @@ class SaveDraft extends Handler<PatchLineComment> {
|
||||
if (!me.equals(comment.getAuthor())) {
|
||||
throw new NoSuchChangeException(changeId);
|
||||
}
|
||||
comment.updated();
|
||||
comment.updated(TimeUtil.nowTs());
|
||||
db.patchComments().update(Collections.singleton(comment));
|
||||
db.commit();
|
||||
return comment;
|
||||
|
@@ -37,6 +37,7 @@ import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -105,7 +106,8 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
|
||||
user.getAccountId(),
|
||||
new Branch.NameKey(
|
||||
config.getProject().getNameKey(),
|
||||
GitRepositoryManager.REF_CONFIG));
|
||||
GitRepositoryManager.REF_CONFIG),
|
||||
TimeUtil.nowTs());
|
||||
|
||||
ps.setCreatedOn(change.getCreatedOn());
|
||||
ps.setUploader(change.getOwner());
|
||||
|
@@ -144,10 +144,11 @@ public final class Account {
|
||||
*
|
||||
* @param newId unique id, see
|
||||
* {@link com.google.gerrit.reviewdb.server.ReviewDb#nextAccountId()}.
|
||||
* @param registeredOn when the account was registered.
|
||||
*/
|
||||
public Account(final Account.Id newId) {
|
||||
accountId = newId;
|
||||
registeredOn = new Timestamp(System.currentTimeMillis());
|
||||
public Account(Account.Id newId, Timestamp registeredOn) {
|
||||
this.accountId = newId;
|
||||
this.registeredOn = registeredOn;
|
||||
|
||||
generalPreferences = new AccountGeneralPreferences();
|
||||
generalPreferences.resetToDefaults();
|
||||
@@ -203,8 +204,8 @@ public final class Account {
|
||||
return contactFiledOn;
|
||||
}
|
||||
|
||||
public void setContactFiled() {
|
||||
contactFiledOn = new Timestamp(System.currentTimeMillis());
|
||||
public void setContactFiled(Timestamp ts) {
|
||||
contactFiledOn = ts;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
|
@@ -86,11 +86,6 @@ public final class AccountGroupByIdAud {
|
||||
addedBy = adder;
|
||||
}
|
||||
|
||||
public AccountGroupByIdAud(final AccountGroupById m,
|
||||
final Account.Id adder) {
|
||||
this(m, adder, now());
|
||||
}
|
||||
|
||||
public AccountGroupByIdAud.Key getKey() {
|
||||
return key;
|
||||
}
|
||||
@@ -99,17 +94,8 @@ public final class AccountGroupByIdAud {
|
||||
return removedOn == null;
|
||||
}
|
||||
|
||||
public void removed(final Account.Id deleter) {
|
||||
removedBy = deleter;
|
||||
removedOn = now();
|
||||
}
|
||||
|
||||
public void removed(final Account.Id deleter, final Timestamp when) {
|
||||
removedBy = deleter;
|
||||
removedOn = when;
|
||||
}
|
||||
|
||||
private static Timestamp now() {
|
||||
return new Timestamp(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
@@ -78,11 +78,6 @@ public final class AccountGroupMemberAudit {
|
||||
protected AccountGroupMemberAudit() {
|
||||
}
|
||||
|
||||
public AccountGroupMemberAudit(final AccountGroupMember m,
|
||||
final Account.Id adder) {
|
||||
this(m, adder, now());
|
||||
}
|
||||
|
||||
public AccountGroupMemberAudit(final AccountGroupMember m,
|
||||
final Account.Id adder, Timestamp addedOn) {
|
||||
final Account.Id who = m.getAccountId();
|
||||
@@ -99,17 +94,13 @@ public final class AccountGroupMemberAudit {
|
||||
return removedOn == null;
|
||||
}
|
||||
|
||||
public void removed(final Account.Id deleter) {
|
||||
public void removed(final Account.Id deleter, final Timestamp when) {
|
||||
removedBy = deleter;
|
||||
removedOn = now();
|
||||
removedOn = when;
|
||||
}
|
||||
|
||||
public void removedLegacy() {
|
||||
removedBy = addedBy;
|
||||
removedOn = key.addedOn;
|
||||
}
|
||||
|
||||
private static Timestamp now() {
|
||||
return new Timestamp(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
@@ -388,11 +388,11 @@ public final class Change {
|
||||
protected Change() {
|
||||
}
|
||||
|
||||
public Change(final Change.Key newKey, final Change.Id newId,
|
||||
final Account.Id ownedBy, final Branch.NameKey forBranch) {
|
||||
public Change(Change.Key newKey, Change.Id newId, Account.Id ownedBy,
|
||||
Branch.NameKey forBranch, Timestamp ts) {
|
||||
changeKey = newKey;
|
||||
changeId = newId;
|
||||
createdOn = new Timestamp(System.currentTimeMillis());
|
||||
createdOn = ts;
|
||||
lastUpdatedOn = createdOn;
|
||||
owner = ownedBy;
|
||||
dest = forBranch;
|
||||
@@ -435,10 +435,6 @@ public final class Change {
|
||||
return rowVersion;
|
||||
}
|
||||
|
||||
public void resetLastUpdatedOn() {
|
||||
lastUpdatedOn = new Timestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public String getSortKey() {
|
||||
return sortKey;
|
||||
}
|
||||
|
@@ -77,11 +77,6 @@ public final class ChangeMessage {
|
||||
protected ChangeMessage() {
|
||||
}
|
||||
|
||||
public ChangeMessage(final ChangeMessage.Key k, final Account.Id a,
|
||||
final PatchSet.Id psid) {
|
||||
this(k, a, new Timestamp(System.currentTimeMillis()), psid);
|
||||
}
|
||||
|
||||
public ChangeMessage(final ChangeMessage.Key k, final Account.Id a,
|
||||
final Timestamp wo, final PatchSet.Id psid) {
|
||||
key = k;
|
||||
|
@@ -123,14 +123,14 @@ public final class PatchLineComment {
|
||||
protected PatchLineComment() {
|
||||
}
|
||||
|
||||
public PatchLineComment(final PatchLineComment.Key id, final int line,
|
||||
final Account.Id a, String parentUuid) {
|
||||
public PatchLineComment(PatchLineComment.Key id, int line, Account.Id a,
|
||||
String parentUuid, Timestamp when) {
|
||||
key = id;
|
||||
lineNbr = line;
|
||||
author = a;
|
||||
this.parentUuid = parentUuid;
|
||||
setStatus(Status.DRAFT);
|
||||
updated();
|
||||
updated(when);
|
||||
}
|
||||
|
||||
public PatchLineComment.Key getKey() {
|
||||
@@ -177,8 +177,8 @@ public final class PatchLineComment {
|
||||
message = s;
|
||||
}
|
||||
|
||||
public void updated() {
|
||||
writtenOn = new Timestamp(System.currentTimeMillis());
|
||||
public void updated(Timestamp when) {
|
||||
writtenOn = when;
|
||||
}
|
||||
|
||||
public void setWrittenOn(Timestamp ts) {
|
||||
|
@@ -140,11 +140,11 @@ public final class PatchSetApproval {
|
||||
protected PatchSetApproval() {
|
||||
}
|
||||
|
||||
public PatchSetApproval(final PatchSetApproval.Key k, final short v) {
|
||||
public PatchSetApproval(PatchSetApproval.Key k, short v, Timestamp ts) {
|
||||
key = k;
|
||||
changeOpen = true;
|
||||
setValue(v);
|
||||
setGranted();
|
||||
setGranted(ts);
|
||||
}
|
||||
|
||||
public PatchSetApproval(final PatchSet.Id psId, final PatchSetApproval src) {
|
||||
@@ -183,10 +183,6 @@ public final class PatchSetApproval {
|
||||
return granted;
|
||||
}
|
||||
|
||||
public void setGranted() {
|
||||
granted = new Timestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public void setGranted(Timestamp ts) {
|
||||
granted = ts;
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ import com.google.gerrit.reviewdb.client.PatchSetApproval.LabelId;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.change.PatchSetInserter.ChangeKind;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@@ -136,7 +137,7 @@ public class ApprovalsUtil {
|
||||
for (Account.Id account : need) {
|
||||
PatchSetApproval psa = new PatchSetApproval(
|
||||
new PatchSetApproval.Key(ps.getId(), account, labelId),
|
||||
(short) 0);
|
||||
(short) 0, TimeUtil.nowTs());
|
||||
psa.cache(change);
|
||||
cells.add(psa);
|
||||
}
|
||||
|
@@ -273,7 +273,8 @@ public class ChangeUtil {
|
||||
new Change.Key("I" + computedChangeId.name()),
|
||||
new Change.Id(db.nextChangeId()),
|
||||
user.getAccountId(),
|
||||
changeToRevert.getDest());
|
||||
changeToRevert.getDest(),
|
||||
TimeUtil.nowTs());
|
||||
change.setTopic(changeToRevert.getTopic());
|
||||
ChangeInserter ins =
|
||||
changeInserterFactory.create(refControl, change, revertCommit);
|
||||
@@ -304,9 +305,9 @@ public class ChangeUtil {
|
||||
change.getDest().getParentKey().get(), ru.getResult()));
|
||||
}
|
||||
|
||||
final ChangeMessage cmsg =
|
||||
new ChangeMessage(new ChangeMessage.Key(changeId,
|
||||
ChangeUtil.messageUUID(db)), user.getAccountId(), patchSetId);
|
||||
final ChangeMessage cmsg = new ChangeMessage(
|
||||
new ChangeMessage.Key(changeId, ChangeUtil.messageUUID(db)),
|
||||
user.getAccountId(), TimeUtil.nowTs(), patchSetId);
|
||||
final StringBuilder msgBuf =
|
||||
new StringBuilder("Patch Set " + patchSetId.get() + ": Reverted");
|
||||
msgBuf.append("\n\n");
|
||||
|
@@ -24,6 +24,7 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroupMember;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.cache.CacheModule;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.SchemaFactory;
|
||||
import com.google.inject.Inject;
|
||||
@@ -115,7 +116,7 @@ public class AccountCacheImpl implements AccountCache {
|
||||
}
|
||||
|
||||
private static AccountState missing(Account.Id accountId) {
|
||||
Account account = new Account(accountId);
|
||||
Account account = new Account(accountId, TimeUtil.nowTs());
|
||||
Collection<AccountExternalId> ids = Collections.emptySet();
|
||||
Set<AccountGroup.UUID> anon = ImmutableSet.of(AccountGroup.ANONYMOUS_USERS);
|
||||
return new AccountState(account, anon, ids);
|
||||
|
@@ -29,6 +29,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.SchemaFactory;
|
||||
import com.google.inject.Inject;
|
||||
@@ -258,7 +259,7 @@ public class AccountManager {
|
||||
}
|
||||
|
||||
final Account.Id newId = new Account.Id(db.nextAccountId());
|
||||
final Account account = new Account(newId);
|
||||
final Account account = new Account(newId, TimeUtil.nowTs());
|
||||
final AccountExternalId extId = createId(newId, who);
|
||||
|
||||
extId.setEmailAddress(who.getEmailAddress());
|
||||
@@ -293,8 +294,8 @@ public class AccountManager {
|
||||
final AccountGroup.Id adminId = g.getId();
|
||||
final AccountGroupMember m =
|
||||
new AccountGroupMember(new AccountGroupMember.Key(newId, adminId));
|
||||
db.accountGroupMembersAudit().insert(
|
||||
Collections.singleton(new AccountGroupMemberAudit(m, newId)));
|
||||
db.accountGroupMembersAudit().insert(Collections.singleton(
|
||||
new AccountGroupMemberAudit(m, newId, TimeUtil.nowTs())));
|
||||
db.accountGroupMembers().insert(Collections.singleton(m));
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.CreateAccount.Input;
|
||||
import com.google.gerrit.server.group.GroupsCollection;
|
||||
import com.google.gerrit.server.ssh.SshKeyCache;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
@@ -149,7 +150,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, Input> {
|
||||
}
|
||||
}
|
||||
|
||||
Account a = new Account(id);
|
||||
Account a = new Account(id, TimeUtil.nowTs());
|
||||
a.setFullName(input.name);
|
||||
a.setPreferredEmail(input.email);
|
||||
db.accounts().insert(Collections.singleton(a));
|
||||
@@ -162,7 +163,8 @@ public class CreateAccount implements RestModifyView<TopLevelResource, Input> {
|
||||
AccountGroupMember m =
|
||||
new AccountGroupMember(new AccountGroupMember.Key(id, groupId));
|
||||
db.accountGroupMembersAudit().insert(Collections.singleton(
|
||||
new AccountGroupMemberAudit(m, currentUser.getAccountId())));
|
||||
new AccountGroupMemberAudit(
|
||||
m, currentUser.getAccountId(), TimeUtil.nowTs())));
|
||||
db.accountGroupMembers().insert(Collections.singleton(m));
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.AccountGroupName;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
@@ -147,8 +148,8 @@ public class PerformCreateGroup {
|
||||
new AccountGroupMember(new AccountGroupMember.Key(accountId, groupId));
|
||||
memberships.add(membership);
|
||||
|
||||
final AccountGroupMemberAudit audit =
|
||||
new AccountGroupMemberAudit(membership, currentUser.getAccountId());
|
||||
final AccountGroupMemberAudit audit = new AccountGroupMemberAudit(
|
||||
membership, currentUser.getAccountId(), TimeUtil.nowTs());
|
||||
membershipsAudit.add(audit);
|
||||
}
|
||||
db.accountGroupMembers().insert(memberships);
|
||||
@@ -170,8 +171,8 @@ public class PerformCreateGroup {
|
||||
new AccountGroupById(new AccountGroupById.Key(groupId, includeUUID));
|
||||
includeList.add(groupInclude);
|
||||
|
||||
final AccountGroupByIdAud audit =
|
||||
new AccountGroupByIdAud(groupInclude, currentUser.getAccountId());
|
||||
final AccountGroupByIdAud audit = new AccountGroupByIdAud(
|
||||
groupInclude, currentUser.getAccountId(), TimeUtil.nowTs());
|
||||
includesAudit.add(audit);
|
||||
}
|
||||
db.accountGroupById().insert(includeList);
|
||||
|
@@ -35,6 +35,7 @@ import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.project.RefControl;
|
||||
import com.google.gerrit.server.ssh.NoSshInfo;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@@ -211,7 +212,7 @@ public class CherryPickChange {
|
||||
Change change =
|
||||
new Change(changeKey, new Change.Id(db.nextChangeId()),
|
||||
currentUser.getAccountId(), new Branch.NameKey(project,
|
||||
destRef.getName()));
|
||||
destRef.getName()), TimeUtil.nowTs());
|
||||
ChangeInserter ins =
|
||||
changeInserterFactory.create(refControl, change, cherryPickCommit);
|
||||
PatchSet newPatchSet = ins.getPatchSet();
|
||||
@@ -247,10 +248,10 @@ public class CherryPickChange {
|
||||
|
||||
private ChangeMessage buildChangeMessage(PatchSet.Id patchSetId, Change dest)
|
||||
throws OrmException {
|
||||
ChangeMessage cmsg =
|
||||
new ChangeMessage(new ChangeMessage.Key(patchSetId.getParentKey(),
|
||||
ChangeUtil.messageUUID(db)), currentUser.getAccountId(),
|
||||
patchSetId);
|
||||
ChangeMessage cmsg = new ChangeMessage(
|
||||
new ChangeMessage.Key(
|
||||
patchSetId.getParentKey(), ChangeUtil.messageUUID(db)),
|
||||
currentUser.getAccountId(), TimeUtil.nowTs(), patchSetId);
|
||||
StringBuilder msgBuf =
|
||||
new StringBuilder("Patch Set " + patchSetId.get()
|
||||
+ ": Cherry Picked");
|
||||
|
@@ -27,6 +27,7 @@ import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.change.PutDraft.Input;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -62,7 +63,7 @@ class CreateDraft implements RestModifyView<RevisionResource, Input> {
|
||||
new PatchLineComment.Key(
|
||||
new Patch.Key(rsrc.getPatchSet().getId(), in.path),
|
||||
ChangeUtil.messageUUID(db.get())),
|
||||
line, rsrc.getAccountId(), Url.decode(in.inReplyTo));
|
||||
line, rsrc.getAccountId(), Url.decode(in.inReplyTo), TimeUtil.nowTs());
|
||||
c.setSide(in.side == Side.PARENT ? (short) 0 : (short) 1);
|
||||
c.setMessage(in.message.trim());
|
||||
c.setRange(in.range);
|
||||
|
@@ -168,8 +168,9 @@ public class PatchSetInserter {
|
||||
}
|
||||
|
||||
public PatchSetInserter setMessage(String message) throws OrmException {
|
||||
changeMessage = new ChangeMessage(new ChangeMessage.Key(change.getId(),
|
||||
ChangeUtil.messageUUID(db)), user.getAccountId(), patchSet.getId());
|
||||
changeMessage = new ChangeMessage(
|
||||
new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)),
|
||||
user.getAccountId(), TimeUtil.nowTs(), patchSet.getId());
|
||||
changeMessage.setMessage(message);
|
||||
return this;
|
||||
}
|
||||
|
@@ -47,6 +47,7 @@ import com.google.gerrit.server.account.AccountsCollection;
|
||||
import com.google.gerrit.server.change.PostReview.Input;
|
||||
import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -361,7 +362,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
ChangeUtil.messageUUID(db.get())),
|
||||
c.line,
|
||||
rsrc.getAccountId(),
|
||||
parent);
|
||||
parent, TimeUtil.nowTs());
|
||||
} else if (parent != null) {
|
||||
e.setParentUuid(parent);
|
||||
}
|
||||
@@ -452,7 +453,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
rsrc.getPatchSet().getId(),
|
||||
rsrc.getAccountId(),
|
||||
lt.getLabelId()),
|
||||
ent.getValue());
|
||||
ent.getValue(), TimeUtil.nowTs());
|
||||
c.setGranted(timestamp);
|
||||
c.cache(change);
|
||||
ins.add(c);
|
||||
@@ -481,7 +482,7 @@ public class PostReview implements RestModifyView<RevisionResource, Input> {
|
||||
rsrc.getAccountId(),
|
||||
rsrc.getControl().getLabelTypes().getLabelTypes().get(0)
|
||||
.getLabelId()),
|
||||
(short) 0);
|
||||
(short) 0, TimeUtil.nowTs());
|
||||
c.setGranted(timestamp);
|
||||
c.cache(change);
|
||||
ins.add(c);
|
||||
|
@@ -53,6 +53,7 @@ import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.gerrit.server.mail.AddReviewerSender;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -314,7 +315,8 @@ public class PostReviewers implements RestModifyView<ChangeResource, Input> {
|
||||
LabelId id =
|
||||
Iterables.getLast(ctl.getLabelTypes().getLabelTypes()).getLabelId();
|
||||
PatchSetApproval dummyApproval = new PatchSetApproval(
|
||||
new PatchSetApproval.Key(patchSetId, reviewerId, id), (short) 0);
|
||||
new PatchSetApproval.Key(patchSetId, reviewerId, id), (short) 0,
|
||||
TimeUtil.nowTs());
|
||||
dummyApproval.cache(ctl.getChange());
|
||||
return dummyApproval;
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.client.CommentRange;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.change.PutDraft.Input;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -84,7 +85,7 @@ class PutDraft implements RestModifyView<DraftResource, Input> {
|
||||
c.getKey().get()),
|
||||
c.getLine(),
|
||||
rsrc.getAuthorId(),
|
||||
c.getParentUuid());
|
||||
c.getParentUuid(), TimeUtil.nowTs());
|
||||
db.get().patchComments().insert(Collections.singleton(update(c, in)));
|
||||
} else {
|
||||
db.get().patchComments().update(Collections.singleton(update(c, in)));
|
||||
@@ -104,7 +105,7 @@ class PutDraft implements RestModifyView<DraftResource, Input> {
|
||||
e.setRange(in.range);
|
||||
e.setLine(in.range != null ? in.range.getEndLine() : in.line);
|
||||
}
|
||||
e.updated();
|
||||
e.updated(TimeUtil.nowTs());
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.change.PutTopic.Input;
|
||||
import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.AtomicUpdate;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -91,7 +92,7 @@ class PutTopic implements RestModifyView<ChangeResource, Input>,
|
||||
IdentifiedUser currentUser = ((IdentifiedUser) control.getCurrentUser());
|
||||
ChangeMessage cmsg = new ChangeMessage(
|
||||
new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)),
|
||||
currentUser.getAccountId(),
|
||||
currentUser.getAccountId(), TimeUtil.nowTs(),
|
||||
change.currentPatchSetId());
|
||||
StringBuilder msgBuf = new StringBuilder(summary);
|
||||
if (!Strings.isNullOrEmpty(input.message)) {
|
||||
|
@@ -227,7 +227,7 @@ public class Submit implements RestModifyView<RevisionResource, Input>,
|
||||
rev.getId(),
|
||||
caller.getAccountId(),
|
||||
LabelId.SUBMIT),
|
||||
(short) 1);
|
||||
(short) 1, TimeUtil.nowTs());
|
||||
}
|
||||
submit.setValue((short) 1);
|
||||
submit.setGranted(timestamp);
|
||||
|
@@ -35,6 +35,7 @@ import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.InvalidChangeOperationException;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@@ -302,9 +303,9 @@ public class RebaseChange {
|
||||
.setRunHooks(runHooks);
|
||||
|
||||
final PatchSet.Id newPatchSetId = patchSetInserter.getPatchSetId();
|
||||
final ChangeMessage cmsg =
|
||||
new ChangeMessage(new ChangeMessage.Key(change.getId(),
|
||||
ChangeUtil.messageUUID(db)), uploader.getAccountId(), patchSetId);
|
||||
final ChangeMessage cmsg = new ChangeMessage(
|
||||
new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)),
|
||||
uploader.getAccountId(), TimeUtil.nowTs(), patchSetId);
|
||||
|
||||
cmsg.setMessage("Patch Set " + newPatchSetId.get()
|
||||
+ ": Patch Set " + patchSetId.get() + " was rebased");
|
||||
|
@@ -794,9 +794,8 @@ public class MergeOp {
|
||||
} catch (OrmException e) {
|
||||
return null;
|
||||
}
|
||||
final ChangeMessage m =
|
||||
new ChangeMessage(new ChangeMessage.Key(c.getId(), uuid), null,
|
||||
c.currentPatchSetId());
|
||||
ChangeMessage m = new ChangeMessage(new ChangeMessage.Key(c.getId(), uuid),
|
||||
null, TimeUtil.nowTs(), c.currentPatchSetId());
|
||||
m.setMessage(body);
|
||||
return m;
|
||||
}
|
||||
|
@@ -1428,7 +1428,8 @@ public class ReceiveCommits {
|
||||
change = new Change(changeKey,
|
||||
new Change.Id(db.nextChangeId()),
|
||||
currentUser.getAccountId(),
|
||||
magicBranch.dest);
|
||||
magicBranch.dest,
|
||||
TimeUtil.nowTs());
|
||||
change.setTopic(magicBranch.topic);
|
||||
ins = changeInserterFactory.create(ctl, change, c)
|
||||
.setDraft(magicBranch.isDraft());
|
||||
@@ -2236,9 +2237,9 @@ public class ReceiveCommits {
|
||||
}
|
||||
}
|
||||
msgBuf.append(".");
|
||||
final ChangeMessage msg =
|
||||
new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil
|
||||
.messageUUID(db)), currentUser.getAccountId(), result.info.getKey());
|
||||
final ChangeMessage msg = new ChangeMessage(
|
||||
new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)),
|
||||
currentUser.getAccountId(), TimeUtil.nowTs(), result.info.getKey());
|
||||
msg.setMessage(msgBuf.toString());
|
||||
|
||||
db.changeMessages().insert(Collections.singleton(msg));
|
||||
|
@@ -35,6 +35,7 @@ import com.google.gerrit.server.account.GroupControl;
|
||||
import com.google.gerrit.server.account.GroupIncludeCache;
|
||||
import com.google.gerrit.server.group.AddIncludedGroups.Input;
|
||||
import com.google.gerrit.server.group.GroupJson.GroupInfo;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -115,7 +116,8 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
||||
if (agi == null) {
|
||||
agi = new AccountGroupById(agiKey);
|
||||
newIncludedGroups.put(d.getGroupUUID(), agi);
|
||||
newIncludedGroupsAudits.add(new AccountGroupByIdAud(agi, me));
|
||||
newIncludedGroupsAudits.add(
|
||||
new AccountGroupByIdAud(agi, me, TimeUtil.nowTs()));
|
||||
}
|
||||
}
|
||||
result.add(json.format(d));
|
||||
|
@@ -39,6 +39,7 @@ import com.google.gerrit.server.account.AuthRequest;
|
||||
import com.google.gerrit.server.account.GroupControl;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gerrit.server.group.AddMembers.Input;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -132,7 +133,8 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
if (m == null) {
|
||||
m = new AccountGroupMember(key);
|
||||
newAccountGroupMembers.put(m.getAccountId(), m);
|
||||
newAccountGroupMemberAudits.add(new AccountGroupMemberAudit(m, me));
|
||||
newAccountGroupMemberAudits.add(
|
||||
new AccountGroupMemberAudit(m, me, TimeUtil.nowTs()));
|
||||
}
|
||||
}
|
||||
result.add(loader.get(a.getId()));
|
||||
|
@@ -34,6 +34,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.GroupControl;
|
||||
import com.google.gerrit.server.account.GroupIncludeCache;
|
||||
import com.google.gerrit.server.group.AddIncludedGroups.Input;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -122,7 +123,7 @@ public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input
|
||||
}
|
||||
|
||||
if (audit != null) {
|
||||
audit.removed(me);
|
||||
audit.removed(me, TimeUtil.nowTs());
|
||||
auditUpdates.add(audit);
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.account.AccountsCollection;
|
||||
import com.google.gerrit.server.account.GroupControl;
|
||||
import com.google.gerrit.server.group.AddMembers.Input;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -107,10 +108,10 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
|
||||
if (audit != null) {
|
||||
audit.removed(me);
|
||||
audit.removed(me, TimeUtil.nowTs());
|
||||
auditUpdates.add(audit);
|
||||
} else {
|
||||
audit = new AccountGroupMemberAudit(m, me);
|
||||
audit = new AccountGroupMemberAudit(m, me, TimeUtil.nowTs());
|
||||
audit.removedLegacy();
|
||||
auditInserts.add(audit);
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import static com.google.gerrit.server.project.Util.grant;
|
||||
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.gerrit.server.project.Util;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
@@ -79,7 +80,8 @@ public class GerritCommonTest extends PrologTestCase {
|
||||
Change change =
|
||||
new Change(new Change.Key("Ibeef"), new Change.Id(1),
|
||||
new Account.Id(2),
|
||||
new Branch.NameKey(localKey, "refs/heads/master"));
|
||||
new Branch.NameKey(localKey, "refs/heads/master"),
|
||||
TimeUtil.nowTs());
|
||||
env.set(StoredValues.CHANGE, change);
|
||||
env.set(StoredValues.CHANGE_CONTROL, util.user(local).controlFor(change));
|
||||
}
|
||||
|
@@ -217,7 +217,7 @@ public class CommentsTest extends TestCase {
|
||||
Patch.Key p = new Patch.Key(psId, filename);
|
||||
PatchLineComment.Key id = new PatchLineComment.Key(p, uuid);
|
||||
PatchLineComment plc =
|
||||
new PatchLineComment(id, line, authorId, inReplyToUuid);
|
||||
new PatchLineComment(id, line, authorId, inReplyToUuid, TimeUtil.nowTs());
|
||||
plc.setMessage(message);
|
||||
plc.setRange(range);
|
||||
plc.setSide(side == Side.PARENT ? (short) 0 : (short) 1);
|
||||
|
@@ -30,6 +30,7 @@ import com.google.gerrit.reviewdb.client.SubmoduleSubscription;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.reviewdb.server.SubmoduleSubscriptionAccess;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.client.KeyUtil;
|
||||
import com.google.gwtorm.server.ListResultSet;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
@@ -608,9 +609,9 @@ public class SubmoduleOpTest extends LocalDiskRepositoryTestCase {
|
||||
|
||||
final CodeReviewCommit codeReviewCommit =
|
||||
new CodeReviewCommit(sourceMergeTip.toObjectId());
|
||||
final Change submittedChange =
|
||||
new Change(new Change.Key(sourceMergeTip.toObjectId().getName()),
|
||||
new Change.Id(1), new Account.Id(1), sourceBranchNameKey);
|
||||
final Change submittedChange = new Change(
|
||||
new Change.Key(sourceMergeTip.toObjectId().getName()), new Change.Id(1),
|
||||
new Account.Id(1), sourceBranchNameKey, TimeUtil.nowTs());
|
||||
codeReviewCommit.change = submittedChange;
|
||||
|
||||
final Map<Change.Id, CodeReviewCommit> mergedCommits =
|
||||
@@ -712,9 +713,9 @@ public class SubmoduleOpTest extends LocalDiskRepositoryTestCase {
|
||||
|
||||
final CodeReviewCommit codeReviewCommit =
|
||||
new CodeReviewCommit(sourceMergeTip.toObjectId());
|
||||
final Change submittedChange =
|
||||
new Change(new Change.Key(sourceMergeTip.toObjectId().getName()),
|
||||
new Change.Id(1), new Account.Id(1), sourceBranchNameKey);
|
||||
final Change submittedChange = new Change(
|
||||
new Change.Key(sourceMergeTip.toObjectId().getName()), new Change.Id(1),
|
||||
new Account.Id(1), sourceBranchNameKey, TimeUtil.nowTs());
|
||||
codeReviewCommit.change = submittedChange;
|
||||
|
||||
final Map<Change.Id, CodeReviewCommit> mergedCommits =
|
||||
|
@@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.AccountExternalId;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -276,7 +277,7 @@ public class FromAddressGeneratorProviderTest extends TestCase {
|
||||
|
||||
private AccountState makeUser(final String name, final String email) {
|
||||
final Account.Id userId = new Account.Id(42);
|
||||
final Account account = new Account(userId);
|
||||
final Account account = new Account(userId, TimeUtil.nowTs());
|
||||
account.setFullName(name);
|
||||
account.setPreferredEmail(email);
|
||||
final AccountState s =
|
||||
|
@@ -48,6 +48,7 @@ import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.gerrit.server.schema.SchemaCreator;
|
||||
import com.google.gerrit.server.util.RequestContext;
|
||||
import com.google.gerrit.server.util.ThreadLocalRequestContext;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gerrit.testutil.InMemoryDatabase;
|
||||
import com.google.gerrit.testutil.InMemoryRepositoryManager;
|
||||
import com.google.inject.Inject;
|
||||
@@ -420,7 +421,7 @@ public abstract class AbstractQueryChangesTest {
|
||||
}
|
||||
|
||||
Change change = new Change(new Change.Key(key), id, ownerId,
|
||||
new Branch.NameKey(project, branch));
|
||||
new Branch.NameKey(project, branch), TimeUtil.nowTs());
|
||||
change.setLastUpdatedOn(new Timestamp(clockMs));
|
||||
clockMs += clockStepMs;
|
||||
return changeFactory.create(
|
||||
|
Reference in New Issue
Block a user