mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
dbeaver/pro#9392 Nullability annos. DEad code delete.
This commit is contained in:
+9
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* DBeaver - Universal Database Manager
|
||||
* Copyright (C) 2010-2025 DBeaver Corp and others
|
||||
* Copyright (C) 2010-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,6 +60,7 @@ public class CBSessionManager implements WebAppSessionManager {
|
||||
/**
|
||||
* Closes Web Session, associated to HttpSession from {@code request}
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseWebSession closeSession(@NotNull HttpServletRequest request) {
|
||||
HttpSession session = request.getSession();
|
||||
@@ -69,11 +70,13 @@ public class CBSessionManager implements WebAppSessionManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseWebSession closeSession(@NotNull String sessionId) {
|
||||
return closeSession(sessionId, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseWebSession closeSession(@NotNull String sessionId, boolean sendSessionExpiredEvent) {
|
||||
BaseWebSession webSession;
|
||||
@@ -204,7 +207,7 @@ public class CBSessionManager implements WebAppSessionManager {
|
||||
*
|
||||
* @return WebSession object or null, if session expired or invalid
|
||||
*/
|
||||
@Nullable
|
||||
@NotNull
|
||||
public WebSession getOrRestoreWebSession(@NotNull WebHttpRequestInfo requestInfo) {
|
||||
final var sessionId = requestInfo.getId();
|
||||
if (sessionId == null) {
|
||||
@@ -283,7 +286,7 @@ public class CBSessionManager implements WebAppSessionManager {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public WebSession findWebSession(HttpServletRequest request) {
|
||||
public WebSession findWebSession(@NotNull HttpServletRequest request) {
|
||||
String sessionId = getSessionId(request);
|
||||
synchronized (sessionMap) {
|
||||
var session = sessionMap.get(sessionId);
|
||||
@@ -294,8 +297,9 @@ public class CBSessionManager implements WebAppSessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public WebSession findWebSession(HttpServletRequest request, boolean errorOnNoFound) throws DBWebException {
|
||||
public WebSession findWebSession(@NotNull HttpServletRequest request, boolean errorOnNoFound) throws DBWebException {
|
||||
WebSession webSession = findWebSession(request);
|
||||
if (webSession != null) {
|
||||
return webSession;
|
||||
@@ -323,6 +327,7 @@ public class CBSessionManager implements WebAppSessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<BaseWebSession> getAllActiveSessions() {
|
||||
synchronized (sessionMap) {
|
||||
|
||||
+12
-4
@@ -24,16 +24,20 @@ import io.cloudbeaver.model.session.WebSession;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.NotNullWhen;
|
||||
import org.jkiss.code.Nullable;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface WebAppSessionManager {
|
||||
@Nullable
|
||||
BaseWebSession closeSession(@NotNull HttpServletRequest request);
|
||||
|
||||
@Nullable
|
||||
BaseWebSession closeSession(@NotNull String sessionId);
|
||||
|
||||
@Nullable
|
||||
BaseWebSession closeSession(@NotNull String sessionId, boolean sendSessionExpiredEvent);
|
||||
|
||||
@NotNull
|
||||
@@ -53,21 +57,25 @@ public interface WebAppSessionManager {
|
||||
BaseWebSession getSession(@NotNull String sessionId);
|
||||
|
||||
@Nullable
|
||||
WebSession findWebSession(HttpServletRequest request);
|
||||
WebSession findWebSession(@NotNull HttpServletRequest request);
|
||||
|
||||
WebSession findWebSession(HttpServletRequest request, boolean errorOnNoFound) throws DBWebException;
|
||||
@NotNullWhen("errorOnNoFound")
|
||||
WebSession findWebSession(@NotNull HttpServletRequest request, boolean errorOnNoFound) throws DBWebException;
|
||||
|
||||
@NotNull
|
||||
Collection<BaseWebSession> getAllActiveSessions();
|
||||
|
||||
WebSession getOrRestoreWebSession(WebHttpRequestInfo httpRequest);
|
||||
@NotNull
|
||||
WebSession getOrRestoreWebSession(@NotNull WebHttpRequestInfo httpRequest);
|
||||
|
||||
@NotNullWhen("!create")
|
||||
WebHeadlessSession getHeadlessSession(
|
||||
@Nullable String smAccessToken,
|
||||
@NotNull WebHttpRequestInfo requestInfo,
|
||||
boolean create
|
||||
) throws DBException;
|
||||
|
||||
boolean touchSession(HttpServletRequest request, HttpServletResponse response) throws DBWebException;
|
||||
boolean touchSession(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws DBWebException;
|
||||
|
||||
default void expireIdleSessions() {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* DBeaver - Universal Database Manager
|
||||
* Copyright (C) 2010-2024 DBeaver Corp and others
|
||||
* Copyright (C) 2010-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import io.cloudbeaver.model.app.WebAppConfiguration;
|
||||
import io.cloudbeaver.model.app.WebServerConfiguration;
|
||||
import io.cloudbeaver.registry.WebDriverRegistry;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
@@ -54,6 +55,7 @@ public interface WebApplication extends ServletApplication {
|
||||
|
||||
boolean isLicenseValid();
|
||||
|
||||
@Nullable
|
||||
String getLicenseStatus();
|
||||
|
||||
@NotNull
|
||||
|
||||
+12
-5
@@ -77,6 +77,7 @@ public abstract class WebServiceBindingBase<API_TYPE extends DBWService> impleme
|
||||
/**
|
||||
* Creates proxy for permission checks and other general API calls validation/logging.
|
||||
*/
|
||||
@NotNull
|
||||
protected API_TYPE getService(DataFetchingEnvironment env) {
|
||||
Object proxyImpl = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{apiInterface}, new ServiceInvocationHandler(serviceImpl, env));
|
||||
return apiInterface.cast(proxyImpl);
|
||||
@@ -99,20 +100,23 @@ public abstract class WebServiceBindingBase<API_TYPE extends DBWService> impleme
|
||||
}
|
||||
}
|
||||
|
||||
protected static HttpServletResponse getServletResponse(DataFetchingEnvironment env) {
|
||||
@NotNull
|
||||
protected static HttpServletResponse getServletResponse(@NotNull DataFetchingEnvironment env) {
|
||||
return GraphQLEndpoint.getServletResponse(env);
|
||||
}
|
||||
|
||||
protected static DBWBindingContext getBindingContext(DataFetchingEnvironment env) {
|
||||
@NotNull
|
||||
protected static DBWBindingContext getBindingContext(@NotNull DataFetchingEnvironment env) {
|
||||
return GraphQLEndpoint.getBindingContext(env);
|
||||
}
|
||||
|
||||
protected static WebSession getWebSession(DataFetchingEnvironment env) throws DBWebException {
|
||||
@NotNull
|
||||
protected static WebSession getWebSession(@NotNull DataFetchingEnvironment env) throws DBWebException {
|
||||
return getWebSession(env, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static WebSession getSessionFromContext(DataFetchingEnvironment env) {
|
||||
protected static WebSession getSessionFromContext(@NotNull DataFetchingEnvironment env) {
|
||||
return env.getGraphQlContext().get(WebSession.class.getName());
|
||||
}
|
||||
|
||||
@@ -125,6 +129,7 @@ public abstract class WebServiceBindingBase<API_TYPE extends DBWService> impleme
|
||||
return webSession;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static WebSession getWebSession(@NotNull DataFetchingEnvironment env, boolean errorOnNotFound) throws DBWebException {
|
||||
if (env.getGraphQlContext().getBoolean(CloudbeaverCliConstants.CLI_MODE)) {
|
||||
return getSessionFromContextOrThrow(env);
|
||||
@@ -133,6 +138,7 @@ public abstract class WebServiceBindingBase<API_TYPE extends DBWService> impleme
|
||||
GraphQLEndpoint.getServletRequestOrThrow(env), getServletResponse(env), errorOnNotFound);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static String getProjectReference(@NotNull DataFetchingEnvironment env) {
|
||||
return env.getArgument("projectId");
|
||||
}
|
||||
@@ -154,6 +160,7 @@ public abstract class WebServiceBindingBase<API_TYPE extends DBWService> impleme
|
||||
GraphQLEndpoint.getServletRequestOrThrow(env));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static WebSession findWebSession(@NotNull DataFetchingEnvironment env, boolean errorOnNotFound) throws DBWebException {
|
||||
return WebAppUtils.getWebApplication().getSessionManager().findWebSession(
|
||||
GraphQLEndpoint.getServletRequestOrThrow(env), errorOnNotFound);
|
||||
@@ -261,7 +268,7 @@ public abstract class WebServiceBindingBase<API_TYPE extends DBWService> impleme
|
||||
throw new DBException("Web session not instantiated");
|
||||
}
|
||||
|
||||
String projectId = args[objectIdArgumentIndex] == null ? null : String.valueOf(args[objectIdArgumentIndex]);
|
||||
String projectId = args[objectIdArgumentIndex] == null ? "" : String.valueOf(args[objectIdArgumentIndex]);
|
||||
// we should always get the project from the session, even if projectId is null - the active project
|
||||
// will be returned
|
||||
WebProjectImpl project = webSession.getProjectById(projectId);
|
||||
|
||||
Reference in New Issue
Block a user