James Moger
2011-10-02 19c634873b49dea8b49fc54ca393153f7eb0eb35
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);
         }
      }