James Moger
2013-07-24 d22773711cf6e7d730e5542d01312ff1965554ba
src/main/java/com/gitblit/GitBlit.java
@@ -84,6 +84,7 @@
import com.gitblit.Constants.AccessPermission;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.Constants.AccountType;
import com.gitblit.Constants.AuthenticationType;
import com.gitblit.Constants.AuthorizationControl;
import com.gitblit.Constants.FederationRequest;
@@ -121,6 +122,7 @@
import com.gitblit.utils.FederationUtils;
import com.gitblit.utils.HttpUtils;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.JGitUtils.LastChange;
import com.gitblit.utils.JsonUtils;
import com.gitblit.utils.MetricUtils;
import com.gitblit.utils.ObjectCache;
@@ -229,6 +231,33 @@
         new GitBlit();
      }
      return gitblit;
   }
   /**
    * Returns the boot date of the Gitblit server.
    *
    * @return the boot date of Gitblit
    */
   public static Date getBootDate() {
      return self().serverStatus.bootDate;
   }
   /**
    * Returns the most recent change date of any repository served by Gitblit.
    *
    * @return a date
    */
   public static Date getLastActivityDate() {
      Date date = null;
      for (String name : self().getRepositoryList()) {
         Repository r = self().getRepository(name);
         Date lastChange = JGitUtils.getLastChange(r).when;
         r.close();
         if (lastChange != null && (date == null || lastChange.after(date))) {
            date = lastChange;
         }
      }
      return date;
   }
   /**
@@ -694,12 +723,12 @@
   public boolean supportsCredentialChanges(UserModel user) {
      if (user == null) {
         return false;
      } else if (!Constants.EXTERNAL_ACCOUNT.equals(user.password)) {
         // credentials likely maintained by Gitblit
         return userService.supportsCredentialChanges();
      } else if (AccountType.LOCAL.equals(user.accountType)) {
         // local account, we can change credentials
         return true;
      } else {
         // credentials are externally maintained
         return false;
         // external account, ask user service
         return userService.supportsCredentialChanges();
      }
   }
@@ -1528,6 +1557,10 @@
    * @return repository or null
    */
   public Repository getRepository(String repositoryName, boolean logError) {
      // Decode url-encoded repository name (issue-278)
      // http://stackoverflow.com/questions/17183110
      repositoryName = repositoryName.replace("%7E", "~").replace("%7e", "~");
      if (isCollectingGarbage(repositoryName)) {
         logger.warn(MessageFormat.format("Rejecting request for {0}, busy collecting garbage!", repositoryName));
         return null;
@@ -1627,6 +1660,10 @@
    * @return repository model or null
    */
   public RepositoryModel getRepositoryModel(String repositoryName) {
      // Decode url-encoded repository name (issue-278)
      // http://stackoverflow.com/questions/17183110
      repositoryName = repositoryName.replace("%7E", "~").replace("%7e", "~");
      if (!repositoryListCache.containsKey(repositoryName)) {
         RepositoryModel model = loadRepositoryModel(repositoryName);
         if (model == null) {
@@ -1669,7 +1706,9 @@
            model.hasCommits = JGitUtils.hasCommits(r);
         }
         model.lastChange = JGitUtils.getLastChange(r);
         LastChange lc = JGitUtils.getLastChange(r);
         model.lastChange = lc.when;
         model.lastChangeAuthor = lc.who;
         if (!model.skipSizeCalculation) {
            ByteFormat byteFormat = new ByteFormat();
            model.size = byteFormat.format(calculateSize(model));
@@ -1973,7 +2012,9 @@
         model.name = repositoryName;
      }
      model.hasCommits = JGitUtils.hasCommits(r);
      model.lastChange = JGitUtils.getLastChange(r);
      LastChange lc = JGitUtils.getLastChange(r);
      model.lastChange = lc.when;
      model.lastChangeAuthor = lc.who;
      model.projectPath = StringUtils.getFirstPathElement(repositoryName);
      
      StoredConfig config = r.getConfig();
@@ -2047,6 +2088,9 @@
               File repoFolder = new File(getRepositoriesFolder(), originRepo);
               if (repoFolder.exists()) {
                  model.originRepository = originRepo.toLowerCase();
                  // persist the fork origin
                  updateConfiguration(r, model);
               }
            }
         } catch (URISyntaxException e) {