mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-2268 add session expired exception for sessionState
This commit is contained in:
+5
-1
@@ -27,7 +27,6 @@ import io.cloudbeaver.server.CBApplication;
|
||||
import io.cloudbeaver.server.CBPlatform;
|
||||
import io.cloudbeaver.server.graphql.GraphQLEndpoint;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.Log;
|
||||
import org.jkiss.dbeaver.model.rm.RMProject;
|
||||
@@ -126,6 +125,11 @@ public abstract class WebServiceBindingBase<API_TYPE extends DBWService> impleme
|
||||
getServletRequest(env));
|
||||
}
|
||||
|
||||
public static WebSession findWebSession(DataFetchingEnvironment env, boolean errorOnNotFound) throws DBWebException {
|
||||
return CBPlatform.getInstance().getSessionManager().findWebSession(
|
||||
getServletRequest(env), errorOnNotFound);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static WebConnectionInfo getWebConnection(WebSession session, String projectId, String connectionId) throws DBWebException {
|
||||
return session.getWebConnectionInfo(projectId, connectionId);
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class WebServiceBindingCore extends WebServiceBindingBase<DBWServiceCore>
|
||||
getWebSession(env), getProjectReference(env), env.getArgument("path")))
|
||||
|
||||
.dataFetcher("sessionPermissions", env -> getService(env).getSessionPermissions(getWebSession(env)))
|
||||
.dataFetcher("sessionState", env -> getService(env).getSessionState(findWebSession(env)))
|
||||
.dataFetcher("sessionState", env -> getService(env).getSessionState(findWebSession(env, true)))
|
||||
|
||||
.dataFetcher("connectionInfo", env -> getService(env).getConnectionState(
|
||||
getWebSession(env), getProjectReference(env), env.getArgument("id")))
|
||||
|
||||
+11
@@ -149,6 +149,17 @@ public class WebSessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
public WebSession findWebSession(HttpServletRequest request, boolean errorOnNoFound) throws DBWebException {
|
||||
WebSession webSession = findWebSession(request);
|
||||
if (webSession != null) {
|
||||
return webSession;
|
||||
}
|
||||
if (errorOnNoFound) {
|
||||
throw new DBWebException("Session has expired", DBWebException.ERROR_CODE_SESSION_EXPIRED);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void expireIdleSessions() {
|
||||
long maxSessionIdleTime = DBWorkbench.getPlatform(CBPlatform.class).getApplication().getMaxSessionIdleTime();
|
||||
if (CBApplication.getInstance().isConfigurationMode()) {
|
||||
|
||||
Reference in New Issue
Block a user