From 3f5b8f5d9203aa7ffb7fbe9cdbaf9dba3da6cae6 Mon Sep 17 00:00:00 2001 From: Hybris95 <hybris_95@hotmail.com> Date: Thu, 01 May 2014 16:14:15 -0400 Subject: [PATCH] Fixes sort, page building and search functions on "my tickets" page. --- src/main/java/com/gitblit/ConfigUserService.java | 29 +++++++++++++++++++---------- 1 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gitblit/ConfigUserService.java b/src/main/java/com/gitblit/ConfigUserService.java index 19e4736..9b4dd7f 100644 --- a/src/main/java/com/gitblit/ConfigUserService.java +++ b/src/main/java/com/gitblit/ConfigUserService.java @@ -98,6 +98,8 @@ private static final String ACCOUNTTYPE = "accountType"; + private static final String DISABLED = "disabled"; + private final File realmFile; private final Logger logger = LoggerFactory.getLogger(ConfigUserService.class); @@ -133,7 +135,7 @@ * @return cookie value */ @Override - public String getCookie(UserModel model) { + public synchronized String getCookie(UserModel model) { if (!StringUtils.isEmpty(model.cookie)) { return model.cookie; } @@ -195,7 +197,7 @@ * @return true if update is successful */ @Override - public boolean updateUserModel(UserModel model) { + public synchronized boolean updateUserModel(UserModel model) { return updateUserModel(model.username, model); } @@ -272,6 +274,9 @@ } read(); originalUser = users.remove(username.toLowerCase()); + if (originalUser != null) { + cookies.remove(originalUser.cookie); + } users.put(model.username.toLowerCase(), model); // null check on "final" teams because JSON-sourced UserModel // can have a null teams object @@ -322,7 +327,7 @@ * @return true if successful */ @Override - public boolean deleteUserModel(UserModel model) { + public synchronized boolean deleteUserModel(UserModel model) { return deleteUser(model.username); } @@ -369,7 +374,7 @@ * @since 0.8.0 */ @Override - public List<String> getAllTeamNames() { + public synchronized List<String> getAllTeamNames() { read(); List<String> list = new ArrayList<String>(teams.keySet()); Collections.sort(list); @@ -444,7 +449,7 @@ * @since 0.8.0 */ @Override - public boolean updateTeamModel(TeamModel model) { + public synchronized boolean updateTeamModel(TeamModel model) { return updateTeamModel(model.name, model); } @@ -456,7 +461,7 @@ * @since 1.2.0 */ @Override - public boolean updateTeamModels(Collection<TeamModel> models) { + public synchronized boolean updateTeamModels(Collection<TeamModel> models) { try { read(); for (TeamModel team : models) { @@ -482,7 +487,7 @@ * @since 0.8.0 */ @Override - public boolean updateTeamModel(String teamname, TeamModel model) { + public synchronized boolean updateTeamModel(String teamname, TeamModel model) { TeamModel original = null; try { read(); @@ -511,7 +516,7 @@ * @since 0.8.0 */ @Override - public boolean deleteTeamModel(TeamModel model) { + public synchronized boolean deleteTeamModel(TeamModel model) { return deleteTeam(model.name); } @@ -523,7 +528,7 @@ * @since 0.8.0 */ @Override - public boolean deleteTeam(String teamname) { + public synchronized boolean deleteTeam(String teamname) { try { // Read realm file read(); @@ -542,7 +547,7 @@ * @return list of all usernames */ @Override - public List<String> getAllUsernames() { + public synchronized List<String> getAllUsernames() { read(); List<String> list = new ArrayList<String>(users.keySet()); Collections.sort(list); @@ -697,6 +702,9 @@ } if (!StringUtils.isEmpty(model.countryCode)) { config.setString(USER, model.username, COUNTRYCODE, model.countryCode); + } + if (model.disabled) { + config.setBoolean(USER, model.username, DISABLED, true); } if (model.getPreferences() != null) { if (!StringUtils.isEmpty(model.getPreferences().locale)) { @@ -865,6 +873,7 @@ if (Constants.EXTERNAL_ACCOUNT.equals(user.password) && user.accountType.isLocal()) { user.accountType = AccountType.EXTERNAL; } + user.disabled = config.getBoolean(USER, username, DISABLED, false); user.organizationalUnit = config.getString(USER, username, ORGANIZATIONALUNIT); user.organization = config.getString(USER, username, ORGANIZATION); user.locality = config.getString(USER, username, LOCALITY); -- Gitblit v1.9.1