From fabe060d3a435f116128851f828e35c2af5fde67 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Mon, 10 Sep 2012 16:26:27 -0400 Subject: [PATCH] Strip folder name and .git from repo links in the project view --- src/com/gitblit/client/GitblitClient.java | 41 +++++++++++++++++++++++++++++++++++------ 1 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/com/gitblit/client/GitblitClient.java b/src/com/gitblit/client/GitblitClient.java index d37ee91..52d4e06 100644 --- a/src/com/gitblit/client/GitblitClient.java +++ b/src/com/gitblit/client/GitblitClient.java @@ -28,6 +28,8 @@ import java.util.TreeSet; import com.gitblit.Constants; +import com.gitblit.Constants.AccessRestrictionType; +import com.gitblit.Constants.AuthorizationControl; import com.gitblit.GitBlitException.ForbiddenException; import com.gitblit.GitBlitException.NotAllowedException; import com.gitblit.GitBlitException.UnauthorizedException; @@ -41,6 +43,7 @@ import com.gitblit.models.ServerStatus; import com.gitblit.models.TeamModel; import com.gitblit.models.UserModel; +import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.RpcUtils; import com.gitblit.utils.StringUtils; import com.gitblit.utils.SyndicationUtils; @@ -184,6 +187,22 @@ return sb.toString(); } } + + public AccessRestrictionType getDefaultAccessRestriction() { + String restriction = null; + if (settings.hasKey(Keys.git.defaultAccessRestriction)) { + restriction = settings.get(Keys.git.defaultAccessRestriction).currentValue; + } + return AccessRestrictionType.fromName(restriction); + } + + public AuthorizationControl getDefaultAuthorizationControl() { + String authorization = null; + if (settings.hasKey(Keys.git.defaultAuthorizationControl)) { + authorization = settings.get(Keys.git.defaultAuthorizationControl).currentValue; + } + return AuthorizationControl.fromName(authorization); + } /** * Returns the list of pre-receive scripts the repository inherited from the @@ -208,7 +227,9 @@ if (repository != null) { for (String teamname : getPermittedTeamnames(repository)) { TeamModel team = getTeamModel(teamname); - scripts.addAll(team.preReceiveScripts); + if (!ArrayUtils.isEmpty(team.preReceiveScripts)) { + scripts.addAll(team.preReceiveScripts); + } } } return new ArrayList<String>(scripts); @@ -258,7 +279,9 @@ if (repository != null) { for (String teamname : getPermittedTeamnames(repository)) { TeamModel team = getTeamModel(teamname); - scripts.addAll(team.postReceiveScripts); + if (!ArrayUtils.isEmpty(team.postReceiveScripts)) { + scripts.addAll(team.postReceiveScripts); + } } } return new ArrayList<String>(scripts); @@ -278,9 +301,11 @@ // create list of available scripts by excluding inherited scripts List<String> scripts = new ArrayList<String>(); - for (String script : settings.pushScripts) { - if (!inherited.contains(script)) { - scripts.add(script); + if (!ArrayUtils.isEmpty(settings.pushScripts)) { + for (String script : settings.pushScripts) { + if (!inherited.contains(script)) { + scripts.add(script); + } } } return scripts; @@ -489,7 +514,7 @@ } return teamnames; } - + public TeamModel getTeamModel(String name) { for (TeamModel team : allTeams) { if (team.name.equalsIgnoreCase(name)) { @@ -553,6 +578,10 @@ public boolean deleteRepository(RepositoryModel repository) throws IOException { return RpcUtils.deleteRepository(repository, url, account, password); } + + public boolean clearRepositoryCache() throws IOException { + return RpcUtils.clearRepositoryCache(url, account, password); + } public boolean createUser(UserModel user) throws IOException { return RpcUtils.createUser(user, url, account, password); -- Gitblit v1.9.1