summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/ConfigUserService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/gitblit/ConfigUserService.java')
-rw-r--r--src/main/java/com/gitblit/ConfigUserService.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/com/gitblit/ConfigUserService.java b/src/main/java/com/gitblit/ConfigUserService.java
index d7d6c14f..f57bba20 100644
--- a/src/main/java/com/gitblit/ConfigUserService.java
+++ b/src/main/java/com/gitblit/ConfigUserService.java
@@ -27,6 +27,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jgit.lib.StoredConfig;
@@ -96,6 +97,8 @@ public class ConfigUserService implements IUserService {
private static final String STARRED = "starred";
+ private static final String OWNS = "owns";
+
private static final String LOCALE = "locale";
private static final String EMAILONMYTICKETCHANGES = "emailMeOnMyTicketChanges";
@@ -617,6 +620,11 @@ public class ConfigUserService implements IUserService {
AccessPermission permission = model.removeRepositoryPermission(oldRole);
model.setRepositoryPermission(newRole, permission);
}
+
+ if (model.isOwner(oldRole)) {
+ model.disown(oldRole);
+ model.own(newRole);
+ }
}
// identify teams which require role rename
@@ -764,6 +772,11 @@ public class ConfigUserService implements IUserService {
config.setStringList(USER, model.username, REPOSITORY, permissions);
}
+ // project and repository ownership
+ if (model.ownedPaths != null) {
+ config.setStringList(USER, model.username, OWNS, new ArrayList<String>(model.ownedPaths));
+ }
+
// user preferences
if (model.getPreferences() != null) {
List<String> starred = model.getPreferences().getStarredRepositories();
@@ -927,13 +940,19 @@ public class ConfigUserService implements IUserService {
}
// starred repositories
- Set<String> starred = new HashSet<String>(Arrays.asList(config
+ Set<String> starred = new TreeSet<String>(Arrays.asList(config
.getStringList(USER, username, STARRED)));
for (String repository : starred) {
UserRepositoryPreferences prefs = user.getPreferences().getRepositoryPreferences(repository);
prefs.starred = true;
}
+ // repository ownership
+ Set<String> ownerOf = new TreeSet<String>(Arrays.asList(config.getStringList(USER, username, OWNS)));
+ for (String path : ownerOf) {
+ user.own(path);
+ }
+
// update cache
users.put(user.username, user);
if (!StringUtils.isEmpty(user.cookie)) {