diff options
author | James Moger <james.moger@gitblit.com> | 2013-05-30 23:13:48 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-05-30 23:13:48 -0400 |
commit | 79d3240ea489067f3eb1af5e535b3687c507a249 (patch) | |
tree | 206ad6116ba02e837637f8f9c2b832ca0198408a /src/main/java/com/gitblit/ConfigUserService.java | |
parent | e17926272c849c920650b259107a41ca69046900 (diff) | |
download | gitblit-79d3240ea489067f3eb1af5e535b3687c507a249.tar.gz gitblit-79d3240ea489067f3eb1af5e535b3687c507a249.zip |
Added simple star/unstar function
Diffstat (limited to 'src/main/java/com/gitblit/ConfigUserService.java')
-rw-r--r-- | src/main/java/com/gitblit/ConfigUserService.java | 21 |
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 7aa09985..f2bd7b82 100644 --- a/src/main/java/com/gitblit/ConfigUserService.java +++ b/src/main/java/com/gitblit/ConfigUserService.java @@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory; import com.gitblit.Constants.AccessPermission;
import com.gitblit.models.TeamModel;
import com.gitblit.models.UserModel;
+import com.gitblit.models.UserRepositoryPreferences;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.DeepCopier;
import com.gitblit.utils.StringUtils;
@@ -88,7 +89,9 @@ public class ConfigUserService implements IUserService { private static final String PRERECEIVE = "preReceiveScript";
private static final String POSTRECEIVE = "postReceiveScript";
-
+
+ private static final String STARRED = "starred";
+
private final File realmFile;
private final Logger logger = LoggerFactory.getLogger(ConfigUserService.class);
@@ -879,6 +882,14 @@ public class ConfigUserService implements IUserService { }
config.setStringList(USER, model.username, REPOSITORY, permissions);
}
+
+ // user preferences
+ if (model.getPreferences() != null) {
+ List<String> starred = model.getPreferences().getStarredRepositories();
+ if (starred.size() > 0) {
+ config.setStringList(USER, model.username, STARRED, starred);
+ }
+ }
}
// write teams
@@ -1021,6 +1032,14 @@ public class ConfigUserService implements IUserService { }
}
+ // starred repositories
+ Set<String> starred = new HashSet<String>(Arrays.asList(config
+ .getStringList(USER, username, STARRED)));
+ for (String repository : starred) {
+ UserRepositoryPreferences prefs = user.getPreferences().getRepositoryPreferences(repository);
+ prefs.starred = true;
+ }
+
// update cache
users.put(user.username, user);
if (!StringUtils.isEmpty(user.cookie)) {
|