Remove asynchronous loading of starred changes
When the starred changes were stored in the database for performance reasons it was important to load them asynchronously while a change query was executed. Now the starred changes are stored in the change index so that this asynchronous loading is no longer needed. This removes the starred changes functionality from IdentifiedUser which was only used by IsStarredByLegacyPredicate. IsStarredByLegacyPredicate is used to serve the "is:starred" query when the current change index is old and doesn't contain any starred changes. In this case we must load the starred changes from the git backend. This is expensive since all starred changes refs must be iterated, but implementing some asynchronous loading for this case seems overkill since IsStarredByLegacyPredicate is only used until the online reindexing to a newer index version that contains starred changes is done. The old implementation of IsStarredByLegacyPredicate was broken since it tried to query the starred changes from the index which doesn't contain starred changes when IsStarredByLegacyPredicate is used. This also fixes the following warning from StarredChangesUtil when the newest change index version is used from which the deprecated STARREDBY is removed: WARN com.google.gerrit.server.StarredChangesUtil : Cannot query starred changes for account 1000000 java.lang.IllegalArgumentException: numHits must be > 0; please use TotalHitCountCollector if you just need the total hit count This warning occurred because the asynchronous loading of changes used the STARREDBY field to load changes from the index, but the index didn't contain this field anymore. Since the starred changes functionality is removed from IdentifiedUser the abstract CurrentUser.getStarredChanges() method is no longer needed and hence it is removed. This means that all subclasses of CurrentUser must be adapted. One subclass exists in the replication plugin and hence this plugin must be updated. Also, since IdentifiedUser no longer needs StarredChangesUtil, binding a null provider for this class in tests is no longer needed. Change-Id: I14a38e9b243b4b182230fe70b023203492a81904 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.server.account.CapabilityControl;
|
import com.google.gerrit.server.account.CapabilityControl;
|
||||||
import com.google.gerrit.server.account.GroupMembership;
|
import com.google.gerrit.server.account.GroupMembership;
|
||||||
import com.google.gerrit.server.account.ListGroupMembership;
|
import com.google.gerrit.server.account.ListGroupMembership;
|
||||||
@@ -22,7 +21,6 @@ import com.google.gerrit.server.group.SystemGroupBackend;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/** An anonymous user who has not yet authenticated. */
|
/** An anonymous user who has not yet authenticated. */
|
||||||
public class AnonymousUser extends CurrentUser {
|
public class AnonymousUser extends CurrentUser {
|
||||||
@@ -36,11 +34,6 @@ public class AnonymousUser extends CurrentUser {
|
|||||||
return new ListGroupMembership(Collections.singleton(SystemGroupBackend.ANONYMOUS_USERS));
|
return new ListGroupMembership(Collections.singleton(SystemGroupBackend.ANONYMOUS_USERS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Change.Id> getStarredChanges() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ANONYMOUS";
|
return "ANONYMOUS";
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ package com.google.gerrit.server;
|
|||||||
|
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.server.account.CapabilityControl;
|
import com.google.gerrit.server.account.CapabilityControl;
|
||||||
import com.google.gerrit.server.account.GroupMembership;
|
import com.google.gerrit.server.account.GroupMembership;
|
||||||
import com.google.inject.servlet.RequestScoped;
|
import com.google.inject.servlet.RequestScoped;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about the currently logged in user.
|
* Information about the currently logged in user.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -87,10 +84,6 @@ public abstract class CurrentUser {
|
|||||||
*/
|
*/
|
||||||
public abstract GroupMembership getEffectiveGroups();
|
public abstract GroupMembership getEffectiveGroups();
|
||||||
|
|
||||||
/** Set of changes starred by this user. */
|
|
||||||
@Deprecated
|
|
||||||
public abstract Set<Change.Id> getStarredChanges();
|
|
||||||
|
|
||||||
/** Unique name of the user on this server, if one has been assigned. */
|
/** Unique name of the user on this server, if one has been assigned. */
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -14,12 +14,10 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import com.google.common.collect.FluentIterable;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
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.AccountState;
|
||||||
import com.google.gerrit.server.account.CapabilityControl;
|
import com.google.gerrit.server.account.CapabilityControl;
|
||||||
@@ -32,7 +30,6 @@ import com.google.gerrit.server.config.AuthConfig;
|
|||||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||||
import com.google.gerrit.server.config.DisableReverseDnsLookup;
|
import com.google.gerrit.server.config.DisableReverseDnsLookup;
|
||||||
import com.google.gerrit.server.group.SystemGroupBackend;
|
import com.google.gerrit.server.group.SystemGroupBackend;
|
||||||
import com.google.gwtorm.server.ResultSet;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
@@ -58,7 +55,6 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
@Singleton
|
@Singleton
|
||||||
public static class GenericFactory {
|
public static class GenericFactory {
|
||||||
private final CapabilityControl.Factory capabilityControlFactory;
|
private final CapabilityControl.Factory capabilityControlFactory;
|
||||||
private final StarredChangesUtil starredChangesUtil;
|
|
||||||
private final AuthConfig authConfig;
|
private final AuthConfig authConfig;
|
||||||
private final Realm realm;
|
private final Realm realm;
|
||||||
private final String anonymousCowardName;
|
private final String anonymousCowardName;
|
||||||
@@ -70,7 +66,6 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
@Inject
|
@Inject
|
||||||
public GenericFactory(
|
public GenericFactory(
|
||||||
@Nullable CapabilityControl.Factory capabilityControlFactory,
|
@Nullable CapabilityControl.Factory capabilityControlFactory,
|
||||||
@Nullable StarredChangesUtil starredChangesUtil,
|
|
||||||
AuthConfig authConfig,
|
AuthConfig authConfig,
|
||||||
Realm realm,
|
Realm realm,
|
||||||
@AnonymousCowardName String anonymousCowardName,
|
@AnonymousCowardName String anonymousCowardName,
|
||||||
@@ -79,7 +74,6 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
AccountCache accountCache,
|
AccountCache accountCache,
|
||||||
GroupBackend groupBackend) {
|
GroupBackend groupBackend) {
|
||||||
this.capabilityControlFactory = capabilityControlFactory;
|
this.capabilityControlFactory = capabilityControlFactory;
|
||||||
this.starredChangesUtil = starredChangesUtil;
|
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.anonymousCowardName = anonymousCowardName;
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
@@ -99,10 +93,9 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
|
|
||||||
public IdentifiedUser runAs(SocketAddress remotePeer, Account.Id id,
|
public IdentifiedUser runAs(SocketAddress remotePeer, Account.Id id,
|
||||||
@Nullable CurrentUser caller) {
|
@Nullable CurrentUser caller) {
|
||||||
return new IdentifiedUser(capabilityControlFactory, starredChangesUtil,
|
return new IdentifiedUser(capabilityControlFactory, authConfig, realm,
|
||||||
authConfig, realm, anonymousCowardName, canonicalUrl, accountCache,
|
anonymousCowardName, canonicalUrl, accountCache, groupBackend,
|
||||||
groupBackend, disableReverseDnsLookup, Providers.of(remotePeer), id,
|
disableReverseDnsLookup, Providers.of(remotePeer), id, caller);
|
||||||
caller);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +108,6 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
@Singleton
|
@Singleton
|
||||||
public static class RequestFactory {
|
public static class RequestFactory {
|
||||||
private final CapabilityControl.Factory capabilityControlFactory;
|
private final CapabilityControl.Factory capabilityControlFactory;
|
||||||
private final StarredChangesUtil starredChangesUtil;
|
|
||||||
private final AuthConfig authConfig;
|
private final AuthConfig authConfig;
|
||||||
private final Realm realm;
|
private final Realm realm;
|
||||||
private final String anonymousCowardName;
|
private final String anonymousCowardName;
|
||||||
@@ -128,7 +120,6 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
@Inject
|
@Inject
|
||||||
RequestFactory(
|
RequestFactory(
|
||||||
CapabilityControl.Factory capabilityControlFactory,
|
CapabilityControl.Factory capabilityControlFactory,
|
||||||
@Nullable StarredChangesUtil starredChangesUtil,
|
|
||||||
AuthConfig authConfig,
|
AuthConfig authConfig,
|
||||||
Realm realm,
|
Realm realm,
|
||||||
@AnonymousCowardName String anonymousCowardName,
|
@AnonymousCowardName String anonymousCowardName,
|
||||||
@@ -138,7 +129,6 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
@DisableReverseDnsLookup Boolean disableReverseDnsLookup,
|
@DisableReverseDnsLookup Boolean disableReverseDnsLookup,
|
||||||
@RemotePeer Provider<SocketAddress> remotePeerProvider) {
|
@RemotePeer Provider<SocketAddress> remotePeerProvider) {
|
||||||
this.capabilityControlFactory = capabilityControlFactory;
|
this.capabilityControlFactory = capabilityControlFactory;
|
||||||
this.starredChangesUtil = starredChangesUtil;
|
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.anonymousCowardName = anonymousCowardName;
|
this.anonymousCowardName = anonymousCowardName;
|
||||||
@@ -150,16 +140,15 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IdentifiedUser create(Account.Id id) {
|
public IdentifiedUser create(Account.Id id) {
|
||||||
return new IdentifiedUser(capabilityControlFactory, starredChangesUtil,
|
return new IdentifiedUser(capabilityControlFactory, authConfig, realm,
|
||||||
authConfig, realm, anonymousCowardName, canonicalUrl, accountCache,
|
anonymousCowardName, canonicalUrl, accountCache, groupBackend,
|
||||||
groupBackend, disableReverseDnsLookup, remotePeerProvider, id, null);
|
disableReverseDnsLookup, remotePeerProvider, id, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IdentifiedUser runAs(Account.Id id, CurrentUser caller) {
|
public IdentifiedUser runAs(Account.Id id, CurrentUser caller) {
|
||||||
return new IdentifiedUser(capabilityControlFactory, starredChangesUtil,
|
return new IdentifiedUser(capabilityControlFactory, authConfig, realm,
|
||||||
authConfig, realm, anonymousCowardName, canonicalUrl, accountCache,
|
anonymousCowardName, canonicalUrl, accountCache, groupBackend,
|
||||||
groupBackend, disableReverseDnsLookup, remotePeerProvider, id,
|
disableReverseDnsLookup, remotePeerProvider, id, caller);
|
||||||
caller);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +157,6 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
SystemGroupBackend.ANONYMOUS_USERS,
|
SystemGroupBackend.ANONYMOUS_USERS,
|
||||||
SystemGroupBackend.REGISTERED_USERS));
|
SystemGroupBackend.REGISTERED_USERS));
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private final StarredChangesUtil starredChangesUtil;
|
|
||||||
|
|
||||||
private final Provider<String> canonicalUrl;
|
private final Provider<String> canonicalUrl;
|
||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
private final AuthConfig authConfig;
|
private final AuthConfig authConfig;
|
||||||
@@ -188,14 +174,11 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
private boolean loadedAllEmails;
|
private boolean loadedAllEmails;
|
||||||
private Set<String> invalidEmails;
|
private Set<String> invalidEmails;
|
||||||
private GroupMembership effectiveGroups;
|
private GroupMembership effectiveGroups;
|
||||||
private Set<Change.Id> starredChanges;
|
|
||||||
private ResultSet<Change.Id> starredQuery;
|
|
||||||
private CurrentUser realUser;
|
private CurrentUser realUser;
|
||||||
private Map<PropertyKey<Object>, Object> properties;
|
private Map<PropertyKey<Object>, Object> properties;
|
||||||
|
|
||||||
private IdentifiedUser(
|
private IdentifiedUser(
|
||||||
CapabilityControl.Factory capabilityControlFactory,
|
CapabilityControl.Factory capabilityControlFactory,
|
||||||
@Nullable StarredChangesUtil starredChangesUtil,
|
|
||||||
final AuthConfig authConfig,
|
final AuthConfig authConfig,
|
||||||
Realm realm,
|
Realm realm,
|
||||||
final String anonymousCowardName,
|
final String anonymousCowardName,
|
||||||
@@ -207,7 +190,6 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
final Account.Id id,
|
final Account.Id id,
|
||||||
@Nullable CurrentUser realUser) {
|
@Nullable CurrentUser realUser) {
|
||||||
super(capabilityControlFactory);
|
super(capabilityControlFactory);
|
||||||
this.starredChangesUtil = starredChangesUtil;
|
|
||||||
this.canonicalUrl = canonicalUrl;
|
this.canonicalUrl = canonicalUrl;
|
||||||
this.accountCache = accountCache;
|
this.accountCache = accountCache;
|
||||||
this.groupBackend = groupBackend;
|
this.groupBackend = groupBackend;
|
||||||
@@ -295,53 +277,6 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
return effectiveGroups;
|
return effectiveGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public Set<Change.Id> getStarredChanges() {
|
|
||||||
if (starredChanges == null) {
|
|
||||||
if (starredChangesUtil == null) {
|
|
||||||
throw new IllegalStateException("StarredChangesUtil is missing");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
starredChanges =
|
|
||||||
FluentIterable.from(
|
|
||||||
starredQuery != null
|
|
||||||
? starredQuery
|
|
||||||
: starredChangesUtil.queryFromIndex(accountId))
|
|
||||||
.toSet();
|
|
||||||
} finally {
|
|
||||||
starredQuery = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return starredChanges;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void clearStarredChanges() {
|
|
||||||
// Async query may have started before an update that the caller expects
|
|
||||||
// to see the results of, so we can't trust it.
|
|
||||||
abortStarredChanges();
|
|
||||||
starredChanges = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void asyncStarredChanges() {
|
|
||||||
if (starredChanges == null && starredChangesUtil != null) {
|
|
||||||
starredQuery = starredChangesUtil.queryFromIndex(accountId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void abortStarredChanges() {
|
|
||||||
if (starredQuery != null) {
|
|
||||||
try {
|
|
||||||
starredQuery.close();
|
|
||||||
} finally {
|
|
||||||
starredQuery = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PersonIdent newRefLogIdent() {
|
public PersonIdent newRefLogIdent() {
|
||||||
return newRefLogIdent(new Date(), TimeZone.getDefault());
|
return newRefLogIdent(new Date(), TimeZone.getDefault());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,10 @@
|
|||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.server.account.CapabilityControl;
|
import com.google.gerrit.server.account.CapabilityControl;
|
||||||
import com.google.gerrit.server.account.GroupMembership;
|
import com.google.gerrit.server.account.GroupMembership;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User identity for plugin code that needs an identity.
|
* User identity for plugin code that needs an identity.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -49,11 +45,6 @@ public class InternalUser extends CurrentUser {
|
|||||||
return GroupMembership.EMPTY;
|
return GroupMembership.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Change.Id> getStarredChanges() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInternalUser() {
|
public boolean isInternalUser() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -14,15 +14,12 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.server.account.CapabilityControl;
|
import com.google.gerrit.server.account.CapabilityControl;
|
||||||
import com.google.gerrit.server.account.GroupMembership;
|
import com.google.gerrit.server.account.GroupMembership;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/** Identity of a peer daemon process that isn't this JVM. */
|
/** Identity of a peer daemon process that isn't this JVM. */
|
||||||
public class PeerDaemonUser extends CurrentUser {
|
public class PeerDaemonUser extends CurrentUser {
|
||||||
@@ -47,11 +44,6 @@ public class PeerDaemonUser extends CurrentUser {
|
|||||||
return GroupMembership.EMPTY;
|
return GroupMembership.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Change.Id> getStarredChanges() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SocketAddress getRemoteAddress() {
|
public SocketAddress getRemoteAddress() {
|
||||||
return peer;
|
return peer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ import com.google.gerrit.server.index.change.ChangeIndexer;
|
|||||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||||
import com.google.gwtorm.server.ListResultSet;
|
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.gwtorm.server.ResultSet;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
@@ -65,7 +63,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
@@ -282,6 +279,47 @@ public class StarredChangesUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
// To be used only for IsStarredByLegacyPredicate.
|
||||||
|
public Set<Change.Id> byAccount(final Account.Id accountId,
|
||||||
|
final String label) throws OrmException {
|
||||||
|
try (final Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
|
return FluentIterable
|
||||||
|
.from(getRefNames(repo, RefNames.REFS_STARRED_CHANGES))
|
||||||
|
.filter(new Predicate<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(String refPart) {
|
||||||
|
return refPart.endsWith("/" + accountId.get());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.transform(new Function<String, Change.Id>() {
|
||||||
|
@Override
|
||||||
|
public Change.Id apply(String refPart) {
|
||||||
|
return Change.Id.fromRefPart(refPart);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(new Predicate<Change.Id>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(Change.Id changeId) {
|
||||||
|
try {
|
||||||
|
return readLabels(repo,
|
||||||
|
RefNames.refsStarredChanges(changeId, accountId))
|
||||||
|
.contains(label);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(String.format(
|
||||||
|
"Cannot query stars by account %d on change %d",
|
||||||
|
accountId.get(), changeId.get()), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).toSet();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new OrmException(
|
||||||
|
String.format("Get changes that were starred by %d failed",
|
||||||
|
accountId.get()), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ImmutableMultimap<Account.Id, String> byChangeFromIndex(
|
public ImmutableMultimap<Account.Id, String> byChangeFromIndex(
|
||||||
Change.Id changeId) throws OrmException, NoSuchChangeException {
|
Change.Id changeId) throws OrmException, NoSuchChangeException {
|
||||||
Set<String> fields = ImmutableSet.of(
|
Set<String> fields = ImmutableSet.of(
|
||||||
@@ -295,29 +333,6 @@ public class StarredChangesUtil {
|
|||||||
return changeData.get(0).stars();
|
return changeData.get(0).stars();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public ResultSet<Change.Id> queryFromIndex(final Account.Id accountId) {
|
|
||||||
try {
|
|
||||||
Set<String> fields = ImmutableSet.of(
|
|
||||||
ChangeField.ID.getName());
|
|
||||||
List<ChangeData> changeData =
|
|
||||||
queryProvider.get().setRequestedFields(fields).byIsStarred(accountId);
|
|
||||||
return new ListResultSet<>(FluentIterable
|
|
||||||
.from(changeData)
|
|
||||||
.transform(new Function<ChangeData, Change.Id>() {
|
|
||||||
@Override
|
|
||||||
public Change.Id apply(ChangeData cd) {
|
|
||||||
return cd.getId();
|
|
||||||
}
|
|
||||||
}).toList());
|
|
||||||
} catch (OrmException | RuntimeException e) {
|
|
||||||
log.warn(String.format("Cannot query starred changes for account %d",
|
|
||||||
accountId.get()), e);
|
|
||||||
List<Change.Id> empty = Collections.emptyList();
|
|
||||||
return new ListResultSet<>(empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Set<String> getRefNames(Repository repo, String prefix)
|
private static Set<String> getRefNames(Repository repo, String prefix)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
RefDatabase refDb = repo.getRefDatabase();
|
RefDatabase refDb = repo.getRefDatabase();
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import com.google.gerrit.extensions.common.SuggestedReviewerInfo;
|
|||||||
import com.google.gerrit.extensions.restapi.IdString;
|
import com.google.gerrit.extensions.restapi.IdString;
|
||||||
import com.google.gerrit.extensions.restapi.Response;
|
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.server.CurrentUser;
|
|
||||||
import com.google.gerrit.server.change.Abandon;
|
import com.google.gerrit.server.change.Abandon;
|
||||||
import com.google.gerrit.server.change.ChangeEdits;
|
import com.google.gerrit.server.change.ChangeEdits;
|
||||||
import com.google.gerrit.server.change.ChangeJson;
|
import com.google.gerrit.server.change.ChangeJson;
|
||||||
@@ -73,7 +72,6 @@ class ChangeApiImpl implements ChangeApi {
|
|||||||
ChangeApiImpl create(ChangeResource change);
|
ChangeApiImpl create(ChangeResource change);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final CurrentUser user;
|
|
||||||
private final Changes changeApi;
|
private final Changes changeApi;
|
||||||
private final Reviewers reviewers;
|
private final Reviewers reviewers;
|
||||||
private final Revisions revisions;
|
private final Revisions revisions;
|
||||||
@@ -102,8 +100,7 @@ class ChangeApiImpl implements ChangeApi {
|
|||||||
private final Move move;
|
private final Move move;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ChangeApiImpl(CurrentUser user,
|
ChangeApiImpl(Changes changeApi,
|
||||||
Changes changeApi,
|
|
||||||
Reviewers reviewers,
|
Reviewers reviewers,
|
||||||
Revisions revisions,
|
Revisions revisions,
|
||||||
ReviewerApiImpl.Factory reviewerApi,
|
ReviewerApiImpl.Factory reviewerApi,
|
||||||
@@ -128,7 +125,6 @@ class ChangeApiImpl implements ChangeApi {
|
|||||||
ChangeEdits.Detail editDetail,
|
ChangeEdits.Detail editDetail,
|
||||||
Move move,
|
Move move,
|
||||||
@Assisted ChangeResource change) {
|
@Assisted ChangeResource change) {
|
||||||
this.user = user;
|
|
||||||
this.changeApi = changeApi;
|
this.changeApi = changeApi;
|
||||||
this.revert = revert;
|
this.revert = revert;
|
||||||
this.reviewers = reviewers;
|
this.reviewers = reviewers;
|
||||||
@@ -336,14 +332,10 @@ class ChangeApiImpl implements ChangeApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
@Override
|
||||||
public ChangeInfo get(EnumSet<ListChangesOption> s)
|
public ChangeInfo get(EnumSet<ListChangesOption> s)
|
||||||
throws RestApiException {
|
throws RestApiException {
|
||||||
try {
|
try {
|
||||||
if (user.isIdentifiedUser()) {
|
|
||||||
user.asIdentifiedUser().clearStarredChanges();
|
|
||||||
}
|
|
||||||
return changeJson.create(s).format(change);
|
return changeJson.create(s).format(change);
|
||||||
} catch (OrmException e) {
|
} catch (OrmException e) {
|
||||||
throw new RestApiException("Cannot retrieve change", e);
|
throw new RestApiException("Cannot retrieve change", e);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import com.google.gerrit.extensions.restapi.RestApiException;
|
|||||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||||
import com.google.gerrit.extensions.restapi.Url;
|
import com.google.gerrit.extensions.restapi.Url;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
|
||||||
import com.google.gerrit.server.change.ChangesCollection;
|
import com.google.gerrit.server.change.ChangesCollection;
|
||||||
import com.google.gerrit.server.change.CreateChange;
|
import com.google.gerrit.server.change.CreateChange;
|
||||||
import com.google.gerrit.server.git.UpdateException;
|
import com.google.gerrit.server.git.UpdateException;
|
||||||
@@ -46,19 +45,16 @@ import java.util.List;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ChangesImpl implements Changes {
|
class ChangesImpl implements Changes {
|
||||||
private final Provider<CurrentUser> user;
|
|
||||||
private final ChangesCollection changes;
|
private final ChangesCollection changes;
|
||||||
private final ChangeApiImpl.Factory api;
|
private final ChangeApiImpl.Factory api;
|
||||||
private final CreateChange createChange;
|
private final CreateChange createChange;
|
||||||
private final Provider<QueryChanges> queryProvider;
|
private final Provider<QueryChanges> queryProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ChangesImpl(Provider<CurrentUser> user,
|
ChangesImpl(ChangesCollection changes,
|
||||||
ChangesCollection changes,
|
|
||||||
ChangeApiImpl.Factory api,
|
ChangeApiImpl.Factory api,
|
||||||
CreateChange createChange,
|
CreateChange createChange,
|
||||||
Provider<QueryChanges> queryProvider) {
|
Provider<QueryChanges> queryProvider) {
|
||||||
this.user = user;
|
|
||||||
this.changes = changes;
|
this.changes = changes;
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.createChange = createChange;
|
this.createChange = createChange;
|
||||||
@@ -117,7 +113,6 @@ class ChangesImpl implements Changes {
|
|||||||
return query().withQuery(query);
|
return query().withQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private List<ChangeInfo> get(final QueryRequest q) throws RestApiException {
|
private List<ChangeInfo> get(final QueryRequest q) throws RestApiException {
|
||||||
QueryChanges qc = queryProvider.get();
|
QueryChanges qc = queryProvider.get();
|
||||||
if (q.getQuery() != null) {
|
if (q.getQuery() != null) {
|
||||||
@@ -130,10 +125,6 @@ class ChangesImpl implements Changes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CurrentUser u = user.get();
|
|
||||||
if (u.isIdentifiedUser()) {
|
|
||||||
u.asIdentifiedUser().clearStarredChanges();
|
|
||||||
}
|
|
||||||
List<?> result = qc.apply(TopLevelResource.INSTANCE);
|
List<?> result = qc.apply(TopLevelResource.INSTANCE);
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
final ChangeIndex index;
|
final ChangeIndex index;
|
||||||
final IndexConfig indexConfig;
|
final IndexConfig indexConfig;
|
||||||
final Provider<ListMembers> listMembers;
|
final Provider<ListMembers> listMembers;
|
||||||
|
final StarredChangesUtil starredChangesUtil;
|
||||||
final boolean allowsDrafts;
|
final boolean allowsDrafts;
|
||||||
|
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
@@ -213,6 +214,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
TrackingFooters trackingFooters,
|
TrackingFooters trackingFooters,
|
||||||
IndexConfig indexConfig,
|
IndexConfig indexConfig,
|
||||||
Provider<ListMembers> listMembers,
|
Provider<ListMembers> listMembers,
|
||||||
|
StarredChangesUtil starredChangesUtil,
|
||||||
@GerritServerConfig Config cfg) {
|
@GerritServerConfig Config cfg) {
|
||||||
this(db, queryProvider, rewriter, opFactories, userFactory, self,
|
this(db, queryProvider, rewriter, opFactories, userFactory, self,
|
||||||
capabilityControlFactory, changeControlGenericFactory, notesFactory,
|
capabilityControlFactory, changeControlGenericFactory, notesFactory,
|
||||||
@@ -220,7 +222,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
allProjectsName, allUsersName, patchListCache, repoManager,
|
allProjectsName, allUsersName, patchListCache, repoManager,
|
||||||
projectCache, listChildProjects, submitDryRun, conflictsCache,
|
projectCache, listChildProjects, submitDryRun, conflictsCache,
|
||||||
trackingFooters, indexes != null ? indexes.getSearchIndex() : null,
|
trackingFooters, indexes != null ? indexes.getSearchIndex() : null,
|
||||||
indexConfig, listMembers,
|
indexConfig, listMembers, starredChangesUtil,
|
||||||
cfg == null ? true : cfg.getBoolean("change", "allowDrafts", true));
|
cfg == null ? true : cfg.getBoolean("change", "allowDrafts", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,6 +253,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
ChangeIndex index,
|
ChangeIndex index,
|
||||||
IndexConfig indexConfig,
|
IndexConfig indexConfig,
|
||||||
Provider<ListMembers> listMembers,
|
Provider<ListMembers> listMembers,
|
||||||
|
StarredChangesUtil starredChangesUtil,
|
||||||
boolean allowsDrafts) {
|
boolean allowsDrafts) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.queryProvider = queryProvider;
|
this.queryProvider = queryProvider;
|
||||||
@@ -278,6 +281,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
this.indexConfig = indexConfig;
|
this.indexConfig = indexConfig;
|
||||||
this.listMembers = listMembers;
|
this.listMembers = listMembers;
|
||||||
|
this.starredChangesUtil = starredChangesUtil;
|
||||||
this.allowsDrafts = allowsDrafts;
|
this.allowsDrafts = allowsDrafts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +293,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
allProjectsName, allUsersName, patchListCache, repoManager,
|
allProjectsName, allUsersName, patchListCache, repoManager,
|
||||||
projectCache, listChildProjects, submitDryRun,
|
projectCache, listChildProjects, submitDryRun,
|
||||||
conflictsCache, trackingFooters, index, indexConfig, listMembers,
|
conflictsCache, trackingFooters, index, indexConfig, listMembers,
|
||||||
allowsDrafts);
|
starredChangesUtil, allowsDrafts);
|
||||||
}
|
}
|
||||||
|
|
||||||
Arguments asUser(Account.Id otherId) {
|
Arguments asUser(Account.Id otherId) {
|
||||||
@@ -678,9 +682,18 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
return new StarPredicate(who, StarredChangesUtil.DEFAULT_LABEL);
|
return new StarPredicate(who, StarredChangesUtil.DEFAULT_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return args.getSchema().hasField(ChangeField.STARREDBY)
|
if (args.getSchema().hasField(ChangeField.STARREDBY)) {
|
||||||
? new IsStarredByPredicate(who)
|
return new IsStarredByPredicate(who);
|
||||||
: new IsStarredByLegacyPredicate(args.asUser(who));
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// starred changes are not contained in the index, we must read them from
|
||||||
|
// git
|
||||||
|
return new IsStarredByLegacyPredicate(who, args.starredChangesUtil
|
||||||
|
.byAccount(who, StarredChangesUtil.DEFAULT_LABEL));
|
||||||
|
} catch (OrmException e) {
|
||||||
|
throw new QueryParseException("Failed to query starred changes.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operator
|
@Operator
|
||||||
|
|||||||
@@ -15,25 +15,16 @@
|
|||||||
package com.google.gerrit.server.query.change;
|
package com.google.gerrit.server.query.change;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
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.CurrentUser;
|
|
||||||
import com.google.gerrit.server.query.OrPredicate;
|
import com.google.gerrit.server.query.OrPredicate;
|
||||||
import com.google.gerrit.server.query.Predicate;
|
import com.google.gerrit.server.query.Predicate;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
|
||||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder.Arguments;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
class IsStarredByLegacyPredicate extends OrPredicate<ChangeData> {
|
class IsStarredByLegacyPredicate extends OrPredicate<ChangeData> {
|
||||||
private static String describe(CurrentUser user) {
|
|
||||||
if (user.isIdentifiedUser()) {
|
|
||||||
return user.getAccountId().toString();
|
|
||||||
}
|
|
||||||
return user.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<Predicate<ChangeData>> predicates(Set<Change.Id> ids) {
|
private static List<Predicate<ChangeData>> predicates(Set<Change.Id> ids) {
|
||||||
List<Predicate<ChangeData>> r = Lists.newArrayListWithCapacity(ids.size());
|
List<Predicate<ChangeData>> r = Lists.newArrayListWithCapacity(ids.size());
|
||||||
for (Change.Id id : ids) {
|
for (Change.Id id : ids) {
|
||||||
@@ -42,16 +33,19 @@ class IsStarredByLegacyPredicate extends OrPredicate<ChangeData> {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final CurrentUser user;
|
private final Account.Id accountId;
|
||||||
|
private final Set<Change.Id> starredChanges;
|
||||||
|
|
||||||
IsStarredByLegacyPredicate(Arguments args) throws QueryParseException {
|
IsStarredByLegacyPredicate(Account.Id accountId,
|
||||||
super(predicates(args.getIdentifiedUser().getStarredChanges()));
|
Set<Change.Id> starredChanges) {
|
||||||
this.user = args.getIdentifiedUser();
|
super(predicates(starredChanges));
|
||||||
|
this.accountId = accountId;
|
||||||
|
this.starredChanges = starredChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(final ChangeData object) {
|
public boolean match(final ChangeData object) {
|
||||||
return user.getStarredChanges().contains(object.getId());
|
return starredChanges.contains(object.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,11 +55,6 @@ class IsStarredByLegacyPredicate extends OrPredicate<ChangeData> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String val = describe(user);
|
return ChangeQueryBuilder.FIELD_STARREDBY + ":" + accountId.toString();
|
||||||
if (val.indexOf(' ') < 0) {
|
|
||||||
return ChangeQueryBuilder.FIELD_STARREDBY + ":" + val;
|
|
||||||
} else {
|
|
||||||
return ChangeQueryBuilder.FIELD_STARREDBY + ":\"" + val + "\"";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,10 @@ import com.google.gerrit.extensions.restapi.AuthException;
|
|||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
|
||||||
import com.google.gerrit.server.change.ChangeJson;
|
import com.google.gerrit.server.change.ChangeJson;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
|
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
@@ -41,7 +38,6 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
|||||||
private final ChangeJson.Factory json;
|
private final ChangeJson.Factory json;
|
||||||
private final ChangeQueryBuilder qb;
|
private final ChangeQueryBuilder qb;
|
||||||
private final QueryProcessor imp;
|
private final QueryProcessor imp;
|
||||||
private final Provider<CurrentUser> user;
|
|
||||||
private EnumSet<ListChangesOption> options;
|
private EnumSet<ListChangesOption> options;
|
||||||
|
|
||||||
@Option(name = "--query", aliases = {"-q"}, metaVar = "QUERY", usage = "Query string")
|
@Option(name = "--query", aliases = {"-q"}, metaVar = "QUERY", usage = "Query string")
|
||||||
@@ -70,12 +66,10 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
|||||||
@Inject
|
@Inject
|
||||||
QueryChanges(ChangeJson.Factory json,
|
QueryChanges(ChangeJson.Factory json,
|
||||||
ChangeQueryBuilder qb,
|
ChangeQueryBuilder qb,
|
||||||
QueryProcessor qp,
|
QueryProcessor qp) {
|
||||||
Provider<CurrentUser> user) {
|
|
||||||
this.json = json;
|
this.json = json;
|
||||||
this.qb = qb;
|
this.qb = qb;
|
||||||
this.imp = qp;
|
this.imp = qp;
|
||||||
this.user = user;
|
|
||||||
|
|
||||||
options = EnumSet.noneOf(ListChangesOption.class);
|
options = EnumSet.noneOf(ListChangesOption.class);
|
||||||
}
|
}
|
||||||
@@ -111,7 +105,6 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
|||||||
return out.size() == 1 ? out.get(0) : out;
|
return out.size() == 1 ? out.get(0) : out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private List<List<ChangeInfo>> query()
|
private List<List<ChangeInfo>> query()
|
||||||
throws OrmException, QueryParseException {
|
throws OrmException, QueryParseException {
|
||||||
if (imp.isDisabled()) {
|
if (imp.isDisabled()) {
|
||||||
@@ -125,22 +118,6 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
|||||||
throw new QueryParseException("limit of 10 queries");
|
throw new QueryParseException("limit of 10 queries");
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifiedUser self = null;
|
|
||||||
try {
|
|
||||||
if (user.get().isIdentifiedUser()) {
|
|
||||||
self = user.get().asIdentifiedUser();
|
|
||||||
self.asyncStarredChanges();
|
|
||||||
}
|
|
||||||
return query0();
|
|
||||||
} finally {
|
|
||||||
if (self != null) {
|
|
||||||
self.abortStarredChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<List<ChangeInfo>> query0() throws OrmException,
|
|
||||||
QueryParseException {
|
|
||||||
int cnt = queries.size();
|
int cnt = queries.size();
|
||||||
List<QueryResult> results = imp.queryChanges(qb.parse(queries));
|
List<QueryResult> results = imp.queryChanges(qb.parse(queries));
|
||||||
List<List<ChangeInfo>> res = json.create(options)
|
List<List<ChangeInfo>> res = json.create(options)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.query.change;
|
package com.google.gerrit.server.query.change;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.account.CapabilityControl;
|
import com.google.gerrit.server.account.CapabilityControl;
|
||||||
import com.google.gerrit.server.account.GroupMembership;
|
import com.google.gerrit.server.account.GroupMembership;
|
||||||
@@ -42,9 +41,4 @@ public final class SingleGroupUser extends CurrentUser {
|
|||||||
public GroupMembership getEffectiveGroups() {
|
public GroupMembership getEffectiveGroups() {
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Change.Id> getStarredChanges() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,8 +95,6 @@ public class IdentifiedUserTest {
|
|||||||
bind(CapabilityControl.Factory.class)
|
bind(CapabilityControl.Factory.class)
|
||||||
.toProvider(Providers.<CapabilityControl.Factory>of(null));
|
.toProvider(Providers.<CapabilityControl.Factory>of(null));
|
||||||
bind(Realm.class).toInstance(mockRealm);
|
bind(Realm.class).toInstance(mockRealm);
|
||||||
bind(StarredChangesUtil.class)
|
|
||||||
.toProvider(Providers.<StarredChangesUtil> of(null));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class FakeQueryBuilder extends ChangeQueryBuilder {
|
|||||||
FakeQueryBuilder.class),
|
FakeQueryBuilder.class),
|
||||||
new ChangeQueryBuilder.Arguments(null, null, null, null, null, null,
|
new ChangeQueryBuilder.Arguments(null, null, null, null, null, null,
|
||||||
null, null, null, null, null, null, null, null, null, null, null,
|
null, null, null, null, null, null, null, null, null, null, null,
|
||||||
null, null, null, indexes, null, null, null, null, null, null));
|
null, null, null, indexes, null, null, null, null, null, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operator
|
@Operator
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import com.google.gerrit.server.CurrentUser;
|
|||||||
import com.google.gerrit.server.GerritPersonIdent;
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.InternalUser;
|
import com.google.gerrit.server.InternalUser;
|
||||||
import com.google.gerrit.server.StarredChangesUtil;
|
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
import com.google.gerrit.server.account.AccountCache;
|
||||||
import com.google.gerrit.server.account.CapabilityControl;
|
import com.google.gerrit.server.account.CapabilityControl;
|
||||||
import com.google.gerrit.server.account.FakeRealm;
|
import com.google.gerrit.server.account.FakeRealm;
|
||||||
@@ -169,8 +168,6 @@ public abstract class AbstractChangeNotesTest extends GerritBaseTests {
|
|||||||
.toInstance(serverIdent);
|
.toInstance(serverIdent);
|
||||||
bind(GitReferenceUpdated.class)
|
bind(GitReferenceUpdated.class)
|
||||||
.toInstance(GitReferenceUpdated.DISABLED);
|
.toInstance(GitReferenceUpdated.DISABLED);
|
||||||
bind(StarredChangesUtil.class)
|
|
||||||
.toProvider(Providers.<StarredChangesUtil> of(null));
|
|
||||||
bind(MetricMaker.class).to(DisabledMetricMaker.class);
|
bind(MetricMaker.class).to(DisabledMetricMaker.class);
|
||||||
bind(ReviewDb.class).toProvider(Providers.<ReviewDb> of(null));
|
bind(ReviewDb.class).toProvider(Providers.<ReviewDb> of(null));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import com.google.gerrit.common.data.PermissionRange;
|
|||||||
import com.google.gerrit.common.data.PermissionRule;
|
import com.google.gerrit.common.data.PermissionRule;
|
||||||
import com.google.gerrit.common.errors.InvalidNameException;
|
import com.google.gerrit.common.errors.InvalidNameException;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
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.rules.PrologEnvironment;
|
import com.google.gerrit.rules.PrologEnvironment;
|
||||||
@@ -907,10 +906,5 @@ public class RefControlTest {
|
|||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Change.Id> getStarredChanges() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Submodule plugins/replication updated: b3ab82de95...5f91046e32
Reference in New Issue
Block a user