summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/gitblit/Constants.java2
-rw-r--r--src/main/java/com/gitblit/GitBlit.java3
-rw-r--r--src/main/java/com/gitblit/client/EditTeamDialog.java21
-rw-r--r--src/main/java/com/gitblit/client/EditUserDialog.java20
-rw-r--r--src/main/java/com/gitblit/utils/ModelUtils.java54
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RootSubPage.java4
6 files changed, 74 insertions, 30 deletions
diff --git a/src/main/java/com/gitblit/Constants.java b/src/main/java/com/gitblit/Constants.java
index 2c67bfff..a3a3c70e 100644
--- a/src/main/java/com/gitblit/Constants.java
+++ b/src/main/java/com/gitblit/Constants.java
@@ -47,6 +47,8 @@ public class Constants {
public static final String EXTERNAL_ACCOUNT = "#externalAccount";
public static final String PROPERTIES_FILE = "gitblit.properties";
+
+ public static final String DEFAULT_USER_REPOSITORY_PREFIX = "~";
public static final String GIT_PATH = "/git/";
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java
index 2348f576..72a0e22a 100644
--- a/src/main/java/com/gitblit/GitBlit.java
+++ b/src/main/java/com/gitblit/GitBlit.java
@@ -3441,7 +3441,8 @@ public class GitBlit implements ServletContextListener {
gcExecutor = new GCExecutor(settings);
// initialize utilities
- ModelUtils.setUserRepoPrefix(settings);
+ String prefix = settings.getString(Keys.git.userRepositoryPrefix, "~");
+ ModelUtils.setUserRepoPrefix(prefix);
// calculate repository list settings checksum for future config changes
repositoryListSettingsChecksum.set(getRepositoryListSettingsChecksum());
diff --git a/src/main/java/com/gitblit/client/EditTeamDialog.java b/src/main/java/com/gitblit/client/EditTeamDialog.java
index 4bd032e1..74640553 100644
--- a/src/main/java/com/gitblit/client/EditTeamDialog.java
+++ b/src/main/java/com/gitblit/client/EditTeamDialog.java
@@ -44,14 +44,15 @@ import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
+import com.gitblit.Constants;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.Constants.AuthorizationControl;
import com.gitblit.Constants.RegistrantType;
+import com.gitblit.Keys;
import com.gitblit.models.RegistrantAccessPermission;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.ServerSettings;
import com.gitblit.models.TeamModel;
-import com.gitblit.utils.ModelUtils;
import com.gitblit.utils.StringUtils;
public class EditTeamDialog extends JDialog {
@@ -323,8 +324,22 @@ public class EditTeamDialog extends JDialog {
List<String> list = new ArrayList<String>();
// repositories
list.add(".*");
- // all repositories excluding personal repositories
- if (ModelUtils.getUserRepoPrefix().length() == 1) list.add("[^" + ModelUtils.getUserRepoPrefix() +"].*");
+
+ String prefix;
+ if (settings.hasKey(Keys.git.userRepositoryPrefix)) {
+ prefix = settings.get(Keys.git.userRepositoryPrefix).currentValue;
+ if (StringUtils.isEmpty(prefix)) {
+ prefix = Constants.DEFAULT_USER_REPOSITORY_PREFIX;
+ }
+ } else {
+ prefix = Constants.DEFAULT_USER_REPOSITORY_PREFIX;
+ }
+
+ if (prefix.length() == 1) {
+ // all repositories excluding personal repositories
+ list.add("[^" + prefix + "].*");
+ }
+
String lastProject = null;
for (String repo : restricted) {
String projectPath = StringUtils.getFirstPathElement(repo);
diff --git a/src/main/java/com/gitblit/client/EditUserDialog.java b/src/main/java/com/gitblit/client/EditUserDialog.java
index f1d9aa6f..fd6745ea 100644
--- a/src/main/java/com/gitblit/client/EditUserDialog.java
+++ b/src/main/java/com/gitblit/client/EditUserDialog.java
@@ -47,6 +47,7 @@ import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
+import com.gitblit.Constants;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.Constants.AuthorizationControl;
import com.gitblit.Constants.PermissionType;
@@ -57,7 +58,6 @@ import com.gitblit.models.RepositoryModel;
import com.gitblit.models.ServerSettings;
import com.gitblit.models.TeamModel;
import com.gitblit.models.UserModel;
-import com.gitblit.utils.ModelUtils;
import com.gitblit.utils.StringUtils;
public class EditUserDialog extends JDialog {
@@ -403,8 +403,22 @@ public class EditUserDialog extends JDialog {
List<String> list = new ArrayList<String>();
// repositories
list.add(".*");
- // all repositories excluding personal repositories
- if (ModelUtils.getUserRepoPrefix().length() == 1) list.add("[^" + ModelUtils.getUserRepoPrefix() +"].*");
+
+ String prefix;
+ if (settings.hasKey(Keys.git.userRepositoryPrefix)) {
+ prefix = settings.get(Keys.git.userRepositoryPrefix).currentValue;
+ if (StringUtils.isEmpty(prefix)) {
+ prefix = Constants.DEFAULT_USER_REPOSITORY_PREFIX;
+ }
+ } else {
+ prefix = Constants.DEFAULT_USER_REPOSITORY_PREFIX;
+ }
+
+ if (prefix.length() == 1) {
+ // all repositories excluding personal repositories
+ list.add("[^" + prefix + "].*");
+ }
+
String lastProject = null;
for (String repo : restricted) {
String projectPath = StringUtils.getFirstPathElement(repo).toLowerCase();
diff --git a/src/main/java/com/gitblit/utils/ModelUtils.java b/src/main/java/com/gitblit/utils/ModelUtils.java
index 8f929aad..d053db65 100644
--- a/src/main/java/com/gitblit/utils/ModelUtils.java
+++ b/src/main/java/com/gitblit/utils/ModelUtils.java
@@ -1,7 +1,23 @@
+/*
+ * Copyright 2013 gitblit.com
+ * Copyright 2013 Florian Zschocke
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.gitblit.utils;
-import com.gitblit.IStoredSettings;
-import com.gitblit.Keys;
+import com.gitblit.Constants;
+
/**
* Utility functions for model classes that do not fit in any other category.
@@ -10,28 +26,22 @@ import com.gitblit.Keys;
*/
public class ModelUtils
{
- /**
- * Default value for the prefix for user repository directories.
- */
- private static final String DEFAULT_USER_REPO_PREFIX = "~";
-
- private static String userRepoPrefix = DEFAULT_USER_REPO_PREFIX;
-
-
+ private static String userRepoPrefix = Constants.DEFAULT_USER_REPOSITORY_PREFIX;
/**
- * Set the user repository prefix from configuration settings.
- * @param settings
+ * Set the user repository prefix.
+ * @param prefix
*/
- public static void setUserRepoPrefix(IStoredSettings settings)
+ public static void setUserRepoPrefix(String prefix)
{
- String newPrefix = DEFAULT_USER_REPO_PREFIX;
- if (settings != null) {
- String prefix = settings.getString(Keys.git.userRepositoryPrefix, DEFAULT_USER_REPO_PREFIX);
- if (prefix != null && !prefix.trim().isEmpty()) {
- if (prefix.charAt(0) == '/') prefix = prefix.substring(1);
- newPrefix = prefix;
- }
+ if (StringUtils.isEmpty(prefix)) {
+ userRepoPrefix = Constants.DEFAULT_USER_REPOSITORY_PREFIX;
+ return;
+ }
+
+ String newPrefix = prefix.replace('\\', '/');
+ if (prefix.charAt(0) == '/') {
+ newPrefix = prefix.substring(1);
}
userRepoPrefix = newPrefix;
@@ -68,7 +78,7 @@ public class ModelUtils
*/
public static boolean isPersonalRepository(String name)
{
- if ( name.startsWith(getUserRepoPrefix()) ) return true;
+ if ( name.startsWith(userRepoPrefix) ) return true;
return false;
}
@@ -101,7 +111,7 @@ public class ModelUtils
{
if ( !isPersonalRepository(path) ) return "";
- return path.substring(getUserRepoPrefix().length());
+ return path.substring(userRepoPrefix.length());
}
}
diff --git a/src/main/java/com/gitblit/wicket/pages/RootSubPage.java b/src/main/java/com/gitblit/wicket/pages/RootSubPage.java
index 17ba4b27..0be714e2 100644
--- a/src/main/java/com/gitblit/wicket/pages/RootSubPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RootSubPage.java
@@ -81,7 +81,9 @@ public abstract class RootSubPage extends RootPage {
// all repositories
repos.add(".*");
// all repositories excluding personal repositories
- if (ModelUtils.getUserRepoPrefix().length() == 1) repos.add("[^" + ModelUtils.getUserRepoPrefix() +"].*");
+ if (ModelUtils.getUserRepoPrefix().length() == 1) {
+ repos.add("[^" + ModelUtils.getUserRepoPrefix() + "].*");
+ }
}
for (String repo : GitBlit.self().getRepositoryList()) {