| | |
| | | import java.util.HashSet;
|
| | | import java.util.Set;
|
| | |
|
| | | import com.gitblit.Constants.AccessRestrictionType;
|
| | | import com.gitblit.Constants.AuthorizationControl;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | |
| | | public String displayName;
|
| | | public String emailAddress;
|
| | | public boolean canAdmin;
|
| | | public boolean canFork;
|
| | | public boolean excludeFromFederation;
|
| | | public final Set<String> repositories = new HashSet<String>();
|
| | | public final Set<TeamModel> teams = new HashSet<TeamModel>();
|
| | |
| | | }
|
| | | return false;
|
| | | }
|
| | | |
| | | public boolean canForkRepository(RepositoryModel repository) {
|
| | | if (canAdmin) {
|
| | | return true;
|
| | | }
|
| | | if (!canFork) {
|
| | | // user has been prohibited from forking
|
| | | return false;
|
| | | }
|
| | | if (!isAuthenticated) {
|
| | | // unauthenticated user model
|
| | | return false;
|
| | | }
|
| | | if (("~" + username).equalsIgnoreCase(repository.projectPath)) {
|
| | | // this repository is already a personal repository
|
| | | return false;
|
| | | }
|
| | | if (!repository.allowForks) {
|
| | | // repository prohibits forks
|
| | | return false;
|
| | | }
|
| | | if (repository.accessRestriction.atLeast(AccessRestrictionType.CLONE)) {
|
| | | return canAccessRepository(repository);
|
| | | }
|
| | | // repository is not clone-restricted
|
| | | return true;
|
| | | }
|
| | |
|
| | | public boolean hasRepository(String name) {
|
| | | return repositories.contains(name.toLowerCase());
|