diff options
author | James Moger <james.moger@gitblit.com> | 2012-10-30 17:01:57 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2012-10-30 17:01:57 -0400 |
commit | e26d9338ddc5f0f0440947e60013a57b82043783 (patch) | |
tree | 753d7620585655734292ee66adc7f44b550d20be /src/com/gitblit/GitBlit.java | |
parent | f5cbd026002eed8209368e9071726dfb67183e81 (diff) | |
download | gitblit-e26d9338ddc5f0f0440947e60013a57b82043783.tar.gz gitblit-e26d9338ddc5f0f0440947e60013a57b82043783.zip |
Refactor GC period into an integer for simpler translations
Also hooked-up GC settings in the Manager.
Diffstat (limited to 'src/com/gitblit/GitBlit.java')
-rw-r--r-- | src/com/gitblit/GitBlit.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 6e587caa..e7b7bb9b 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -1445,7 +1445,7 @@ public class GitBlit implements ServletContextListener { 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 +1730,27 @@ public class GitBlit implements ServletContextListener { 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 +1917,7 @@ public class GitBlit implements ServletContextListener { 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));
}
|