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:
		| @@ -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); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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"); | ||||
|   | ||||
| @@ -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( | ||||
|   | ||||
| @@ -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( | ||||
|   | ||||
| @@ -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[] { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Shawn O. Pearce
					Shawn O. Pearce