mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-19 02:20:47 +08:00
dbeaver/pro#10243 add reconcile project list on update (#4571)
Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com> Co-authored-by: Ainur <59531286+yagudin10@users.noreply.github.com>
This commit is contained in:
co-authored by
Daria Marutkina
Ainur
parent
f4b55add99
commit
4475513341
+11
@@ -155,6 +155,17 @@ public abstract class BaseWebSession extends AbstractSessionPersistent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes user permissions, teams and accessible projects.
|
||||
* <p>
|
||||
* Unlike {@link #refreshUserData()} this method must not re-create heavyweight session state
|
||||
* (navigator model, session projects, connection caches), so it is safe to call
|
||||
* for foreign sessions on server-wide events.
|
||||
*/
|
||||
public void refreshUserPermissions() {
|
||||
refreshUserData();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SMAuthSpace getSessionSpace() {
|
||||
|
||||
+44
-2
@@ -262,12 +262,54 @@ public class WebSession extends BaseWebSession
|
||||
|
||||
@Override
|
||||
public void refreshUserData() {
|
||||
super.refreshUserData();
|
||||
refreshSessionAuth();
|
||||
refreshUserPermissions();
|
||||
|
||||
initNavigatorModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshUserPermissions() {
|
||||
super.refreshUserData();
|
||||
refreshSessionAuth();
|
||||
if (getUserId() == null && globalProject != null) {
|
||||
// refreshSessionAuth() updates accessible connections for named users only,
|
||||
// for anonymous sessions this was done by initNavigatorModel()
|
||||
globalProject.refreshAccessibleConnectionIds();
|
||||
}
|
||||
syncSessionProjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds/removes only those session projects whose accessibility actually changed.
|
||||
* <p>
|
||||
* Unlike {@link #initNavigatorModel()} this keeps existing projects, and therefore
|
||||
* their live connections and SQL contexts, intact.
|
||||
*/
|
||||
private void syncSessionProjects() {
|
||||
if (getNavigatorModel() == null) {
|
||||
// model was never initialized for this session - nothing to sync
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Map<String, RMProject> actualProjects = new LinkedHashMap<>();
|
||||
for (RMProject rmProject : getRmController().listAccessibleProjects()) {
|
||||
actualProjects.put(rmProject.getId(), rmProject);
|
||||
}
|
||||
for (WebSessionProjectImpl project : new ArrayList<>(getWorkspace().getProjects())) {
|
||||
if (actualProjects.remove(project.getId()) == null && !project.isInMemory()) {
|
||||
// in-memory (anonymous) projects are never listed by RM
|
||||
deleteSessionProject(project);
|
||||
}
|
||||
}
|
||||
for (RMProject rmProject : actualProjects.values()) {
|
||||
createWebProject(rmProject);
|
||||
}
|
||||
} catch (DBException e) {
|
||||
addSessionError(e);
|
||||
log.error("Error synchronizing accessible projects", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Note: for admin use only
|
||||
public void resetUserState(boolean needResetUserCache) throws DBException {
|
||||
clearAuthTokens();
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public class WSServerConfigurationChangedEventHandler extends WSDefaultEventHand
|
||||
|
||||
@Override
|
||||
protected void updateSessionData(@NotNull BaseWebSession activeUserSession, @NotNull WSServerConfigurationChangedEvent event) {
|
||||
activeUserSession.refreshUserData();
|
||||
activeUserSession.refreshUserPermissions();
|
||||
super.updateSessionData(activeUserSession, event);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -699,7 +699,7 @@ public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
webSession.resetUserState();
|
||||
} else {
|
||||
// Just reload session state
|
||||
webSession.refreshUserData();
|
||||
webSession.refreshUserPermissions();
|
||||
}
|
||||
|
||||
WebAppUtils.getWebApplication().getDriverRegistry().refreshApplicableDrivers();
|
||||
|
||||
Reference in New Issue
Block a user