From fbe265fa787e4be9cb63c6bae2ef30b9400d9afc Mon Sep 17 00:00:00 2001
From: Simon Harrer <simon.harrer@gmail.com>
Date: Thu, 18 Jul 2013 10:11:04 -0400
Subject: [PATCH] Fixes findbugs warning - dereferencing null in exception case
---
src/main/java/com/gitblit/models/UserModel.java | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java
index e4c659c..6d58512 100644
--- a/src/main/java/com/gitblit/models/UserModel.java
+++ b/src/main/java/com/gitblit/models/UserModel.java
@@ -75,17 +75,21 @@
// non-persisted fields
public boolean isAuthenticated;
public AccountType accountType;
+
+ public UserPreferences userPreferences;
public UserModel(String username) {
this.username = username;
this.isAuthenticated = true;
this.accountType = AccountType.LOCAL;
+ this.userPreferences = new UserPreferences(this.username);
}
private UserModel() {
this.username = "$anonymous";
this.isAuthenticated = false;
this.accountType = AccountType.LOCAL;
+ this.userPreferences = new UserPreferences(this.username);
}
public boolean isLocalAccount() {
@@ -269,7 +273,13 @@
}
public void setRepositoryPermission(String repository, AccessPermission permission) {
- permissions.put(repository.toLowerCase(), permission);
+ if (permission == null) {
+ // remove the permission
+ permissions.remove(repository.toLowerCase());
+ } else {
+ // set the new permission
+ permissions.put(repository.toLowerCase(), permission);
+ }
}
public RegistrantAccessPermission getRepositoryPermission(RepositoryModel repository) {
@@ -602,6 +612,10 @@
return "~" + username;
}
+ public UserPreferences getPreferences() {
+ return userPreferences;
+ }
+
@Override
public int hashCode() {
return username.hashCode();
--
Gitblit v1.9.1