Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3388]Remove the deleted roles and permissions info during reloading role info #3419

Closed
wants to merge 7 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -95,8 +96,29 @@ private void reload() {
tmpPermissionInfoMap.put(role, permissionInfoPage.getPageItems());
}

Iterator<String> roleIt = roleSet.iterator();
while (roleIt.hasNext()) {
String role = roleIt.next();
if (!tmpRoleSet.contains(role)) {
roleIt.remove();
}
}
roleSet.addAll(tmpRoleSet);

for (Iterator<Map.Entry<String, List<RoleInfo>>> roleInfoIt = roleInfoMap.entrySet().iterator(); roleInfoIt.hasNext();) {
Map.Entry<String, List<RoleInfo>> item = roleInfoIt.next();
if (!tmpRoleInfoMap.containsKey(item.getKey())) {
roleInfoIt.remove();
}
}
roleInfoMap.putAll(tmpRoleInfoMap);

for (Iterator<Map.Entry<String, List<PermissionInfo>>> permissionIt = permissionInfoMap.entrySet().iterator(); permissionIt.hasNext();) {
Map.Entry<String, List<PermissionInfo>> item = permissionIt.next();
if (!tmpPermissionInfoMap.containsKey(item.getKey())) {
permissionIt.remove();
}
}
permissionInfoMap.putAll(tmpPermissionInfoMap);
} catch (Exception e) {
Loggers.AUTH.warn("[LOAD-ROLES] load failed", e);
Expand Down