From f762b160efd5cafd919a6fd7f9587f578eceb454 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Sun, 02 Oct 2011 16:59:44 -0400 Subject: [PATCH] Merge branch 'master' into rpc --- src/com/gitblit/GitBlit.java | 39 +++++++++++++++++++++++++++++++++------ 1 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index c35340a..1727038 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -59,13 +59,14 @@ import com.gitblit.Constants.FederationToken; import com.gitblit.models.FederationModel; import com.gitblit.models.FederationProposal; +import com.gitblit.models.FederationSet; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; +import com.gitblit.utils.ByteFormat; import com.gitblit.utils.FederationUtils; import com.gitblit.utils.JGitUtils; +import com.gitblit.utils.JsonUtils; import com.gitblit.utils.StringUtils; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; /** * GitBlit is the servlet context listener singleton that acts as the core for @@ -530,6 +531,10 @@ model.origin = config.getString("remote", "origin", "url"); } r.close(); + if (getBoolean(Keys.web.showRepositorySizes, true)) { + ByteFormat byteFormat = new ByteFormat(); + model.size = byteFormat.format(calculateSize(model)); + } return model; } @@ -875,6 +880,29 @@ } /** + * Returns the list of federation sets. + * + * @return list of federation sets + */ + public List<FederationSet> getFederationSets(String gitblitUrl) { + List<FederationSet> list = new ArrayList<FederationSet>(); + // generate standard tokens + for (FederationToken type : FederationToken.values()) { + FederationSet fset = new FederationSet(type.toString(), type, getFederationToken(type)); + fset.repositories = getRepositories(gitblitUrl, fset.token); + list.add(fset); + } + // generate tokens for federation sets + for (String set : settings.getStrings(Keys.federation.sets)) { + FederationSet fset = new FederationSet(set, FederationToken.REPOSITORIES, + getFederationToken(set)); + fset.repositories = getRepositories(gitblitUrl, fset.token); + list.add(fset); + } + return list; + } + + /** * Returns the list of possible federation tokens for this Gitblit instance. * * @return list of federation tokens @@ -978,8 +1006,7 @@ */ public boolean submitFederationProposal(FederationProposal proposal, String gitblitUrl) { // convert proposal to json - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - String json = gson.toJson(proposal); + String json = JsonUtils.toJsonString(proposal); try { // make the proposals folder @@ -1025,10 +1052,10 @@ && file.getName().toLowerCase().endsWith(Constants.PROPOSAL_EXT); } }); - Gson gson = new Gson(); for (File file : files) { String json = com.gitblit.utils.FileUtils.readContent(file, null); - FederationProposal proposal = gson.fromJson(json, FederationProposal.class); + FederationProposal proposal = JsonUtils.fromJsonString(json, + FederationProposal.class); list.add(proposal); } } -- Gitblit v1.9.1