From e0ae994e31c3a93a13c7b0141fe37dd1aac9b228 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 02 May 2012 14:36:48 -0400
Subject: [PATCH] Merge pull request #15 from mragab/java-proxy
---
src/com/gitblit/GitBlit.java | 119 ++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 92 insertions(+), 27 deletions(-)
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index f6691dc..565b024 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -73,6 +73,7 @@
import com.gitblit.models.FederationSet;
import com.gitblit.models.Metric;
import com.gitblit.models.RepositoryModel;
+import com.gitblit.models.SearchResult;
import com.gitblit.models.ServerSettings;
import com.gitblit.models.ServerStatus;
import com.gitblit.models.SettingModel;
@@ -184,6 +185,7 @@
}
return self().timezone;
}
+
/**
* Returns the boolean value for the specified key. If the key does not
@@ -375,6 +377,38 @@
this.userService = userService;
this.userService.setup(settings);
}
+
+ /**
+ *
+ * @return true if the user service supports credential changes
+ */
+ public boolean supportsCredentialChanges() {
+ return userService.supportsCredentialChanges();
+ }
+
+ /**
+ *
+ * @return true if the user service supports display name changes
+ */
+ public boolean supportsDisplayNameChanges() {
+ return userService.supportsDisplayNameChanges();
+ }
+
+ /**
+ *
+ * @return true if the user service supports email address changes
+ */
+ public boolean supportsEmailAddressChanges() {
+ return userService.supportsEmailAddressChanges();
+ }
+
+ /**
+ *
+ * @return true if the user service supports team membership changes
+ */
+ public boolean supportsTeamMembershipChanges() {
+ return userService.supportsTeamMembershipChanges();
+ }
/**
* Authenticate a user based on a username and password.
@@ -462,6 +496,18 @@
userCookie.setPath("/");
response.addCookie(userCookie);
}
+ }
+
+ /**
+ * Logout a user.
+ *
+ * @param user
+ */
+ public void logout(UserModel user) {
+ if (userService == null) {
+ return;
+ }
+ userService.logout(user);
}
/**
@@ -809,6 +855,8 @@
"gitblit", null, "postReceiveScript")));
model.mailingLists = new ArrayList<String>(Arrays.asList(config.getStringList(
"gitblit", null, "mailingList")));
+ model.indexedBranches = new ArrayList<String>(Arrays.asList(config.getStringList(
+ "gitblit", null, "indexBranch")));
}
model.HEAD = JGitUtils.getHEADRef(r);
model.availableRefs = JGitUtils.getAvailableHeadTargets(r);
@@ -868,6 +916,9 @@
repository.close();
}
}
+
+ // close any open index writer/searcher in the Lucene executor
+ luceneExecutor.close(repositoryName);
}
/**
@@ -1043,24 +1094,33 @@
config.setBoolean("gitblit", null, "showReadme", repository.showReadme);
config.setBoolean("gitblit", null, "skipSizeCalculation", repository.skipSizeCalculation);
config.setBoolean("gitblit", null, "skipSummaryMetrics", repository.skipSummaryMetrics);
- config.setStringList("gitblit", null, "federationSets", repository.federationSets);
config.setString("gitblit", null, "federationStrategy",
repository.federationStrategy.name());
config.setBoolean("gitblit", null, "isFederated", repository.isFederated);
- if (!ArrayUtils.isEmpty(repository.preReceiveScripts)) {
- config.setStringList("gitblit", null, "preReceiveScript", repository.preReceiveScripts);
- }
- if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {
- config.setStringList("gitblit", null, "postReceiveScript",
- repository.postReceiveScripts);
- }
- if (!ArrayUtils.isEmpty(repository.mailingLists)) {
- config.setStringList("gitblit", null, "mailingList", repository.mailingLists);
- }
+
+ updateList(config, "federationSets", repository.federationSets);
+ updateList(config, "preReceiveScript", repository.preReceiveScripts);
+ updateList(config, "postReceiveScript", repository.postReceiveScripts);
+ updateList(config, "mailingList", repository.mailingLists);
+ updateList(config, "indexBranch", repository.indexedBranches);
+
try {
config.save();
} catch (IOException e) {
logger.error("Failed to save repository config!", e);
+ }
+ }
+
+ private void updateList(StoredConfig config, String field, List<String> list) {
+ // a null list is skipped, not cleared
+ // this is for RPC administration where an older manager might be used
+ if (list == null) {
+ return;
+ }
+ if (ArrayUtils.isEmpty(list)) {
+ config.unset("gitblit", null, field);
+ } else {
+ config.setStringList("gitblit", null, field, list);
}
}
@@ -1645,6 +1705,20 @@
}
return scripts;
}
+
+ /**
+ * Search the specified repositories using the Lucene query.
+ *
+ * @param query
+ * @param page
+ * @param pageSize
+ * @param repositories
+ * @return
+ */
+ public List<SearchResult> search(String query, int page, int pageSize, List<String> repositories) {
+ List<SearchResult> srs = luceneExecutor.search(query, page, pageSize, repositories);
+ return srs;
+ }
/**
* Notify the administrators by email.
@@ -1697,15 +1771,6 @@
}
/**
- * Update the Lucene index of a repository.
- *
- * @param repository
- */
- public void updateLuceneIndex(RepositoryModel repository) {
- luceneExecutor.queue(repository);
- }
-
- /**
* Returns the descriptions/comments of the Gitblit config settings.
*
* @return SettingsModel
@@ -1731,6 +1796,10 @@
*/
private ServerSettings loadSettingModels() {
ServerSettings settingsModel = new ServerSettings();
+ settingsModel.supportsCredentialChanges = userService.supportsCredentialChanges();
+ settingsModel.supportsDisplayNameChanges = userService.supportsDisplayNameChanges();
+ settingsModel.supportsEmailAddressChanges = userService.supportsEmailAddressChanges();
+ settingsModel.supportsTeamMembershipChanges = userService.supportsTeamMembershipChanges();
try {
// Read bundled Gitblit properties to extract setting descriptions.
// This copy is pristine and only used for populating the setting
@@ -1822,13 +1891,9 @@
} else {
logger.warn("Mail server is not properly configured. Mail services disabled.");
}
- luceneExecutor = new LuceneExecutor(settings);
- if (luceneExecutor.isReady()) {
- logger.info("Lucene executor is scheduled to process the repository queue every 2 minutes.");
- scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);
- } else {
- logger.warn("Lucene executor is disabled.");
- }
+ luceneExecutor = new LuceneExecutor(settings, repositoriesFolder);
+ logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes.");
+ scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);
if (startFederation) {
configureFederation();
}
--
Gitblit v1.9.1