Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Place new service contracts implemented by desktop in a `service.desktop` packag
web server in a `service.web` package. The package names describe the implementation side, not the caller.
Give services on opposite sides distinct IDs.

## Shared API base

`com.dbeaver.datadam.api.base` contains `DDRemoteService`, the common interface for DataDam services called over
WebSockets, and `DDExceptionRemote`, their common checked exception extending `DBException`.
Remote DAM, MCP function, and shared-project service contracts share these base types.

## Remote DAM API

[`apis/com.dbeaver.datadam.dam.remote.api`](apis/com.dbeaver.datadam.dam.remote.api/README.md) contains the Remote DAM
Expand Down
11 changes: 11 additions & 0 deletions apis/com.dbeaver.datadam.api.base/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: DataDam API Base
Bundle-SymbolicName: com.dbeaver.datadam.api.base
Bundle-Version: 0.0.19.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-21
Export-Package: com.dbeaver.datadam.api.base
Bundle-ActivationPolicy: lazy
Require-Bundle: org.jkiss.utils
Automatic-Module-Name: com.dbeaver.datadam.api.base
4 changes: 4 additions & 0 deletions apis/com.dbeaver.datadam.api.base/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/main/java
output.. = target/classes/
bin.includes = .,\
META-INF/
54 changes: 54 additions & 0 deletions apis/com.dbeaver.datadam.api.base/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.dbeaver.datadam</groupId>
<artifactId>api</artifactId>
<version>0.0.19-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>com.dbeaver.datadam.api.base</artifactId>
<packaging>eclipse-plugin</packaging>
<name>DataDam API Base</name>

<dependencies>
<dependency>
<groupId>com.dbeaver.common</groupId>
<artifactId>org.jkiss.utils</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.dam.remote.api.transport;
package com.dbeaver.datadam.api.base;

import com.dbeaver.datadam.dam.remote.api.model.DDRemoteDamSessionInfo;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;

/** Receives physical session lifecycle notifications. */
public interface DDRemoteDamSessionListener {
void onConnected(@NotNull DDRemoteDamSessionInfo session);
/** Base checked exception for DataDam remote services. */
public class DDExceptionRemote extends DBException {
public DDExceptionRemote(@NotNull String message) {
super(message);
}

void onDisconnected(@NotNull DDRemoteDamSessionInfo session);
public DDExceptionRemote(@NotNull String message, @NotNull Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.api.base;

/** Base contract for DataDam remote services. */
public interface DDRemoteService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.api.base;

import org.jkiss.dbeaver.DBException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class DDExceptionRemoteTest {
@Test
void preservesMessageAndOptionalCauseAsADatabaseException() {
DBException plain = new DDExceptionRemote("Remote operation failed");
Assertions.assertEquals("Remote operation failed", plain.getMessage());
Assertions.assertNull(plain.getCause());

var cause = new IllegalArgumentException("Invalid request");
DBException wrapped = new DDExceptionRemote("Remote operation failed", cause);
Assertions.assertEquals("Remote operation failed", wrapped.getMessage());
Assertions.assertSame(cause, wrapped.getCause());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ Export-Package: com.dbeaver.datadam.dam.remote.api,
com.dbeaver.messaging.rpc
Bundle-ActivationPolicy: lazy
Require-Bundle: org.jkiss.utils,
com.dbeaver.datadam.api.base;visibility:=reexport,
com.google.gson
Automatic-Module-Name: com.dbeaver.datadam.dam.remote.api
11 changes: 10 additions & 1 deletion apis/com.dbeaver.datadam.dam.remote.api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ See [Messaging](MESSAGING.md) for the neutral request/reply and typed RPC contra

The WebSocket handshake sends `DDRemoteDamHandshakeRequest` with `appDeploymentId`, `appInstanceId`, `workspaceId`,
`clientDamId`, `product`, and `version`, in that constructor order. All six fields are mandatory.
An optional seventh field, `suggestedName`, proposes an initial display name. The six-argument constructor and
requests without this field remain supported; null means no suggestion and is omitted from encoded requests.
When supplied, the name uses the same normalization and 256-Unicode-code-point limit as Account renames;
blank, non-string, and oversized values are rejected.
`DDRemoteDamHandshakeResponse` returns the assigned `damSessionId` and `DDRemoteDamSettings`, containing immutable
`account` and `dam` string maps. The desktop applies this snapshot before registering settings-dependent services
and registers `service.desktop.DDRemoteDamSettingsService` (`dbeaver.dam.settings`) for subsequent complete snapshots. A missing
Expand Down Expand Up @@ -65,6 +69,11 @@ Account derives the account from the authenticated user and enforces authorizati
Names are normalized, limited to 256 Unicode code points, and do not need to be unique. DAMs without a client ID
cannot be renamed. A lookup can return null until the DAM appears in the Account snapshot.

Registration persistence may apply `suggestedName` only when the stored name is unset or equals the stored
deployment ID. Other saved names are preserved. Persistence is asynchronous and does not gate the `ready` response.
Initial naming is part of registration and does not send a separate notification or require a follow-up request.
Later manual renames still use Account GraphQL. Servers without registration naming support may ignore the suggestion.

The shared models remain in this module: `DDRemoteDam`, `DDRemoteDamHistorySession`, `DDRemoteDamTraffic`,
`DDRemoteDamAccountTraffic`, and `DDRemoteDamTrafficDetails`. `DDRemoteDam` retains its nullable `damName`, shared name
validation, and constructor compatibility for unnamed records. These models do not imply a relay RPC contract.
Expand Down Expand Up @@ -100,7 +109,7 @@ validation, and constructor compatibility for unnamed records. These models do n
or `CLOSED` state. Only `CONNECTED` carries `session()` information; `isReady()` tests readiness.
`observeState(observer)` delivers the current state and ordered changes without a snapshot/subscription race. Its returned
subscription closes only that observer. Initial notification can be synchronous; later callbacks run on the notifying
thread. `addSessionListener` remains transitions-only, calling `onConnected` and `onDisconnected` with session information.
thread. Consumers derive connection transitions from these ordered state snapshots.

`DDRemoteDamRequestReplyTransport` adapts a scoped channel to `MessagingRequestReplyEndpoint<JsonObject>`:

Expand Down
5 changes: 5 additions & 0 deletions apis/com.dbeaver.datadam.dam.remote.api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<name>DataDam Remote DAM API</name>

<dependencies>
<dependency>
<groupId>com.dbeaver.datadam</groupId>
<artifactId>com.dbeaver.datadam.api.base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.dbeaver.common</groupId>
<artifactId>org.jkiss.utils</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public final class DDRemoteDamProtocol {
private static final String FIELD_CLIENT_DAM_ID = "clientDamId";
private static final String FIELD_PRODUCT = "product";
private static final String FIELD_VERSION = "version";
private static final String FIELD_SUGGESTED_NAME = "suggestedName";
private static final String FIELD_DAM_SESSION_ID = "damSessionId";

private DDRemoteDamProtocol() {
Expand Down Expand Up @@ -125,6 +126,9 @@ public static String encodeHandshakeRequest(@NotNull DDRemoteDamHandshakeRequest
payload.addProperty(FIELD_CLIENT_DAM_ID, hello.clientDamId());
payload.addProperty(FIELD_PRODUCT, hello.product());
payload.addProperty(FIELD_VERSION, hello.version());
if (hello.suggestedName() != null) {
payload.addProperty(FIELD_SUGGESTED_NAME, hello.suggestedName());
}
return envelope(TYPE_HANDSHAKE_REQUEST, payload).toString();
}

Expand All @@ -137,7 +141,9 @@ public static DDRemoteDamHandshakeRequest decodeHandshakeRequest(@NotNull String
readString(payload, FIELD_WORKSPACE_ID),
readString(payload, FIELD_CLIENT_DAM_ID),
readString(payload, FIELD_PRODUCT),
readString(payload, FIELD_VERSION)
readString(payload, FIELD_VERSION),
payload.has(FIELD_SUGGESTED_NAME) && !payload.get(FIELD_SUGGESTED_NAME).isJsonNull()
? readString(payload, FIELD_SUGGESTED_NAME) : null
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/
package com.dbeaver.datadam.dam.remote.api.exception;

import com.dbeaver.datadam.api.base.DDExceptionRemote;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;

public class DDRemoteDamException extends DBException {
public class DDRemoteDamException extends DDExceptionRemote {
public DDRemoteDamException(@NotNull String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ public record DDRemoteDamHandshakeRequest(
@NotNull String workspaceId,
@NotNull String clientDamId,
@NotNull String product,
@NotNull String version
@NotNull String version,
@Nullable String suggestedName
Comment thread
serge-rider marked this conversation as resolved.
Resolved
) {
public static final int MAX_WORKSPACE_ID_LENGTH = 256;
public static final int MAX_CLIENT_DAM_ID_LENGTH = 2048;

public DDRemoteDamHandshakeRequest(
@NotNull String appDeploymentId, @NotNull String appInstanceId, @NotNull String workspaceId,
@NotNull String clientDamId, @NotNull String product, @NotNull String version
) {
this(appDeploymentId, appInstanceId, workspaceId, clientDamId, product, version, null);
}

public DDRemoteDamHandshakeRequest {
DDRemoteDamMessage.requireText(appDeploymentId, "appDeploymentId");
DDRemoteDamMessage.requireText(appInstanceId, "appInstanceId");
Expand All @@ -43,6 +51,9 @@ public record DDRemoteDamHandshakeRequest(
}
DDRemoteDamMessage.requireText(product, "product");
DDRemoteDamMessage.requireText(version, "version");
if (suggestedName != null) {
suggestedName = DDRemoteDam.normalizeName(suggestedName);
}
}

public static boolean isValidClientDamId(@Nullable String clientDamId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/
package com.dbeaver.datadam.dam.remote.api.service.desktop;

import com.dbeaver.datadam.api.base.DDRemoteService;
import com.dbeaver.datadam.dam.remote.api.exception.DDRemoteDamException;
import com.dbeaver.datadam.dam.remote.api.model.DDRemoteDamSettings;
import org.jkiss.code.NotNull;

public interface DDRemoteDamSettingsService {
public interface DDRemoteDamSettingsService extends DDRemoteService {

Check warning on line 24 in apis/com.dbeaver.datadam.dam.remote.api/src/main/java/com/dbeaver/datadam/dam/remote/api/service/desktop/DDRemoteDamSettingsService.java

View workflow job for this annotation

GitHub Actions / Check / Lint

Checkstyle

Missing a Javadoc comment for 'DDRemoteDamSettingsService'. [MissingJavadocTypeCheck]
String SERVICE_ID = "dbeaver.dam.settings";

void updateSettings(@NotNull DDRemoteDamSettings settings) throws DDRemoteDamException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/
package com.dbeaver.datadam.dam.remote.api.service.desktop;

import com.dbeaver.datadam.api.base.DDRemoteService;
import com.dbeaver.datadam.dam.remote.api.exception.DDRemoteDamException;
import com.dbeaver.datadam.dam.remote.api.model.DDSharedProjectEvent;
import org.jkiss.code.NotNull;

public interface DDSharedProjectEventsService {
public interface DDSharedProjectEventsService extends DDRemoteService {

Check warning on line 24 in apis/com.dbeaver.datadam.dam.remote.api/src/main/java/com/dbeaver/datadam/dam/remote/api/service/desktop/DDSharedProjectEventsService.java

View workflow job for this annotation

GitHub Actions / Check / Lint

Checkstyle

Missing a Javadoc comment for 'DDSharedProjectEventsService'. [MissingJavadocTypeCheck]
String SERVICE_ID = "dbeaver.dam.shared-project-events";

void projectChanged(@NotNull DDSharedProjectEvent event) throws DDRemoteDamException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
*/
package com.dbeaver.datadam.dam.remote.api.service.web;

import com.dbeaver.datadam.api.base.DDRemoteService;
import com.dbeaver.datadam.dam.remote.api.exception.DDRemoteDamException;
import com.dbeaver.datadam.dam.remote.api.model.DDGatewayKeyMaterial;
import com.dbeaver.datadam.dam.remote.api.model.DDGatewayKeyRegistrationStatus;
import org.jkiss.code.NotNull;

/** Account-scoped encryption keys on the web server, accessed by an authenticated Desktop session. */
public interface DDGatewayKeyService {
public interface DDGatewayKeyService extends DDRemoteService {
String SERVICE_ID = "datadam.account.gateway-keys";

/** Whether this account has a configured, encrypted key bundle. Requires storage key read permission. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public interface DDRemoteDamChannel extends AutoCloseable {
@NotNull
DDRemoteDamSubscription subscribe(@NotNull String topic, @NotNull DDRemoteDamMessageListener listener);

@NotNull
DDRemoteDamSubscription addSessionListener(@NotNull DDRemoteDamSessionListener listener);

@Override
void close();
}
Loading
Loading