Remove Common class entirely

We no longer depend upon the Common class, and can now instead get
the configuration from the Gerrit object on the client, and not have
it at all on the server, except in the web mode, where we need it for
the host page to pass do the client.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-08-06 17:20:06 -07:00
parent 94c33ce154
commit cd5a8d4a31
21 changed files with 60 additions and 109 deletions

View File

@@ -14,10 +14,10 @@
package com.google.gerrit.client;
import com.google.gerrit.client.data.GerritConfig;
import com.google.gerrit.client.data.SystemInfoService;
import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.reviewdb.AccountGeneralPreferences;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.LinkMenuBar;
import com.google.gerrit.client.ui.LinkMenuItem;
@@ -70,6 +70,7 @@ public class Gerrit implements EntryPoint {
private static String myHost;
private static String myVersion;
private static GerritConfig myConfig;
private static Account myAccount;
private static final HandlerManager globalHandlers = new HandlerManager(true);
@@ -122,6 +123,11 @@ public class Gerrit implements EntryPoint {
}
}
/** Get the public configuration data used by this Gerrit instance. */
public static GerritConfig getConfig() {
return myConfig;
}
/** @return the currently signed in user's account data; null if no account */
public static Account getUserAccount() {
return myAccount;
@@ -209,7 +215,7 @@ public class Gerrit implements EntryPoint {
final HostPageDataService hpd = GWT.create(HostPageDataService.class);
hpd.load(new GerritCallback<HostPageData>() {
public void onSuccess(final HostPageData result) {
Common.setGerritConfig(result.config);
myConfig = result.config;
if (result.xsrfToken != null) {
JsonUtil.getDefaultXsrfManager().setToken(null, result.xsrfToken);
}
@@ -344,7 +350,7 @@ public class Gerrit implements EntryPoint {
if (signedIn) {
whoAmI();
addLink(menuRight, C.menuSettings(), Link.SETTINGS);
switch (Common.getGerritConfig().getLoginType()) {
switch (getConfig().getLoginType()) {
case HTTP:
break;
@@ -358,7 +364,7 @@ public class Gerrit implements EntryPoint {
break;
}
} else {
switch (Common.getGerritConfig().getLoginType()) {
switch (getConfig().getLoginType()) {
case HTTP:
break;

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.client;
import com.google.gerrit.client.openid.OpenIdLoginPanel;
import com.google.gerrit.client.rpc.Common;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
@@ -72,7 +71,7 @@ public class SignInDialog extends AutoCenterDialogBox {
public SignInDialog(final Mode signInMode, final String errorMsg) {
super(/* auto hide */true, /* modal */true);
switch (Common.getGerritConfig().getLoginType()) {
switch (Gerrit.getConfig().getLoginType()) {
case OPENID:
panel = new OpenIdLoginPanel(signInMode, errorMsg);
break;

View File

@@ -19,7 +19,6 @@ import static com.google.gerrit.client.FormatUtil.mediumFormat;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.Link;
import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.ui.AccountScreen;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
@@ -130,7 +129,7 @@ public class AccountSettings extends AccountScreen {
}, Util.C.tabWebIdentities());
tabTokens.add(Link.SETTINGS_WEBIDENT);
if (Common.getGerritConfig().isUseContributorAgreements()) {
if (Gerrit.getConfig().isUseContributorAgreements()) {
tabs.add(new LazyPanel() {
@Override
protected AgreementPanel createWidget() {

View File

@@ -14,9 +14,9 @@
package com.google.gerrit.client.account;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.reviewdb.ContactInformation;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.ui.TextSaveButtonListener;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
@@ -65,7 +65,7 @@ class ContactPanelFull extends ContactPanelShort {
hasContact.setStyleName("gerrit-AccountContactOnFile");
hasContact.setVisible(false);
if (Common.getGerritConfig().isUseContactInfo()) {
if (Gerrit.getConfig().isUseContactInfo()) {
body.add(privhtml);
body.add(hasContact);
body.add(infoSecure);
@@ -116,7 +116,7 @@ class ContactPanelFull extends ContactPanelShort {
@Override
ContactInformation toContactInformation() {
final ContactInformation info;
if (Common.getGerritConfig().isUseContactInfo()) {
if (Gerrit.getConfig().isUseContactInfo()) {
info = new ContactInformation();
info.setAddress(addressTxt.getText());
info.setCountry(countryTxt.getText());

View File

@@ -18,7 +18,6 @@ import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.reviewdb.AccountExternalId;
import com.google.gerrit.client.reviewdb.ContactInformation;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.TextSaveButtonListener;
import com.google.gwt.event.dom.client.ChangeEvent;
@@ -96,7 +95,7 @@ class ContactPanelShort extends Composite {
});
final FlowPanel emailLine = new FlowPanel();
emailLine.add(emailPick);
if (Common.getGerritConfig().isAllowRegisterNewEmail()) {
if (Gerrit.getConfig().isAllowRegisterNewEmail()) {
emailLine.add(registerNewEmail);
}
@@ -210,7 +209,7 @@ class ContactPanelShort extends Composite {
if (emailPick.getItemCount() > 0) {
emailPick.setVisible(true);
emailPick.setEnabled(true);
if (Common.getGerritConfig().isAllowRegisterNewEmail()) {
if (Gerrit.getConfig().isAllowRegisterNewEmail()) {
final String t = Util.C.buttonOpenRegisterNewEmail();
emailPick.addItem("... " + t + " ", t);
}
@@ -235,7 +234,7 @@ class ContactPanelShort extends Composite {
}
private void doRegisterNewEmail() {
if (!Common.getGerritConfig().isAllowRegisterNewEmail()) {
if (!Gerrit.getConfig().isAllowRegisterNewEmail()) {
return;
}

View File

@@ -15,9 +15,9 @@
package com.google.gerrit.client.account;
import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.SignInDialog;
import com.google.gerrit.client.reviewdb.AccountExternalId;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -51,7 +51,7 @@ class ExternalIdPanel extends Composite {
});
body.add(deleteIdentity);
switch (Common.getGerritConfig().getLoginType()) {
switch (Gerrit.getConfig().getLoginType()) {
case OPENID: {
final Button linkIdentity = new Button(Util.C.buttonLinkIdentity());
linkIdentity.addClickHandler(new ClickHandler() {

View File

@@ -14,9 +14,9 @@
package com.google.gerrit.client.account;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.Link;
import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.ui.AccountScreen;
import com.google.gerrit.client.ui.SmallHeading;
import com.google.gwt.user.client.ui.FlowPanel;
@@ -80,7 +80,7 @@ public class RegisterScreen extends AccountScreen {
final FlowPanel choices = new FlowPanel();
choices.setStyleName("gerrit-RegisterScreen-NextLinks");
if (Common.getGerritConfig().isUseContributorAgreements()) {
if (Gerrit.getConfig().isUseContributorAgreements()) {
final FlowPanel agreementGroup = new FlowPanel();
agreementGroup.setStyleName("gerrit-RegisterScreen-Section");
agreementGroup.add(new SmallHeading(Util.C.welcomeAgreementHeading()));

View File

@@ -17,8 +17,6 @@ package com.google.gerrit.client.admin;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.Link;
import com.google.gerrit.client.reviewdb.Project;
import com.google.gerrit.client.reviewdb.ProjectRight;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.AccountScreen;
import com.google.gwt.event.logical.shared.SelectionEvent;
@@ -74,7 +72,7 @@ public class ProjectAdminScreen extends AccountScreen {
}, Util.C.projectAdminTabGeneral());
tabTokens.add(Link.toProjectAdmin(projectName, INFO_TAB));
if (!Common.getGerritConfig().getWildProject().equals(projectName)) {
if (!Gerrit.getConfig().getWildProject().equals(projectName)) {
tabs.add(new LazyPanel() {
@Override
protected ProjectBranchesPanel createWidget() {

View File

@@ -14,10 +14,10 @@
package com.google.gerrit.client.admin;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.data.GitwebLink;
import com.google.gerrit.client.reviewdb.Branch;
import com.google.gerrit.client.reviewdb.Project;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.InvalidNameException;
import com.google.gerrit.client.rpc.InvalidRevisionException;
@@ -260,7 +260,7 @@ public class ProjectBranchesPanel extends Composite {
}
void populate(final int row, final Branch k) {
final GitwebLink c = Common.getGerritConfig().getGitwebLink();
final GitwebLink c = Gerrit.getConfig().getGitwebLink();
table.setWidget(row, 1, new CheckBox());
table.setText(row, 2, k.getShortName());

View File

@@ -14,9 +14,8 @@
package com.google.gerrit.client.admin;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.reviewdb.Project;
import com.google.gerrit.client.reviewdb.ProjectRight;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.SmallHeading;
import com.google.gerrit.client.ui.TextSaveButtonListener;
@@ -164,10 +163,10 @@ public class ProjectInfoPanel extends Composite {
project = result.project;
final boolean isall =
Common.getGerritConfig().getWildProject().equals(project.getNameKey());
Gerrit.getConfig().getWildProject().equals(project.getNameKey());
submitTypePanel.setVisible(!isall);
agreementsPanel.setVisible(!isall);
useContributorAgreements.setVisible(Common.getGerritConfig()
useContributorAgreements.setVisible(Gerrit.getConfig()
.isUseContributorAgreements());
descTxt.setText(project.getDescription());

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.client.admin;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.data.ApprovalType;
import com.google.gerrit.client.data.GerritConfig;
import com.google.gerrit.client.reviewdb.AccountGroup;
@@ -21,7 +22,6 @@ import com.google.gerrit.client.reviewdb.ApprovalCategory;
import com.google.gerrit.client.reviewdb.ApprovalCategoryValue;
import com.google.gerrit.client.reviewdb.Project;
import com.google.gerrit.client.reviewdb.ProjectRight;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountGroupSuggestOracle;
import com.google.gerrit.client.ui.FancyFlexTable;
@@ -113,15 +113,15 @@ public class ProjectRightsPanel extends Composite {
populateRangeBoxes();
}
});
for (final ApprovalType at : Common.getGerritConfig().getApprovalTypes()
for (final ApprovalType at : Gerrit.getConfig().getApprovalTypes()
.getApprovalTypes()) {
final ApprovalCategory c = at.getCategory();
catBox.addItem(c.getName(), c.getId().get());
}
for (final ApprovalType at : Common.getGerritConfig().getApprovalTypes()
for (final ApprovalType at : Gerrit.getConfig().getApprovalTypes()
.getActionTypes()) {
final ApprovalCategory c = at.getCategory();
if (Common.getGerritConfig().getWildProject().equals(projectName)
if (Gerrit.getConfig().getWildProject().equals(projectName)
&& ApprovalCategory.OWN.equals(c.getId())) {
// Giving out control of the WILD_PROJECT to other groups beyond
// Administrators is dangerous. Having control over WILD_PROJECT
@@ -210,7 +210,7 @@ public class ProjectRightsPanel extends Composite {
return;
}
at =
Common.getGerritConfig().getApprovalTypes().getApprovalType(
Gerrit.getConfig().getApprovalTypes().getApprovalType(
new ApprovalCategory.Id(catBox.getValue(idx)));
if (at == null) {
return;
@@ -272,7 +272,7 @@ public class ProjectRightsPanel extends Composite {
final ApprovalType at;
if (idx >= 0) {
at =
Common.getGerritConfig().getApprovalTypes().getApprovalType(
Gerrit.getConfig().getApprovalTypes().getApprovalType(
new ApprovalCategory.Id(catBox.getValue(idx)));
} else {
at = null;
@@ -368,14 +368,13 @@ public class ProjectRightsPanel extends Composite {
void populate(final int row,
final Map<AccountGroup.Id, AccountGroup> groups, final ProjectRight k) {
final GerritConfig config = Common.getGerritConfig();
final GerritConfig config = Gerrit.getConfig();
final ApprovalType ar =
config.getApprovalTypes().getApprovalType(k.getApprovalCategoryId());
final AccountGroup group = groups.get(k.getAccountGroupId());
if (Common.getGerritConfig().getWildProject().equals(
k.getProjectNameKey())
&& !Common.getGerritConfig().getWildProject().equals(projectName)) {
if (Gerrit.getConfig().getWildProject().equals(k.getProjectNameKey())
&& !Gerrit.getConfig().getWildProject().equals(projectName)) {
table.setText(row, 1, "");
} else {
table.setWidget(row, 1, new CheckBox());

View File

@@ -27,7 +27,6 @@ import com.google.gerrit.client.reviewdb.ApprovalCategory;
import com.google.gerrit.client.reviewdb.ApprovalCategoryValue;
import com.google.gerrit.client.reviewdb.Change;
import com.google.gerrit.client.reviewdb.PatchSetApproval;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountDashboardLink;
import com.google.gerrit.client.ui.AddMemberBox;
@@ -60,7 +59,7 @@ public class ApprovalTable extends Composite {
private AccountInfoCache accountCache = AccountInfoCache.empty();
public ApprovalTable() {
types = Common.getGerritConfig().getApprovalTypes().getApprovalTypes();
types = Gerrit.getConfig().getApprovalTypes().getApprovalTypes();
table = new Grid(1, 3 + types.size());
table.addStyleName("gerrit-InfoTable");
displayHeader();

View File

@@ -24,7 +24,6 @@ import com.google.gerrit.client.data.GitwebLink;
import com.google.gerrit.client.reviewdb.Change;
import com.google.gerrit.client.reviewdb.ChangeMessage;
import com.google.gerrit.client.reviewdb.PatchSet;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
@@ -254,7 +253,7 @@ public class ChangeScreen extends Screen {
patchSetPanels.clear();
final PatchSet currps = detail.getCurrentPatchSet();
final GitwebLink gw = Common.getGerritConfig().getGitwebLink();
final GitwebLink gw = Gerrit.getConfig().getGitwebLink();
for (final PatchSet ps : detail.getPatchSets()) {
final ComplexDisclosurePanel panel =
new ComplexDisclosurePanel(Util.M.patchSetHeader(ps.getPatchSetId()),

View File

@@ -29,7 +29,6 @@ import com.google.gerrit.client.reviewdb.PatchSet;
import com.google.gerrit.client.reviewdb.PatchSetInfo;
import com.google.gerrit.client.reviewdb.Project;
import com.google.gerrit.client.reviewdb.UserIdentity;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountDashboardLink;
import com.google.gerrit.client.ui.RefreshListener;
@@ -179,7 +178,7 @@ class PatchSetPanel extends Composite implements OpenHandler<DisclosurePanel> {
final String projectName = projectKey.get();
final FlowPanel downloads = new FlowPanel();
if (Common.getGerritConfig().isUseRepoDownload()) {
if (Gerrit.getConfig().isUseRepoDownload()) {
// This site prefers usage of the 'repo' tool, so suggest
// that for easy fetch.
//
@@ -194,28 +193,28 @@ class PatchSetPanel extends Composite implements OpenHandler<DisclosurePanel> {
}
if (changeDetail.isAllowsAnonymous()
&& Common.getGerritConfig().getGitDaemonUrl() != null) {
&& Gerrit.getConfig().getGitDaemonUrl() != null) {
// Anonymous Git is claimed to be available, and this project
// isn't secured. The anonymous Git daemon will be much more
// efficient than our own SSH daemon, so prefer offering it.
//
final StringBuilder r = new StringBuilder();
r.append("git pull ");
r.append(Common.getGerritConfig().getGitDaemonUrl());
r.append(Gerrit.getConfig().getGitDaemonUrl());
r.append(projectName);
r.append(" ");
r.append(patchSet.getRefName());
downloads.add(new CopyableLabel(r.toString()));
} else if (Gerrit.isSignedIn() && Gerrit.getUserAccount() != null
&& Common.getGerritConfig().getSshdAddress() != null
&& Gerrit.getConfig().getSshdAddress() != null
&& Gerrit.getUserAccount().getSshUserName() != null
&& Gerrit.getUserAccount().getSshUserName().length() > 0) {
// The user is signed in and anonymous access isn't allowed.
// Use our SSH daemon URL as its the only way they can get
// to the project (that we know of anyway).
//
final String sshAddr = Common.getGerritConfig().getSshdAddress();
final String sshAddr = Gerrit.getConfig().getSshdAddress();
final StringBuilder r = new StringBuilder();
r.append("git pull ssh://");
r.append(Gerrit.getUserAccount().getSshUserName());
@@ -274,7 +273,7 @@ class PatchSetPanel extends Composite implements OpenHandler<DisclosurePanel> {
return;
}
for (final ApprovalType at : Common.getGerritConfig().getApprovalTypes()
for (final ApprovalType at : Gerrit.getConfig().getApprovalTypes()
.getActionTypes()) {
final ApprovalCategoryValue max = at.getMax();
if (max == null || max.getValue() <= 0) {

View File

@@ -26,7 +26,6 @@ import com.google.gerrit.client.reviewdb.Patch;
import com.google.gerrit.client.reviewdb.PatchLineComment;
import com.google.gerrit.client.reviewdb.PatchSet;
import com.google.gerrit.client.reviewdb.PatchSetApproval;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.AccountScreen;
@@ -172,7 +171,7 @@ public class PublishCommentScreen extends AccountScreen implements ClickHandler
}
private void initApprovals(final PatchSetPublishDetail r, final Panel body) {
for (final ApprovalType ct : Common.getGerritConfig().getApprovalTypes()
for (final ApprovalType ct : Gerrit.getConfig().getApprovalTypes()
.getApprovalTypes()) {
if (r.isAllowed(ct.getCategory().getId())) {
initApprovalType(r, body, ct);

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.client.reviewdb;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.Gerrit;
import com.google.gwtorm.client.Column;
import com.google.gwtorm.client.StringKey;
@@ -142,7 +142,7 @@ public final class AccountExternalId {
}
public boolean canUserDelete() {
switch (Common.getGerritConfig().getLoginType()) {
switch (Gerrit.getConfig().getLoginType()) {
case OPENID:
if (getExternalId().startsWith("Google Account ")) {
// Don't allow users to delete legacy google account tokens.

View File

@@ -1,30 +0,0 @@
// Copyright (C) 2008 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.rpc;
import com.google.gerrit.client.data.GerritConfig;
public class Common {
private static GerritConfig config;
/** Get the public configuration data used by this Gerrit instance. */
public static GerritConfig getGerritConfig() {
return config;
}
public static void setGerritConfig(final GerritConfig imp) {
config = imp;
}
}

View File

@@ -14,17 +14,12 @@
package com.google.gerrit.pgm;
import static com.google.inject.Scopes.SINGLETON;
import static com.google.inject.Stage.PRODUCTION;
import com.google.gerrit.client.data.GerritConfig;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.server.config.DatabaseModule;
import com.google.gerrit.server.config.GerritConfigProvider;
import com.google.gerrit.server.config.GerritGlobalModule;
import com.google.gerrit.server.ssh.SshDaemon;
import com.google.gerrit.server.ssh.SshModule;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
@@ -34,20 +29,7 @@ public class Daemon extends AbstractProgram {
public int run() throws Exception {
final Injector injector =
Guice.createInjector(PRODUCTION, new DatabaseModule(),
new GerritGlobalModule(), new SshModule(),
new AbstractModule() {
@Override
protected void configure() {
bind(GerritConfig.class).toProvider(GerritConfigProvider.class)
.in(SINGLETON);
}
});
// This is a hack to force the GerritConfig to install itself into
// Common.setGerritConfig. If we don't do this here in the daemon
// it won't inject in time for things that demand it. This must die.
//
Common.setGerritConfig(injector.getInstance(GerritConfig.class));
new GerritGlobalModule(), new SshModule());
injector.getInstance(SshDaemon.class).start();
return never();

View File

@@ -18,7 +18,6 @@ import com.google.gerrit.client.data.ApprovalTypes;
import com.google.gerrit.client.data.GerritConfig;
import com.google.gerrit.client.data.GitwebLink;
import com.google.gerrit.client.reviewdb.Project;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.server.ContactStore;
import com.google.gerrit.server.mail.EmailSender;
import com.google.gerrit.server.ssh.SshInfo;
@@ -108,7 +107,6 @@ public class GerritConfigProvider implements Provider<GerritConfig> {
config.setSshdAddress(host);
}
Common.setGerritConfig(config);
return config;
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.workflow;
import com.google.gerrit.client.data.ApprovalType;
import com.google.gerrit.client.data.ApprovalTypes;
import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.reviewdb.AccountGroup;
import com.google.gerrit.client.reviewdb.ApprovalCategory;
@@ -37,6 +38,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -47,6 +49,7 @@ public class FunctionState {
Collection<PatchSetApproval> all);
}
private final ApprovalTypes approvalTypes;
private final AccountCache accountCache;
private final ProjectCache projectCache;
@@ -63,10 +66,11 @@ public class FunctionState {
private Set<PatchSetApproval> modified;
@Inject
FunctionState(final ProjectCache pc, final AccountCache ac,
final GroupCache egc, @Assisted final Change c,
FunctionState(final ApprovalTypes approvalTypes, final ProjectCache pc,
final AccountCache ac, final GroupCache egc, @Assisted final Change c,
@Assisted final PatchSet.Id psId,
@Assisted final Collection<PatchSetApproval> all) {
this.approvalTypes = approvalTypes;
projectCache = pc;
accountCache = ac;
@@ -85,6 +89,10 @@ public class FunctionState {
}
}
List<ApprovalType> getApprovalTypes() {
return approvalTypes.getApprovalTypes();
}
public Change getChange() {
return change;
}

View File

@@ -18,7 +18,6 @@ import com.google.gerrit.client.data.ApprovalType;
import com.google.gerrit.client.reviewdb.ApprovalCategory;
import com.google.gerrit.client.reviewdb.Change;
import com.google.gerrit.client.reviewdb.ProjectRight;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.server.CurrentUser;
/**
@@ -57,8 +56,7 @@ public class SubmitFunction extends CategoryFunction {
if (state.getChange().getStatus() != Change.Status.NEW) {
return false;
}
for (final ApprovalType t : Common.getGerritConfig().getApprovalTypes()
.getApprovalTypes()) {
for (final ApprovalType t : state.getApprovalTypes()) {
if (!state.isValid(t)) {
return false;
}