From 4fb6af1374106e082a27bd573dedbeb77ca75280 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 09 May 2013 22:49:16 -0400
Subject: [PATCH] Do not include clientapps.json in distribution files
---
src/main/java/com/gitblit/GitBlit.java | 351 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 273 insertions(+), 78 deletions(-)
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java
index 0452e1d..9346e0a 100644
--- a/src/main/java/com/gitblit/GitBlit.java
+++ b/src/main/java/com/gitblit/GitBlit.java
@@ -22,6 +22,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
+import java.lang.reflect.Type;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
@@ -54,6 +55,8 @@
import javax.mail.Message;
import javax.mail.MessagingException;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMultipart;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
@@ -69,7 +72,6 @@
import org.eclipse.jgit.lib.RepositoryCache.FileKey;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.storage.file.FileBasedConfig;
-import org.eclipse.jgit.storage.file.WindowCache;
import org.eclipse.jgit.storage.file.WindowCacheConfig;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
@@ -88,14 +90,17 @@
import com.gitblit.fanout.FanoutNioService;
import com.gitblit.fanout.FanoutService;
import com.gitblit.fanout.FanoutSocketService;
+import com.gitblit.git.GitDaemon;
import com.gitblit.models.FederationModel;
import com.gitblit.models.FederationProposal;
import com.gitblit.models.FederationSet;
import com.gitblit.models.ForkModel;
+import com.gitblit.models.GitClientApplication;
import com.gitblit.models.Metric;
import com.gitblit.models.ProjectModel;
import com.gitblit.models.RegistrantAccessPermission;
import com.gitblit.models.RepositoryModel;
+import com.gitblit.models.RepositoryUrl;
import com.gitblit.models.SearchResult;
import com.gitblit.models.ServerSettings;
import com.gitblit.models.ServerStatus;
@@ -118,6 +123,11 @@
import com.gitblit.utils.X509Utils.X509Metadata;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonIOException;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.reflect.TypeToken;
/**
* GitBlit is the servlet context listener singleton that acts as the core for
@@ -145,6 +155,9 @@
private final List<FederationModel> federationRegistrations = Collections
.synchronizedList(new ArrayList<FederationModel>());
+
+ private final List<GitClientApplication> clientApplications = Collections
+ .synchronizedList(new ArrayList<GitClientApplication>());
private final Map<String, FederationModel> federationPullResults = new ConcurrentHashMap<String, FederationModel>();
@@ -187,6 +200,8 @@
private FileBasedConfig projectConfigs;
private FanoutService fanoutService;
+
+ private GitDaemon gitDaemon;
public GitBlit() {
if (gitblit == null) {
@@ -446,20 +461,143 @@
serverStatus.heapFree = Runtime.getRuntime().freeMemory();
return serverStatus;
}
+
+ /**
+ * Returns a list of repository URLs and the user access permission.
+ *
+ * @param request
+ * @param user
+ * @param repository
+ * @return a list of repository urls
+ */
+ public List<RepositoryUrl> getRepositoryUrls(HttpServletRequest request, UserModel user, RepositoryModel repository) {
+ if (user == null) {
+ user = UserModel.ANONYMOUS;
+ }
+ String username = UserModel.ANONYMOUS.equals(user) ? "" : user.username;
+
+ List<RepositoryUrl> list = new ArrayList<RepositoryUrl>();
+ // http/https url
+ if (settings.getBoolean(Keys.git.enableGitServlet, true)) {
+ AccessPermission permission = user.getRepositoryPermission(repository).permission;
+ if (permission.exceeds(AccessPermission.NONE)) {
+ list.add(new RepositoryUrl(getRepositoryUrl(request, username, repository), permission));
+ }
+ }
+
+ // git daemon url
+ String gitDaemonUrl = getGitDaemonUrl(request, user, repository);
+ if (!StringUtils.isEmpty(gitDaemonUrl)) {
+ AccessPermission permission = getGitDaemonAccessPermission(user, repository);
+ if (permission.exceeds(AccessPermission.NONE)) {
+ list.add(new RepositoryUrl(gitDaemonUrl, permission));
+ }
+ }
+
+ // add all other urls
+ // {0} = repository
+ // {1} = username
+ for (String url : settings.getStrings(Keys.web.otherUrls)) {
+ if (url.contains("{1}")) {
+ // external url requires username, only add url IF we have one
+ if(!StringUtils.isEmpty(username)) {
+ list.add(new RepositoryUrl(MessageFormat.format(url, repository.name, username), null));
+ }
+ } else {
+ // external url does not require username
+ list.add(new RepositoryUrl(MessageFormat.format(url, repository.name), null));
+ }
+ }
+ return list;
+ }
+
+ protected String getRepositoryUrl(HttpServletRequest request, String username, RepositoryModel repository) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(HttpUtils.getGitblitURL(request));
+ sb.append(Constants.GIT_PATH);
+ sb.append(repository.name);
+
+ // inject username into repository url if authentication is required
+ if (repository.accessRestriction.exceeds(AccessRestrictionType.NONE)
+ && !StringUtils.isEmpty(username)) {
+ sb.insert(sb.indexOf("://") + 3, username + "@");
+ }
+ return sb.toString();
+ }
+
+ protected String getGitDaemonUrl(HttpServletRequest request, UserModel user, RepositoryModel repository) {
+ if (gitDaemon != null) {
+ String bindInterface = settings.getString(Keys.git.daemonBindInterface, "localhost");
+ if (bindInterface.equals("localhost")
+ && (!request.getServerName().equals("localhost") && !request.getServerName().equals("127.0.0.1"))) {
+ // git daemon is bound to localhost and the request is from elsewhere
+ return null;
+ }
+ if (user.canClone(repository)) {
+ String servername = request.getServerName();
+ String url = gitDaemon.formatUrl(servername, repository.name);
+ return url;
+ }
+ }
+ return null;
+ }
+
+ protected AccessPermission getGitDaemonAccessPermission(UserModel user, RepositoryModel repository) {
+ if (gitDaemon != null && user.canClone(repository)) {
+ AccessPermission gitDaemonPermission = user.getRepositoryPermission(repository).permission;
+ if (gitDaemonPermission.atLeast(AccessPermission.CLONE)) {
+ if (repository.accessRestriction.atLeast(AccessRestrictionType.CLONE)) {
+ // can not authenticate clone via anonymous git protocol
+ gitDaemonPermission = AccessPermission.NONE;
+ } else if (repository.accessRestriction.atLeast(AccessRestrictionType.PUSH)) {
+ // can not authenticate push via anonymous git protocol
+ gitDaemonPermission = AccessPermission.CLONE;
+ } else {
+ // normal user permission
+ }
+ }
+ return gitDaemonPermission;
+ }
+ return AccessPermission.NONE;
+ }
/**
- * Returns the list of non-Gitblit clone urls. This allows Gitblit to
- * advertise alternative urls for Git client repository access.
+ * Returns the list of custom client applications to be used for the
+ * repository url panel;
*
- * @param repositoryName
- * @return list of non-gitblit clone urls
+ * @return a list of client applications
*/
- public List<String> getOtherCloneUrls(String repositoryName) {
- List<String> cloneUrls = new ArrayList<String>();
- for (String url : settings.getStrings(Keys.web.otherUrls)) {
- cloneUrls.add(MessageFormat.format(url, repositoryName));
+ public List<GitClientApplication> getClientApplications() {
+ if (clientApplications.isEmpty()) {
+ try {
+ InputStream is = getClass().getResourceAsStream("/clientapps.json");
+ Collection<GitClientApplication> clients = readClientApplications(is);
+ is.close();
+ if (clients != null) {
+ clientApplications.clear();
+ clientApplications.addAll(clients);
+ }
+ } catch (IOException e) {
+ logger.error("Failed to deserialize clientapps.json resource!", e);
+ }
}
- return cloneUrls;
+ return clientApplications;
+ }
+
+ private Collection<GitClientApplication> readClientApplications(InputStream is) {
+ try {
+ Type type = new TypeToken<Collection<GitClientApplication>>() {
+ }.getType();
+ InputStreamReader reader = new InputStreamReader(is);
+ Gson gson = new GsonBuilder().create();
+ Collection<GitClientApplication> links = gson.fromJson(reader, type);
+ return links;
+ } catch (JsonIOException e) {
+ logger.error("Error deserializing client applications!", e);
+ } catch (JsonSyntaxException e) {
+ logger.error("Error deserializing client applications!", e);
+ }
+ return null;
}
/**
@@ -613,7 +751,7 @@
X509Metadata metadata = HttpUtils.getCertificateMetadata(httpRequest);
if (user != null) {
flagWicketSession(AuthenticationType.CERTIFICATE);
- logger.info(MessageFormat.format("{0} authenticated by client certificate {1} from {2}",
+ logger.debug(MessageFormat.format("{0} authenticated by client certificate {1} from {2}",
user.username, metadata.serialNumber, httpRequest.getRemoteAddr()));
return user;
} else {
@@ -630,15 +768,18 @@
// try to authenticate by servlet container principal
Principal principal = httpRequest.getUserPrincipal();
if (principal != null) {
- UserModel user = getUserModel(principal.getName());
- if (user != null) {
- flagWicketSession(AuthenticationType.CONTAINER);
- logger.info(MessageFormat.format("{0} authenticated by servlet container principal from {1}",
- user.username, httpRequest.getRemoteAddr()));
- return user;
- } else {
- logger.warn(MessageFormat.format("Failed to find UserModel for {0}, attempted servlet container authentication from {1}",
- principal.getName(), httpRequest.getRemoteAddr()));
+ String username = principal.getName();
+ if (StringUtils.isEmpty(username)) {
+ UserModel user = getUserModel(username);
+ if (user != null) {
+ flagWicketSession(AuthenticationType.CONTAINER);
+ logger.debug(MessageFormat.format("{0} authenticated by servlet container principal from {1}",
+ user.username, httpRequest.getRemoteAddr()));
+ return user;
+ } else {
+ logger.warn(MessageFormat.format("Failed to find UserModel for {0}, attempted servlet container authentication from {1}",
+ principal.getName(), httpRequest.getRemoteAddr()));
+ }
}
}
@@ -647,7 +788,7 @@
UserModel user = authenticate(httpRequest.getCookies());
if (user != null) {
flagWicketSession(AuthenticationType.COOKIE);
- logger.info(MessageFormat.format("{0} authenticated by cookie from {1}",
+ logger.debug(MessageFormat.format("{0} authenticated by cookie from {1}",
user.username, httpRequest.getRemoteAddr()));
return user;
}
@@ -669,7 +810,7 @@
UserModel user = authenticate(username, password);
if (user != null) {
flagWicketSession(AuthenticationType.CREDENTIALS);
- logger.info(MessageFormat.format("{0} authenticated by BASIC request header from {1}",
+ logger.debug(MessageFormat.format("{0} authenticated by BASIC request header from {1}",
user.username, httpRequest.getRemoteAddr()));
return user;
} else {
@@ -1286,7 +1427,15 @@
for (String repo : list) {
RepositoryModel model = getRepositoryModel(user, repo);
if (model != null) {
- repositories.add(model);
+ if (!model.hasCommits) {
+ // only add empty repositories that user can push to
+ if (UserModel.ANONYMOUS.canPush(model)
+ || user != null && user.canPush(model)) {
+ repositories.add(model);
+ }
+ } else {
+ repositories.add(model);
+ }
}
}
if (getBoolean(Keys.web.showRepositorySizes, true)) {
@@ -1373,7 +1522,7 @@
FileBasedConfig config = (FileBasedConfig) getRepositoryConfig(r);
if (config.isOutdated()) {
// reload model
- logger.info(MessageFormat.format("Config for \"{0}\" has changed. Reloading model and updating cache.", repositoryName));
+ logger.debug(MessageFormat.format("Config for \"{0}\" has changed. Reloading model and updating cache.", repositoryName));
model = loadRepositoryModel(model.name);
removeFromCachedRepositoryList(model.name);
addToCachedRepositoryList(model);
@@ -1656,6 +1805,11 @@
} else {
model.name = com.gitblit.utils.FileUtils.getRelativePath(basePath, r.getDirectory().getParentFile());
}
+ if (StringUtils.isEmpty(model.name)) {
+ // Repository is NOT located relative to the base folder because it
+ // is symlinked. Use the provided repository name.
+ model.name = repositoryName;
+ }
model.hasCommits = JGitUtils.hasCommits(r);
model.lastChange = JGitUtils.getLastChange(r);
model.projectPath = StringUtils.getFirstPathElement(repositoryName);
@@ -1668,6 +1822,8 @@
model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", "")));
model.useTickets = getConfig(config, "useTickets", false);
model.useDocs = getConfig(config, "useDocs", false);
+ model.useIncrementalPushTags = getConfig(config, "useIncrementalPushTags", false);
+ model.incrementalPushTagPrefix = getConfig(config, "incrementalPushTagPrefix", null);
model.allowForks = getConfig(config, "allowForks", true);
model.accessRestriction = AccessRestrictionType.fromName(getConfig(config,
"accessRestriction", settings.getString(Keys.git.defaultAccessRestriction, null)));
@@ -2189,6 +2345,13 @@
config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners));
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useTickets", repository.useTickets);
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"))) {
+ config.unset(Constants.CONFIG_GITBLIT, null, "incrementalPushTagPrefix");
+ } else {
+ config.setString(Constants.CONFIG_GITBLIT, null, "incrementalPushTagPrefix", repository.incrementalPushTagPrefix);
+ }
config.setBoolean(Constants.CONFIG_GITBLIT, null, "allowForks", repository.allowForks);
config.setString(Constants.CONFIG_GITBLIT, null, "accessRestriction", repository.accessRestriction.name());
config.setString(Constants.CONFIG_GITBLIT, null, "authorizationControl", repository.authorizationControl.name());
@@ -2575,17 +2738,8 @@
}
// send an email, if possible
- try {
- Message message = mailExecutor.createMessageForAdministrators();
- if (message != null) {
- message.setSubject("Federation proposal from " + proposal.url);
- message.setText("Please review the proposal @ " + gitblitUrl + "/proposal/"
- + proposal.token);
- mailExecutor.queue(message);
- }
- } catch (Throwable t) {
- logger.error("Failed to notify administrators of proposal", t);
- }
+ sendMailToAdministrators("Federation proposal from " + proposal.url,
+ "Please review the proposal @ " + gitblitUrl + "/proposal/" + proposal.token);
return true;
}
@@ -2872,16 +3026,8 @@
* @param message
*/
public void sendMailToAdministrators(String subject, String message) {
- try {
- Message mail = mailExecutor.createMessageForAdministrators();
- if (mail != null) {
- mail.setSubject(subject);
- mail.setText(message);
- mailExecutor.queue(mail);
- }
- } catch (MessagingException e) {
- logger.error("Messaging error", e);
- }
+ List<String> toAddresses = settings.getStrings(Keys.mail.adminAddresses);
+ sendMail(subject, message, toAddresses);
}
/**
@@ -2903,11 +3049,24 @@
* @param toAddresses
*/
public void sendMail(String subject, String message, String... toAddresses) {
+ if (toAddresses == null || toAddresses.length == 0) {
+ logger.debug(MessageFormat.format("Dropping message {0} because there are no recipients", subject));
+ return;
+ }
try {
Message mail = mailExecutor.createMessage(toAddresses);
if (mail != null) {
mail.setSubject(subject);
- mail.setText(message);
+
+ MimeBodyPart messagePart = new MimeBodyPart();
+ messagePart.setText(message, "utf-8");
+ messagePart.setHeader("Content-Type", "text/plain; charset=\"utf-8\"");
+ messagePart.setHeader("Content-Transfer-Encoding", "quoted-printable");
+
+ MimeMultipart multiPart = new MimeMultipart();
+ multiPart.addBodyPart(messagePart);
+ mail.setContent(multiPart);
+
mailExecutor.queue(mail);
}
} catch (MessagingException e) {
@@ -2934,11 +3093,24 @@
* @param toAddresses
*/
public void sendHtmlMail(String subject, String message, String... toAddresses) {
+ if (toAddresses == null || toAddresses.length == 0) {
+ logger.debug(MessageFormat.format("Dropping message {0} because there are no recipients", subject));
+ return;
+ }
try {
Message mail = mailExecutor.createMessage(toAddresses);
if (mail != null) {
mail.setSubject(subject);
- mail.setContent(message, "text/html");
+
+ MimeBodyPart messagePart = new MimeBodyPart();
+ messagePart.setText(message, "utf-8");
+ messagePart.setHeader("Content-Type", "text/html; charset=\"utf-8\"");
+ messagePart.setHeader("Content-Transfer-Encoding", "quoted-printable");
+
+ MimeMultipart multiPart = new MimeMultipart();
+ multiPart.addBodyPart(messagePart);
+ mail.setContent(multiPart);
+
mailExecutor.queue(mail);
}
} catch (MessagingException e) {
@@ -2971,11 +3143,10 @@
* Parse the properties file and aggregate all the comments by the setting
* key. A setting model tracks the current value, the default value, the
* description of the setting and and directives about the setting.
- * @param referencePropertiesInputStream
*
* @return Map<String, SettingModel>
*/
- private ServerSettings loadSettingModels(InputStream referencePropertiesInputStream) {
+ private ServerSettings loadSettingModels() {
ServerSettings settingsModel = new ServerSettings();
settingsModel.supportsCredentialChanges = userService.supportsCredentialChanges();
settingsModel.supportsDisplayNameChanges = userService.supportsDisplayNameChanges();
@@ -2985,7 +3156,7 @@
// Read bundled Gitblit properties to extract setting descriptions.
// This copy is pristine and only used for populating the setting
// models map.
- InputStream is = referencePropertiesInputStream;
+ InputStream is = getClass().getResourceAsStream("/reference.properties");
BufferedReader propertiesReader = new BufferedReader(new InputStreamReader(is));
StringBuilder description = new StringBuilder();
SettingModel setting = new SettingModel();
@@ -3090,18 +3261,34 @@
projectConfigs = new FileBasedConfig(getFileOrFolder(Keys.web.projectsFile, "${baseFolder}/projects.conf"), FS.detect());
getProjectConfigs();
- // schedule mail engine
+ configureMailExecutor();
+ configureLuceneIndexing();
+ configureGarbageCollector();
+ if (startFederation) {
+ configureFederation();
+ }
+ configureJGit();
+ configureFanout();
+ configureGitDaemon();
+
+ ContainerUtils.CVE_2007_0450.test();
+ }
+
+ protected void configureMailExecutor() {
if (mailExecutor.isReady()) {
logger.info("Mail executor is scheduled to process the message queue every 2 minutes.");
scheduledExecutor.scheduleAtFixedRate(mailExecutor, 1, 2, TimeUnit.MINUTES);
} else {
logger.warn("Mail server is not properly configured. Mail services disabled.");
}
-
- // schedule lucene engine
- enableLuceneIndexing();
-
-
+ }
+
+ protected void configureLuceneIndexing() {
+ scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);
+ logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes.");
+ }
+
+ protected void configureGarbageCollector() {
// schedule gc engine
if (gcExecutor.isReady()) {
logger.info("GC executor is scheduled to scan repositories every 24 hours.");
@@ -3125,23 +3312,21 @@
logger.info(MessageFormat.format("Next scheculed GC scan is in {0}", when));
scheduledExecutor.scheduleAtFixedRate(gcExecutor, delay, 60*24, TimeUnit.MINUTES);
}
-
- if (startFederation) {
- configureFederation();
- }
-
+ }
+
+ protected void configureJGit() {
// Configure JGit
WindowCacheConfig cfg = new WindowCacheConfig();
-
+
cfg.setPackedGitWindowSize(settings.getFilesize(Keys.git.packedGitWindowSize, cfg.getPackedGitWindowSize()));
cfg.setPackedGitLimit(settings.getFilesize(Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
cfg.setDeltaBaseCacheLimit(settings.getFilesize(Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit()));
cfg.setPackedGitOpenFiles(settings.getFilesize(Keys.git.packedGitOpenFiles, cfg.getPackedGitOpenFiles()));
cfg.setStreamFileThreshold(settings.getFilesize(Keys.git.streamFileThreshold, cfg.getStreamFileThreshold()));
cfg.setPackedGitMMAP(settings.getBoolean(Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));
-
+
try {
- WindowCache.reconfigure(cfg);
+ cfg.install();
logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitWindowSize, cfg.getPackedGitWindowSize()));
logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit()));
@@ -3151,16 +3336,16 @@
} catch (IllegalArgumentException e) {
logger.error("Failed to configure JGit parameters!", e);
}
-
- ContainerUtils.CVE_2007_0450.test();
-
+ }
+
+ protected void configureFanout() {
// startup Fanout PubSub service
if (settings.getInteger(Keys.fanout.port, 0) > 0) {
String bindInterface = settings.getString(Keys.fanout.bindInterface, null);
int port = settings.getInteger(Keys.fanout.port, FanoutService.DEFAULT_PORT);
boolean useNio = settings.getBoolean(Keys.fanout.useNio, true);
int limit = settings.getInteger(Keys.fanout.connectionLimit, 0);
-
+
if (useNio) {
if (StringUtils.isEmpty(bindInterface)) {
fanoutService = new FanoutNioService(port);
@@ -3174,16 +3359,25 @@
fanoutService = new FanoutSocketService(bindInterface, port);
}
}
-
+
fanoutService.setConcurrentConnectionLimit(limit);
fanoutService.setAllowAllChannelAnnouncements(false);
fanoutService.start();
}
}
- protected void enableLuceneIndexing() {
- scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);
- logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes.");
+ protected void configureGitDaemon() {
+ int port = settings.getInteger(Keys.git.daemonPort, 0);
+ String bindInterface = settings.getString(Keys.git.daemonBindInterface, "localhost");
+ if (port > 0) {
+ try {
+ gitDaemon = new GitDaemon(bindInterface, port, getRepositoriesFolder());
+ gitDaemon.start();
+ } catch (IOException e) {
+ gitDaemon = null;
+ logger.error(MessageFormat.format("Failed to start Git daemon on {0}:{1,number,0}", bindInterface, port), e);
+ }
+ }
}
protected final Logger getLogger() {
@@ -3213,10 +3407,6 @@
*/
@Override
public void contextInitialized(ServletContextEvent contextEvent) {
- contextInitialized(contextEvent, contextEvent.getServletContext().getResourceAsStream("/WEB-INF/reference.properties"));
- }
-
- public void contextInitialized(ServletContextEvent contextEvent, InputStream referencePropertiesInputStream) {
servletContext = contextEvent.getServletContext();
if (settings == null) {
// Gitblit is running in a servlet container
@@ -3228,13 +3418,15 @@
if (!StringUtils.isEmpty(openShift)) {
// Gitblit is running in OpenShift/JBoss
File base = new File(openShift);
+ logger.info("EXPRESS contextFolder is " + contextFolder.getAbsolutePath());
// gitblit.properties setting overrides
File overrideFile = new File(base, "gitblit.properties");
webxmlSettings.applyOverrides(overrideFile);
// Copy the included scripts to the configured groovy folder
- File localScripts = new File(base, webxmlSettings.getString(Keys.groovy.scriptsFolder, "groovy"));
+ String path = webxmlSettings.getString(Keys.groovy.scriptsFolder, "groovy");
+ File localScripts = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, base, path);
if (!localScripts.exists()) {
File warScripts = new File(contextFolder, "/WEB-INF/data/groovy");
if (!warScripts.equals(localScripts)) {
@@ -3279,7 +3471,7 @@
}
}
- settingsModel = loadSettingModels(referencePropertiesInputStream);
+ settingsModel = loadSettingModels();
serverStatus.servletContainer = servletContext.getServerInfo();
}
@@ -3296,6 +3488,9 @@
if (fanoutService != null) {
fanoutService.stop();
}
+ if (gitDaemon != null) {
+ gitDaemon.stop();
+ }
}
/**
--
Gitblit v1.9.1