\r
#### fixes\r
\r
+- Restore original user or team object on failure to update (issue 118)\r
- Repository URL uses `X-Forwarded-Proto` and `X-Forwarded-Port`, if available, for reverse proxy configurations (issue 115)\r
- Fixes to relative path determination in repository searh algorithm for symlinks (issue 116)\r
- Output real RAW content, not simulated RAW content (issue 114)\r
*/\r
@Override\r
public boolean updateUserModel(String username, UserModel model) {\r
+ UserModel originalUser = null;\r
try {\r
read();\r
- UserModel oldUser = users.remove(username.toLowerCase());\r
+ originalUser = users.remove(username.toLowerCase());\r
users.put(model.username.toLowerCase(), model);\r
// null check on "final" teams because JSON-sourced UserModel\r
// can have a null teams object\r
}\r
\r
// check for implicit team removal\r
- if (oldUser != null) {\r
- for (TeamModel team : oldUser.teams) {\r
+ if (originalUser != null) {\r
+ for (TeamModel team : originalUser.teams) {\r
if (!model.isTeamMember(team.name)) {\r
team.removeUser(username);\r
}\r
write();\r
return true;\r
} catch (Throwable t) {\r
+ if (originalUser != null) {\r
+ // restore original user\r
+ users.put(originalUser.username, originalUser);\r
+ }\r
logger.error(MessageFormat.format("Failed to update user model {0}!", model.username),\r
t);\r
}\r
*/\r
@Override\r
public boolean updateTeamModel(String teamname, TeamModel model) {\r
+ TeamModel original = null;\r
try {\r
read();\r
- teams.remove(teamname.toLowerCase());\r
+ original = teams.remove(teamname.toLowerCase());\r
teams.put(model.name.toLowerCase(), model);\r
write();\r
return true;\r
} catch (Throwable t) {\r
+ if (original != null) {\r
+ // restore original team\r
+ teams.put(original.name, original);\r
+ }\r
logger.error(MessageFormat.format("Failed to update team model {0}!", model.name), t);\r
}\r
return false;\r