Make the GroupCache available to client side code
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.client.changes;
|
||||
|
||||
import com.google.gerrit.client.data.AccountInfoCacheFactory;
|
||||
import com.google.gerrit.client.data.ChangeDetail;
|
||||
import com.google.gerrit.client.data.GroupCache;
|
||||
import com.google.gerrit.client.data.PatchSetDetail;
|
||||
import com.google.gerrit.client.reviewdb.Change;
|
||||
import com.google.gerrit.client.reviewdb.PatchSet;
|
||||
@@ -28,8 +29,12 @@ import com.google.gwtorm.client.SchemaFactory;
|
||||
|
||||
public class ChangeDetailServiceImpl extends BaseServiceImplementation
|
||||
implements ChangeDetailService {
|
||||
public ChangeDetailServiceImpl(final SchemaFactory<ReviewDb> rdf) {
|
||||
private final GroupCache groupCache;
|
||||
|
||||
public ChangeDetailServiceImpl(final SchemaFactory<ReviewDb> rdf,
|
||||
final GroupCache groups) {
|
||||
super(rdf);
|
||||
groupCache = groups;
|
||||
}
|
||||
|
||||
public void changeDetail(final Change.Id id,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
package com.google.gerrit.client.data;
|
||||
|
||||
import com.google.gerrit.client.reviewdb.Account;
|
||||
import com.google.gerrit.client.reviewdb.AccountGroup;
|
||||
@@ -44,7 +44,7 @@ public class GroupCache {
|
||||
}
|
||||
};
|
||||
|
||||
protected GroupCache(final SchemaFactory<ReviewDb> rdf, final SystemConfig cfg) {
|
||||
public GroupCache(final SchemaFactory<ReviewDb> rdf, final SystemConfig cfg) {
|
||||
schema = rdf;
|
||||
adminGroupId = cfg.adminGroupId;
|
||||
anonymousGroupId = cfg.anonymousGroupId;
|
||||
@@ -164,6 +164,10 @@ public class GroupCache {
|
||||
* @return unmodifiable set listing the groups the account is a member of.
|
||||
*/
|
||||
public Set<AccountGroup.Id> getGroups(final Account.Id accountId) {
|
||||
if (accountId == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
Set<AccountGroup.Id> m;
|
||||
synchronized (byAccount) {
|
||||
m = byAccount.get(accountId);
|
||||
@@ -20,6 +20,7 @@ import com.google.gerrit.client.changes.ChangeDetailServiceImpl;
|
||||
public class ChangeDetailServiceSrv extends GerritJsonServlet {
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new ChangeDetailServiceImpl(GerritServer.getInstance().getDatabase());
|
||||
final GerritServer gs = GerritServer.getInstance();
|
||||
return new ChangeDetailServiceImpl(gs.getDatabase(), gs.getGroupCache());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server;
|
||||
import com.google.gerrit.client.data.ApprovalType;
|
||||
import com.google.gerrit.client.data.GerritConfig;
|
||||
import com.google.gerrit.client.data.GitwebLink;
|
||||
import com.google.gerrit.client.data.GroupCache;
|
||||
import com.google.gerrit.client.reviewdb.AccountGroup;
|
||||
import com.google.gerrit.client.reviewdb.ApprovalCategory;
|
||||
import com.google.gerrit.client.reviewdb.ApprovalCategoryValue;
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server;
|
||||
import com.google.gerrit.client.admin.AccountGroupDetail;
|
||||
import com.google.gerrit.client.admin.GroupAdminService;
|
||||
import com.google.gerrit.client.data.AccountInfoCacheFactory;
|
||||
import com.google.gerrit.client.data.GroupCache;
|
||||
import com.google.gerrit.client.reviewdb.Account;
|
||||
import com.google.gerrit.client.reviewdb.AccountGroup;
|
||||
import com.google.gerrit.client.reviewdb.AccountGroupMember;
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server;
|
||||
|
||||
import com.google.gerrit.client.admin.ProjectAdminService;
|
||||
import com.google.gerrit.client.admin.ProjectDetail;
|
||||
import com.google.gerrit.client.data.GroupCache;
|
||||
import com.google.gerrit.client.reviewdb.Account;
|
||||
import com.google.gerrit.client.reviewdb.AccountGroup;
|
||||
import com.google.gerrit.client.reviewdb.ApprovalCategory;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.ssh;
|
||||
|
||||
import com.google.gerrit.server.GroupCache;
|
||||
import com.google.gerrit.client.data.GroupCache;
|
||||
|
||||
/** Causes the {@link GroupCache} to purge all entries and reload. */
|
||||
class AdminFlushGroupCache extends AbstractCommand {
|
||||
|
||||
Reference in New Issue
Block a user