Skip to content

Commit

Permalink
DURACLOUD-1226: Ensures that instances are notified when user root pe…
Browse files Browse the repository at this point in the history
…rmission changes. (PR #25)

Resolves: https://jira.duraspace.org/browse/DURACLOUD-1226
  • Loading branch information
dbernstein authored and bbranan committed Mar 5, 2019
1 parent 259e3e5 commit a99170c
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ public void deleteUser(Long userId) {
// Remove the user
getUserRepo().delete(userId);

notifyUserChange(accountRights);
if (user.isRoot()) {
notifyRootUsersChanged();
} else {
notifyUserChange(accountRights);
}
}

@Override
Expand All @@ -111,11 +115,8 @@ public void setRootUser(Long userId) {
// Adding root from the user
DuracloudUser user = repoMgr.getUserRepo().findOne(userId);
user.setRoot(true);
notifyRootUsersChanged();

// Load user rights
List<AccountRights> accountRights = getRightsRepo().findByUserId(userId);

notifyUserChange(accountRights);
}

@Override
Expand All @@ -125,11 +126,7 @@ public void unsetRootUser(Long userId) {
// Remove root from the user
DuracloudUser user = repoMgr.getUserRepo().findOne(userId);
user.setRoot(false);

// Load user rights
List<AccountRights> accountRights = getRightsRepo().findByUserId(userId);

notifyUserChange(accountRights);
notifyRootUsersChanged();
}

private void notifyUserChange(List<AccountRights> accountRights) {
Expand All @@ -142,6 +139,14 @@ private void notifyUserChange(List<AccountRights> accountRights) {
}
}

private void notifyRootUsersChanged() {
try {
this.accountChangeNotifier.rootUsersChanged();
} catch (Exception ex) {
log.error("failed to notify of user change: " + ex.getMessage(), ex);
}
}

private void notifyAccountChange(List<AccountRights> accountRights) {
for (AccountRights right : accountRights) {
try {
Expand Down

0 comments on commit a99170c

Please sign in to comment.