From 717267cdf6fff130865c194dc33620ac1cd10a51 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 31 Oct 2012 08:50:20 -0400
Subject: [PATCH] Reject add if permission selector has not been set

---
 src/com/gitblit/GitBlit.java |   35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 6e587ca..e9b5e73 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -1048,6 +1048,16 @@
 					}
 				}
 				
+				// rebuild fork networks
+				for (RepositoryModel model : repositoryListCache.values()) {
+					if (!StringUtils.isEmpty(model.originRepository)) {
+						if (repositoryListCache.containsKey(model.originRepository)) {
+							RepositoryModel origin = repositoryListCache.get(model.originRepository);
+							origin.addFork(model.name);
+						}
+					}
+				}
+				
 				long duration = System.currentTimeMillis() - startTime;
 				logger.info(MessageFormat.format(msg, repositoryListCache.size(), duration));
 			}
@@ -1445,7 +1455,7 @@
 					Constants.CONFIG_GITBLIT, null, "federationSets")));
 			model.isFederated = getConfig(config, "isFederated", false);
 			model.gcThreshold = getConfig(config, "gcThreshold", settings.getString(Keys.git.defaultGarbageCollectionThreshold, "500KB"));
-			model.gcPeriod = getConfig(config, "gcPeriod", settings.getString(Keys.git.defaultGarbageCollectionPeriod, "7 days"));
+			model.gcPeriod = getConfig(config, "gcPeriod", settings.getInteger(Keys.git.defaultGarbageCollectionPeriod, 7));
 			try {
 				model.lastGC = new SimpleDateFormat(Constants.ISO8601).parse(getConfig(config, "lastGC", "1970-01-01'T'00:00:00Z"));
 			} catch (Exception e) {
@@ -1730,6 +1740,27 @@
 	private boolean getConfig(StoredConfig config, String field, boolean defaultValue) {
 		return config.getBoolean(Constants.CONFIG_GITBLIT, field, defaultValue);
 	}
+	
+	/**
+	 * Returns the gitblit string value for the specified key. If key is not
+	 * set, returns defaultValue.
+	 * 
+	 * @param config
+	 * @param field
+	 * @param defaultValue
+	 * @return field value or defaultValue
+	 */
+	private int getConfig(StoredConfig config, String field, int defaultValue) {
+		String value = config.getString(Constants.CONFIG_GITBLIT, null, field);
+		if (StringUtils.isEmpty(value)) {
+			return defaultValue;
+		}
+		try {
+			return Integer.parseInt(value);
+		} catch (Exception e) {
+		}
+		return defaultValue;
+	}
 
 	/**
 	 * Creates/updates the repository model keyed by reopsitoryName. Saves all
@@ -1896,7 +1927,7 @@
 				repository.federationStrategy.name());
 		config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFederated", repository.isFederated);
 		config.setString(Constants.CONFIG_GITBLIT, null, "gcThreshold", repository.gcThreshold);
-		config.setString(Constants.CONFIG_GITBLIT, null, "gcPeriod", repository.gcPeriod);
+		config.setInt(Constants.CONFIG_GITBLIT, null, "gcPeriod", repository.gcPeriod);
 		if (repository.lastGC != null) {
 			config.setString(Constants.CONFIG_GITBLIT, null, "lastGC", new SimpleDateFormat(Constants.ISO8601).format(repository.lastGC));
 		}

--
Gitblit v1.9.1