| | |
| | | import java.util.Arrays;
|
| | | import java.util.Collection;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | |
|
| | | import com.gitblit.Constants.AccessPermission;
|
| | | import com.gitblit.Constants.FederationPullStatus;
|
| | | import com.gitblit.Constants.FederationStrategy;
|
| | | import com.gitblit.GitBlitException.ForbiddenException;
|
| | |
| | | repositoryName.indexOf(DOT_GIT_EXT));
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | // confirm that the origin of any pre-existing repository matches
|
| | | // the clone url
|
| | | String fetchHead = null;
|
| | | Repository existingRepository = GitBlit.self().getRepository(repositoryName);
|
| | | |
| | | if (existingRepository == null && GitBlit.self().isCollectingGarbage(repositoryName)) {
|
| | | logger.warn(MessageFormat.format("Skipping local repository {0}, busy collecting garbage", repositoryName));
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (existingRepository != null) {
|
| | | StoredConfig config = existingRepository.getConfig();
|
| | | config.load();
|
| | |
| | | // reparent all repository permissions if the local
|
| | | // repositories are stored within subfolders
|
| | | if (!StringUtils.isEmpty(registrationFolder)) {
|
| | | List<String> permissions = new ArrayList<String>(user.repositories);
|
| | | user.repositories.clear();
|
| | | for (String permission : permissions) {
|
| | | user.addRepository(registrationFolder + "/" + permission);
|
| | | if (user.permissions != null) {
|
| | | // pulling from >= 1.2 version
|
| | | Map<String, AccessPermission> copy = new HashMap<String, AccessPermission>(user.permissions);
|
| | | user.permissions.clear();
|
| | | for (Map.Entry<String, AccessPermission> entry : copy.entrySet()) {
|
| | | user.setRepositoryPermission(registrationFolder + "/" + entry.getKey(), entry.getValue());
|
| | | }
|
| | | } else {
|
| | | // pulling from <= 1.1 version
|
| | | List<String> permissions = new ArrayList<String>(user.repositories);
|
| | | user.repositories.clear();
|
| | | for (String permission : permissions) {
|
| | | user.addRepositoryPermission(registrationFolder + "/" + permission);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | GitBlit.self().updateUserModel(user.username, user, true);
|
| | | } else {
|
| | | // update repository permissions of local user
|
| | | for (String repository : user.repositories) {
|
| | | localUser.addRepository(repository);
|
| | | if (user.permissions != null) {
|
| | | // pulling from >= 1.2 version
|
| | | Map<String, AccessPermission> copy = new HashMap<String, AccessPermission>(user.permissions);
|
| | | for (Map.Entry<String, AccessPermission> entry : copy.entrySet()) {
|
| | | localUser.setRepositoryPermission(entry.getKey(), entry.getValue());
|
| | | }
|
| | | } else {
|
| | | // pulling from <= 1.1 version
|
| | | for (String repository : user.repositories) {
|
| | | localUser.addRepositoryPermission(repository);
|
| | | }
|
| | | }
|
| | | localUser.password = user.password;
|
| | | localUser.canAdmin = user.canAdmin;
|
| | |
| | |
|
| | | // update team repositories
|
| | | TeamModel remoteTeam = user.getTeam(teamname);
|
| | | if (remoteTeam != null && !ArrayUtils.isEmpty(remoteTeam.repositories)) {
|
| | | int before = team.repositories.size();
|
| | | team.addRepositories(remoteTeam.repositories);
|
| | | int after = team.repositories.size();
|
| | | if (after > before) {
|
| | | // repository count changed, update
|
| | | if (remoteTeam != null) {
|
| | | if (remoteTeam.permissions != null) {
|
| | | // pulling from >= 1.2
|
| | | for (Map.Entry<String, AccessPermission> entry : remoteTeam.permissions.entrySet()){
|
| | | team.setRepositoryPermission(entry.getKey(), entry.getValue());
|
| | | }
|
| | | GitBlit.self().updateTeamModel(teamname, team, false);
|
| | | } else if(!ArrayUtils.isEmpty(remoteTeam.repositories)) {
|
| | | // pulling from <= 1.1
|
| | | team.addRepositoryPermissions(remoteTeam.repositories);
|
| | | GitBlit.self().updateTeamModel(teamname, team, false);
|
| | | }
|
| | | }
|