restricted.add(repo.name);\r
}\r
}\r
+ StringUtils.sortRepositorynames(restricted);\r
\r
- // remove repositories for which team already has a permission\r
+ List<String> list = new ArrayList<String>();\r
+ // repositories\r
+ list.add(".*");\r
+ // all repositories excluding personal repositories\r
+ list.add("[^~].*");\r
+ String lastProject = null;\r
+ for (String repo : restricted) {\r
+ String projectPath = StringUtils.getFirstPathElement(repo);\r
+ if (lastProject == null || !lastProject.equalsIgnoreCase(projectPath)) {\r
+ lastProject = projectPath;\r
+ if (!StringUtils.isEmpty(projectPath)) {\r
+ // regex for all repositories within a project\r
+ list.add(projectPath + "/.*");\r
+ }\r
+ list.add(repo);\r
+ }\r
+ }\r
+\r
+ // remove repositories for which user already has a permission\r
if (permissions == null) {\r
permissions = new ArrayList<RegistrantAccessPermission>();\r
} else {\r
for (RegistrantAccessPermission rp : permissions) {\r
- restricted.remove(rp.registrant);\r
+ list.remove(rp.registrant);\r
}\r
}\r
-\r
- StringUtils.sortRepositorynames(restricted);\r
- repositoryPalette.setObjects(restricted, permissions);\r
+ repositoryPalette.setObjects(list, permissions);\r
}\r
\r
public void setUsers(List<String> users, List<String> selected) {\r
restricted.add(repo.name);\r
}\r
}\r
+ StringUtils.sortRepositorynames(restricted);\r
+ \r
+ List<String> list = new ArrayList<String>();\r
+ // repositories\r
+ list.add(".*");\r
+ // all repositories excluding personal repositories\r
+ list.add("[^~].*");\r
+ String lastProject = null;\r
+ for (String repo : restricted) {\r
+ String projectPath = StringUtils.getFirstPathElement(repo);\r
+ if (lastProject == null || !lastProject.equalsIgnoreCase(projectPath)) {\r
+ lastProject = projectPath;\r
+ if (!StringUtils.isEmpty(projectPath)) {\r
+ // regex for all repositories within a project\r
+ list.add(projectPath + "/.*");\r
+ }\r
+ list.add(repo);\r
+ }\r
+ }\r
\r
// remove repositories for which user already has a permission\r
if (permissions == null) {\r
permissions = new ArrayList<RegistrantAccessPermission>();\r
} else {\r
for (RegistrantAccessPermission rp : permissions) {\r
- restricted.remove(rp.registrant);\r
+ list.remove(rp.registrant);\r
}\r
}\r
- \r
- StringUtils.sortRepositorynames(restricted);\r
- repositoryPalette.setObjects(restricted, permissions);\r
+ repositoryPalette.setObjects(list, permissions);\r
}\r
\r
public void setTeams(List<TeamModel> teams, List<TeamModel> selected) {\r
import org.apache.wicket.model.util.CollectionModel;\r
import org.apache.wicket.model.util.ListModel;\r
\r
-import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.GitBlit;\r
import com.gitblit.GitBlitException;\r
import com.gitblit.models.RegistrantAccessPermission;\r
-import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.TeamModel;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.RequiresAdminRole;\r
\r
CompoundPropertyModel<TeamModel> model = new CompoundPropertyModel<TeamModel>(teamModel);\r
\r
- List<String> repos = new ArrayList<String>();\r
- for (String repo : GitBlit.self().getRepositoryList()) {\r
- RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(repo);\r
- if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)) {\r
- repos.add(repo);\r
- }\r
- }\r
- StringUtils.sortRepositorynames(repos);\r
+ List<String> repos = getAccessRestrictedRepositoryList(true);\r
\r
List<String> teamUsers = new ArrayList<String>(teamModel.users);\r
Collections.sort(teamUsers);\r
import org.apache.wicket.model.util.CollectionModel;\r
import org.apache.wicket.model.util.ListModel;\r
\r
-import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.GitBlit;\r
import com.gitblit.GitBlitException;\r
import com.gitblit.Keys;\r
import com.gitblit.models.RegistrantAccessPermission;\r
-import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.TeamModel;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.utils.StringUtils;\r
StringUtils.isEmpty(userModel.password) ? "" : userModel.password);\r
CompoundPropertyModel<UserModel> model = new CompoundPropertyModel<UserModel>(userModel);\r
\r
- List<String> repos = new ArrayList<String>();\r
- for (String repo : GitBlit.self().getRepositoryList()) {\r
- RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(repo);\r
- if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)) {\r
- repos.add(repo);\r
- }\r
- }\r
- StringUtils.sortRepositorynames(repos);\r
+ // build list of projects including all repositories wildcards\r
+ List<String> repos = getAccessRestrictedRepositoryList(true);\r
\r
List<String> userTeams = new ArrayList<String>();\r
for (TeamModel team : userModel.teams) {\r
*/\r
package com.gitblit.wicket.pages;\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
import org.apache.wicket.PageParameters;\r
import org.apache.wicket.markup.html.basic.Label;\r
\r
+import com.gitblit.GitBlit;\r
+import com.gitblit.Constants.AccessRestrictionType;\r
+import com.gitblit.models.RepositoryModel;\r
import com.gitblit.utils.StringUtils;\r
\r
/**\r
add(new Label("pageSubName", subName));\r
super.setupPage("", pageName);\r
}\r
+ \r
+ protected List<String> getAccessRestrictedRepositoryList(boolean includeWildcards) {\r
+ // build list of access-restricted projects\r
+ String lastProject = null;\r
+ List<String> repos = new ArrayList<String>();\r
+ if (includeWildcards) {\r
+ // all repositories\r
+ repos.add(".*");\r
+ // all repositories excluding personal repositories\r
+ repos.add("[^~].*");\r
+ }\r
+ for (String repo : GitBlit.self().getRepositoryList()) {\r
+ RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(repo);\r
+ if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)) {\r
+ if (includeWildcards) {\r
+ if (lastProject == null || !lastProject.equalsIgnoreCase(repositoryModel.projectPath)) {\r
+ lastProject = repositoryModel.projectPath;\r
+ if (!StringUtils.isEmpty(repositoryModel.projectPath)) {\r
+ // regex for all repositories within a project\r
+ repos.add(repositoryModel.projectPath + "/.*");\r
+ }\r
+ }\r
+ }\r
+ repos.add(repo);\r
+ }\r
+ }\r
+ return repos;\r
+ }\r
}\r