| | |
| | | import java.io.Serializable;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collection;
|
| | | import java.util.Collections;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | |
| | |
|
| | | // field names are reflectively mapped in EditTeam page
|
| | | public String name;
|
| | | public boolean canAdmin;
|
| | | public boolean canFork;
|
| | | public boolean canCreate;
|
| | | public final Set<String> users = new HashSet<String>();
|
| | | // retained for backwards-compatibility with RPC clients
|
| | | @Deprecated
|
| | |
| | | public void removeRepository(String name) {
|
| | | removeRepositoryPermission(name);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * Returns a list of repository permissions for this team.
|
| | | * |
| | | * @return the team's list of permissions
|
| | | */
|
| | | public List<RepositoryAccessPermission> getRepositoryPermissions() {
|
| | | List<RepositoryAccessPermission> list = new ArrayList<RepositoryAccessPermission>();
|
| | | for (Map.Entry<String, AccessPermission> entry : permissions.entrySet()) {
|
| | | list.add(new RepositoryAccessPermission(entry.getKey(), entry.getValue()));
|
| | | }
|
| | | Collections.sort(list);
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * Returns true if the team has any type of specified access permission for
|
| | |
| | | */
|
| | | public boolean hasRepositoryPermission(String name) {
|
| | | String repository = AccessPermission.repositoryFromRole(name).toLowerCase();
|
| | | return permissions.containsKey(repository) || repositories.contains(repository);
|
| | | if (permissions.containsKey(repository)) {
|
| | | // exact repository permission specified
|
| | | return true;
|
| | | } else {
|
| | | // search for regex permission match
|
| | | for (String key : permissions.keySet()) {
|
| | | if (name.matches(key)) {
|
| | | AccessPermission p = permissions.get(key);
|
| | | if (p != null) {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | /**
|