ETag computation needs to honor changes in other changes

If `submitWholetopic` is enabled a change may stay unchanged,
but a change in the same topic can influence submittability.

Change-Id: I5c958369e9deec9546bc691629f14266d6755721
This commit is contained in:
Stefan Beller
2015-02-17 10:10:38 -08:00
parent ea34214362
commit add7038b5e
3 changed files with 60 additions and 13 deletions

View File

@@ -57,17 +57,15 @@ public class ChangeResource implements RestResource, HasETag {
return getControl().getNotes();
}
@Override
public String getETag() {
CurrentUser user = control.getCurrentUser();
Hasher h = Hashing.md5().newHasher()
.putLong(getChange().getLastUpdatedOn().getTime())
// This includes all information relevant for ETag computation
// unrelated to the UI.
public void prepareETag(Hasher h, CurrentUser user) {
h.putLong(getChange().getLastUpdatedOn().getTime())
.putInt(getChange().getRowVersion())
.putBoolean(user.getStarredChanges().contains(getChange().getId()))
.putInt(user.isIdentifiedUser()
? ((IdentifiedUser) user).getAccountId().get()
: 0);
byte[] buf = new byte[20];
ObjectId noteId;
try {
@@ -82,6 +80,14 @@ public class ChangeResource implements RestResource, HasETag {
for (ProjectState p : control.getProjectControl().getProjectState().tree()) {
hashObjectId(h, p.getConfig().getRevision(), buf);
}
}
@Override
public String getETag() {
CurrentUser user = control.getCurrentUser();
Hasher h = Hashing.md5().newHasher()
.putBoolean(user.getStarredChanges().contains(getChange().getId()));
prepareETag(h, user);
return h.hash().toString();
}