From a7a0b8ea01dca14602fdb49047d987c36461e861 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Tue, 26 Nov 2013 16:07:04 -0500
Subject: [PATCH] Refactor access to home page class
---
src/main/java/com/gitblit/GitBlit.java | 33 ++++++++++++++++++++++++++++-----
1 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java
index f313b6e..6d52e76 100644
--- a/src/main/java/com/gitblit/GitBlit.java
+++ b/src/main/java/com/gitblit/GitBlit.java
@@ -164,7 +164,7 @@
private final Logger logger = LoggerFactory.getLogger(GitBlit.class);
- private final ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(5);
+ private final ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(10);
private final List<FederationModel> federationRegistrations = Collections
.synchronizedList(new ArrayList<FederationModel>());
@@ -206,6 +206,8 @@
private LuceneExecutor luceneExecutor;
private GCExecutor gcExecutor;
+
+ private MirrorExecutor mirrorExecutor;
private TimeZone timezone;
@@ -2004,7 +2006,6 @@
model.description = getConfig(config, "description", "");
model.originRepository = getConfig(config, "originRepository", null);
model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
- model.useDocs = getConfig(config, "useDocs", false);
model.useIncrementalPushTags = getConfig(config, "useIncrementalPushTags", false);
model.incrementalPushTagPrefix = getConfig(config, "incrementalPushTagPrefix", null);
model.allowForks = getConfig(config, "allowForks", true);
@@ -2035,6 +2036,7 @@
model.origin = config.getString("remote", "origin", "url");
if (model.origin != null) {
model.origin = model.origin.replace('\\', '/');
+ model.isMirror = config.getBoolean("remote", "origin", "mirror", false);
}
model.preReceiveScripts = new ArrayList<String>(Arrays.asList(config.getStringList(
Constants.CONFIG_GITBLIT, null, "preReceiveScript")));
@@ -2563,7 +2565,6 @@
config.setString(Constants.CONFIG_GITBLIT, null, "description", repository.description);
config.setString(Constants.CONFIG_GITBLIT, null, "originRepository", repository.originRepository);
config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners));
- config.setBoolean(Constants.CONFIG_GITBLIT, null, "useDocs", repository.useDocs);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useIncrementalPushTags", repository.useIncrementalPushTags);
if (StringUtils.isEmpty(repository.incrementalPushTagPrefix) ||
repository.incrementalPushTagPrefix.equals(settings.getString(Keys.git.defaultIncrementalPushTagPrefix, "r"))) {
@@ -3505,6 +3506,7 @@
mailExecutor = new MailExecutor(settings);
luceneExecutor = new LuceneExecutor(settings, repositoriesFolder);
gcExecutor = new GCExecutor(settings);
+ mirrorExecutor = new MirrorExecutor(settings);
// initialize utilities
String prefix = settings.getString(Keys.git.userRepositoryPrefix, "~");
@@ -3544,6 +3546,7 @@
configureMailExecutor();
configureLuceneIndexing();
configureGarbageCollector();
+ configureMirrorExecutor();
if (startFederation) {
configureFederation();
}
@@ -3551,8 +3554,6 @@
configureFanout();
configureGitDaemon();
configureCommitCache();
-
- ContainerUtils.CVE_2007_0450.test();
}
protected void configureMailExecutor() {
@@ -3592,6 +3593,19 @@
}
logger.info(MessageFormat.format("Next scheculed GC scan is in {0}", when));
scheduledExecutor.scheduleAtFixedRate(gcExecutor, delay, 60*24, TimeUnit.MINUTES);
+ }
+ }
+
+ protected void configureMirrorExecutor() {
+ if (mirrorExecutor.isReady()) {
+ int mins = TimeUtils.convertFrequencyToMinutes(settings.getString(Keys.git.mirrorPeriod, "30 mins"));
+ if (mins < 5) {
+ mins = 5;
+ }
+ int delay = 1;
+ scheduledExecutor.scheduleAtFixedRate(mirrorExecutor, delay, mins, TimeUnit.MINUTES);
+ logger.info("Mirror executor is scheduled to fetch updates every {} minutes.", mins);
+ logger.info("Next scheduled mirror fetch is in {} minutes", delay);
}
}
@@ -3758,6 +3772,10 @@
}
}
+ // disable Git daemon on Express - we can't bind 9418 and we
+ // can't port-forward to the daemon
+ webxmlSettings.overrideSetting(Keys.git.daemonPort, 0);
+
// configure context using the web.xml
configureContext(webxmlSettings, base, true);
} else {
@@ -3801,6 +3819,10 @@
FileSettings settings = new FileSettings(localSettings.getAbsolutePath());
configureContext(settings, base, true);
}
+
+ // WAR or Express is likely to be running on a Tomcat.
+ // Test for the forward-slash/%2F issue and auto-adjust settings.
+ ContainerUtils.CVE_2007_0450.test(settings);
}
settingsModel = loadSettingModels();
@@ -3864,6 +3886,7 @@
scheduledExecutor.shutdownNow();
luceneExecutor.close();
gcExecutor.close();
+ mirrorExecutor.close();
if (fanoutService != null) {
fanoutService.stop();
}
--
Gitblit v1.9.1