use of com.gitblit.Constants.PermissionType in project gitblit by gitblit.
the class TeamModel method getRepositoryPermissions.
/**
* Returns a list of repository permissions for this team.
*
* @return the team's list of permissions
*/
public List<RegistrantAccessPermission> getRepositoryPermissions() {
List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();
if (canAdmin) {
// team has REWIND access to all repositories
return list;
}
for (Map.Entry<String, AccessPermission> entry : permissions.entrySet()) {
String registrant = entry.getKey();
String source = null;
boolean editable = true;
PermissionType pType = PermissionType.EXPLICIT;
if (StringUtils.findInvalidCharacter(registrant) != null) {
// a regex will have at least 1 invalid character
pType = PermissionType.REGEX;
source = registrant;
}
list.add(new RegistrantAccessPermission(registrant, entry.getValue(), pType, RegistrantType.REPOSITORY, source, editable));
}
Collections.sort(list);
return list;
}
use of com.gitblit.Constants.PermissionType in project gitblit by gitblit.
the class UserModel method getRepositoryPermissions.
/**
* Returns a list of repository permissions for this user exclusive of
* permissions inherited from team memberships.
*
* @return the user's list of permissions
*/
public List<RegistrantAccessPermission> getRepositoryPermissions() {
List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();
if (canAdmin()) {
// user has REWIND access to all repositories
return list;
}
for (Map.Entry<String, AccessPermission> entry : permissions.entrySet()) {
String registrant = entry.getKey();
AccessPermission ap = entry.getValue();
String source = null;
boolean mutable = true;
PermissionType pType = PermissionType.EXPLICIT;
if (isMyPersonalRepository(registrant)) {
pType = PermissionType.OWNER;
ap = AccessPermission.REWIND;
mutable = false;
} else if (StringUtils.findInvalidCharacter(registrant) != null) {
// a regex will have at least 1 invalid character
pType = PermissionType.REGEX;
source = registrant;
}
list.add(new RegistrantAccessPermission(registrant, ap, pType, RegistrantType.REPOSITORY, source, mutable));
}
Collections.sort(list);
// include immutable team permissions, being careful to preserve order
Set<RegistrantAccessPermission> set = new LinkedHashSet<RegistrantAccessPermission>(list);
for (TeamModel team : teams) {
for (RegistrantAccessPermission teamPermission : team.getRepositoryPermissions()) {
// we can not change an inherited team permission, though we can override
teamPermission.registrantType = RegistrantType.REPOSITORY;
teamPermission.permissionType = PermissionType.TEAM;
teamPermission.source = team.name;
teamPermission.mutable = false;
set.add(teamPermission);
}
}
return new ArrayList<RegistrantAccessPermission>(set);
}
Aggregations