Move the GerritConfig to the new Common class

Like the current user's Account.Id having fast access to the
(relatively) static GerritConfig is useful in both client and
server side code.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-01-06 16:24:06 -08:00
parent 3ed1b689db
commit ff0c05a2ff
12 changed files with 39 additions and 36 deletions

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.server;
import com.google.gerrit.client.changes.ChangeDetailServiceImpl;
import com.google.gerrit.client.data.GerritConfig;
import com.google.gerrit.client.data.GroupCache;
import com.google.gerrit.client.reviewdb.ReviewDb;
import com.google.gwtorm.client.SchemaFactory;
@@ -27,7 +26,6 @@ public class ChangeDetailServiceSrv extends GerritJsonServlet {
final GerritServer gs = GerritServer.getInstance();
final SchemaFactory<ReviewDb> rdf = gs.getDatabase();
final GroupCache groups = gs.getGroupCache();
final GerritConfig config = gs.getGerritConfig();
return new ChangeDetailServiceImpl(rdf, groups, config);
return new ChangeDetailServiceImpl(rdf, groups);
}
}

View File

@@ -24,6 +24,7 @@ import com.google.gerrit.client.reviewdb.ApprovalCategoryValue;
import com.google.gerrit.client.reviewdb.ProjectRight;
import com.google.gerrit.client.reviewdb.ReviewDb;
import com.google.gerrit.client.reviewdb.SystemConfig;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.git.RepositoryCache;
import com.google.gwtjsonrpc.server.SignedToken;
import com.google.gwtjsonrpc.server.XsrfException;
@@ -77,7 +78,6 @@ public class GerritServer {
private final Database<ReviewDb> db;
private SystemConfig sConfig;
private GerritConfig gerritConfig;
private final SignedToken xsrf;
private final SignedToken account;
private final RepositoryCache repositories;
@@ -287,7 +287,7 @@ public class GerritServer {
c.getId()).toList()));
}
gerritConfig = r;
Common.setGerritConfig(r);
}
/** Get the {@link ReviewDb} schema factory for the server. */
@@ -338,11 +338,6 @@ public class GerritServer {
return u;
}
/** Get the cached configuration data used by the client. */
public GerritConfig getGerritConfig() {
return gerritConfig;
}
/** Get the repositories maintained by this server. */
public RepositoryCache getRepositoryCache() {
return repositories;

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server;
import com.google.gerrit.client.rpc.Common;
import com.google.gwt.user.server.rpc.RPCServletUtils;
import com.google.gwtjsonrpc.server.XsrfException;
import com.google.gwtorm.client.OrmException;
@@ -66,7 +67,7 @@ public class HostPageServlet extends HttpServlet {
if (hostDoc == null) {
throw new ServletException("No " + hostPageName + " in CLASSPATH");
}
injectJson(hostDoc, "gerrit_gerritconfig", srv.getGerritConfig());
injectJson(hostDoc, "gerrit_gerritconfig", Common.getGerritConfig());
injectCssFile(hostDoc, "gerrit_sitecss", sitePath, "GerritSite.css");
injectXmlFile(hostDoc, "gerrit_header", sitePath, "GerritSiteHeader.html");
injectXmlFile(hostDoc, "gerrit_footer", sitePath, "GerritSiteFooter.html");

View File

@@ -18,6 +18,7 @@ import com.google.gerrit.client.data.GerritConfig;
import com.google.gerrit.client.data.SystemInfoService;
import com.google.gerrit.client.reviewdb.ContributorAgreement;
import com.google.gerrit.client.reviewdb.ReviewDb;
import com.google.gerrit.client.rpc.Common;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtorm.client.OrmException;
@@ -31,7 +32,7 @@ public class SystemInfoServiceImpl implements SystemInfoService {
}
public void loadGerritConfig(final AsyncCallback<GerritConfig> callback) {
callback.onSuccess(server.getGerritConfig());
callback.onSuccess(Common.getGerritConfig());
}
public void contributorAgreements(

View File

@@ -27,6 +27,7 @@ import com.google.gerrit.client.reviewdb.ChangeApproval;
import com.google.gerrit.client.reviewdb.ContactInformation;
import com.google.gerrit.client.reviewdb.ContributorAgreement;
import com.google.gerrit.client.reviewdb.PatchSet;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.git.PatchSetImporter;
import com.google.gerrit.server.GerritServer;
import com.google.gwtorm.client.OrmException;
@@ -466,7 +467,7 @@ class Receive extends AbstractGitCommand {
change.setCurrentPatchSet(imp.getPatchSetInfo());
db.changes().insert(Collections.singleton(change));
for (final ApprovalType t : server.getGerritConfig().getApprovalTypes()) {
for (final ApprovalType t : Common.getGerritConfig().getApprovalTypes()) {
final ApprovalCategoryValue v = t.getMax();
if (v != null) {
db.changeApprovals().insert(
@@ -528,7 +529,7 @@ class Receive extends AbstractGitCommand {
db.changeApprovals().update(Collections.singleton(a));
}
}
for (final ApprovalType t : server.getGerritConfig().getApprovalTypes()) {
for (final ApprovalType t : Common.getGerritConfig().getApprovalTypes()) {
final ApprovalCategoryValue v = t.getMax();
if (!have.contains(t.getCategory().getId()) && v != null) {
db.changeApprovals().insert(

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.ssh;
import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.server.GerritServer;
import com.google.gwtjsonrpc.server.XsrfException;
import com.google.gwtorm.client.OrmException;
@@ -67,7 +68,7 @@ public class SshServlet extends HttpServlet {
throw new ServletException("Cannot load GerritServer", e);
}
final int myPort = srv.getGerritConfig().getSshdPort();
final int myPort = Common.getGerritConfig().getSshdPort();
sshd = SshServer.setUpDefaultServer();
sshd.setPort(myPort);
sshd.setKeyPairProvider(new FileKeyPairProvider(new String[] {