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

feat: Add C2C custom messages #970

Merged
merged 42 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9ed0d1b
WiP: echo service and foundation for sending messages
ununhexium Jun 11, 2024
5c6a0b9
WiP kinda works
ununhexium Jun 11, 2024
b88d17c
WiP adapt tests
ununhexium Jun 12, 2024
1f23808
WiP: generic custom messgae: cancelled
ununhexium Jun 12, 2024
810d6be
WiP: roundtrip
ununhexium Jun 13, 2024
c827160
Waypoint: Generic echo service
ununhexium Jun 13, 2024
9f94781
Add test for the handlers
ununhexium Jun 13, 2024
23a2db1
Working e2e samples
ununhexium Jun 13, 2024
4ef66b2
Add demo
ununhexium Jun 13, 2024
ada26d5
Refactor demo folder
ununhexium Jun 14, 2024
ec8f734
Remove lombok usage for Kotlin demo
ununhexium Jun 14, 2024
776cd2c
rm obsolete TODO
ununhexium Jun 14, 2024
397365b
rm obsolete TODO
ununhexium Jun 14, 2024
587f010
Ensure message is authorized
ununhexium Jun 14, 2024
e315337
Rename SovityMessageRequest
ununhexium Jun 14, 2024
908a6db
Refactoring: avoid redundancy in message response
ununhexium Jun 14, 2024
e3fb2b8
Refactoring: use real message type directly
ununhexium Jun 14, 2024
8a60741
Report sovity handler misconfiguration as exception
ununhexium Jun 14, 2024
ecfbf73
Throw exception when a handler fault happened
ununhexium Jun 14, 2024
9dc6a62
cleanup
ununhexium Jun 14, 2024
1ac080b
cleanup
ununhexium Jun 14, 2024
364ee63
move package
ununhexium Jun 14, 2024
468b88b
Add doc and demo
ununhexium Jun 14, 2024
5502f5f
Checkstyle
ununhexium Jun 14, 2024
0e8a938
Remove useless code
ununhexium Jun 14, 2024
7ba4195
More doc and cleanup
ununhexium Jun 14, 2024
c2d3abb
Checkstyle
ununhexium Jun 14, 2024
e594632
Increase timeout for GH tests
ununhexium Jun 14, 2024
459e9fb
Headers
ununhexium Jun 14, 2024
73f1455
Code review
ununhexium Jun 17, 2024
d1b034d
cleanup and checkstyle
ununhexium Jun 17, 2024
eb931d5
Fix dead links
ununhexium Jun 17, 2024
3c0b8a9
Fix links
ununhexium Jun 17, 2024
3493fcc
Core review, Add exception handling and feedback
ununhexium Jun 19, 2024
0efc027
Fix space issue
ununhexium Jun 19, 2024
5bcd9ce
Format for checkstyle
ununhexium Jun 19, 2024
a112ec6
Merge branch 'main' into 1108-custom-c2c-messages
ununhexium Jun 19, 2024
327caee
Cleanup
ununhexium Jun 20, 2024
d6e1678
Disable test demo
ununhexium Jun 20, 2024
3984155
Add payload to sovity messenger exception
ununhexium Jun 20, 2024
830bdc7
Remove Kotlin plugin from previous attempt
ununhexium Jun 25, 2024
c5ec552
Merge branch 'main' into 1108-custom-c2c-messages
richardtreier Jun 25, 2024
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 4
ij_continuation_indent_size = 4

[*.ts]
quote_type = single
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md).

#### Minor Changes

- Add the SovityMessenger extension

#### Patch Changes

- Postman-collection: Fixed an issue where an API-call was previously wrong in the details of the POST-body.
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("java")
id("checkstyle")
id("maven-publish")
kotlin("jvm") version "2.0.0"
ununhexium marked this conversation as resolved.
Show resolved Hide resolved
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/checkstyle/checkstyle-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
<property name="braceAdjustment" value="4"/>
<property name="caseIndent" value="4"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="8"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="4"/>
</module>
<module name="AbbreviationAsWordInName">
Expand Down
75 changes: 75 additions & 0 deletions extensions/sovity-messenger-demo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
plugins {
`java-library`
`maven-publish`
}

dependencies {
annotationProcessor(libs.lombok)

compileOnly(libs.lombok)

implementation(project(":extensions:sovity-messenger"))

implementation(libs.edc.controlPlaneCore)
implementation(libs.edc.dspApiConfiguration)
implementation(libs.edc.dspHttpSpi)
implementation(libs.edc.httpSpi)
implementation(libs.edc.managementApiConfiguration)

// implementation("com.squareup.okhttp3:okhttp:${okHttpVersion}")
ununhexium marked this conversation as resolved.
Show resolved Hide resolved
// implementation("org.json:json:${jsonVersion}")
// implementation("org.glassfish.jersey.media:jersey-media-multipart:3.1.3")
//
// implementation("de.fraunhofer.iais.eis.ids.infomodel:infomodel-java:1.0.2-basecamp")
// implementation("de.fraunhofer.iais.eis.ids.infomodel:infomodel-util:1.0.2-basecamp")
//

testAnnotationProcessor(libs.lombok)

testCompileOnly(libs.lombok)

testImplementation(project(":utils:test-connector-remote"))

testImplementation(libs.edc.junit)
testImplementation(libs.edc.dataPlaneSelectorCore)
testImplementation(libs.edc.dspApiConfiguration)
testImplementation(libs.edc.dspHttpCore)
testImplementation(libs.edc.iamMock)
testImplementation(libs.edc.jsonLd)

testImplementation(libs.edc.http) {
exclude(group = "org.eclipse.jetty", module = "jetty-client")
exclude(group = "org.eclipse.jetty", module = "jetty-http")
exclude(group = "org.eclipse.jetty", module = "jetty-io")
exclude(group = "org.eclipse.jetty", module = "jetty-server")
exclude(group = "org.eclipse.jetty", module = "jetty-util")
exclude(group = "org.eclipse.jetty", module = "jetty-webapp")
}

// Updated jetty versions for e.g. CVE-2023-26048
testImplementation(libs.bundles.jetty.cve2023)

testImplementation(libs.assertj.core)
testImplementation(libs.junit.api)
testImplementation(libs.jsonAssert)
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.restAssured.restAssured)
testImplementation(libs.testcontainers.testcontainers)
testImplementation(libs.testcontainers.junitJupiter)
testImplementation(libs.testcontainers.postgresql)

testRuntimeOnly(libs.junit.engine)
}

tasks.getByName<Test>("test") {
useJUnitPlatform()
}

publishing {
publications {
create<MavenPublication>(project.name) {
from(components["java"])
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.extension.sovitymessenger.demo;

import de.sovity.edc.extension.messenger.api.MessageHandlerRegistry;
import de.sovity.edc.extension.messenger.api.SovityMessenger;
import de.sovity.edc.extension.sovitymessenger.demo.message.Addition;
import de.sovity.edc.extension.sovitymessenger.demo.message.Answer;
import de.sovity.edc.extension.sovitymessenger.demo.message.Sqrt;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;

import java.util.function.Function;

import static java.lang.Math.sqrt;


public class SovityMessengerDemo implements ServiceExtension {

public static final String NAME = "sovityMessengerDemo";

@Override
public String name() {
return NAME;
}

/*
* 3 parts are needed:
* - the messenger
* - the handler registry
* - your handlers
*/

@Inject
private SovityMessenger sovityMessenger;

@Inject
private MessageHandlerRegistry registry;
ununhexium marked this conversation as resolved.
Show resolved Hide resolved

@Override
public void initialize(ServiceExtensionContext context) {
// Register the various messages that you would like to process.
registry.register(Sqrt.class, (Function<Sqrt, Answer>) single -> new Answer(sqrt(single.getValue())));
registry.register(Addition.class, (Function<Addition, Answer>) add -> new Answer(add.op1 + add.op2));

/*
* In the counterpart connector, messages can be sent with the code below.
* Check out the de.sovity.edc.extension.sovitymessenger.demo.SovityMessengerDemoTest#demo()
* for a detailed usage.
*/

// val answer = sovityMessenger.send(Answer.class, "http://localhost/api/dsp", new Sqrt(9.0));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.extension.sovitymessenger.demo.message;

import com.fasterxml.jackson.annotation.JsonProperty;
import de.sovity.edc.extension.messenger.api.SovityMessage;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static de.sovity.edc.extension.sovitymessenger.demo.message.Common.ROOT;

@Getter
@AllArgsConstructor
@NoArgsConstructor
public class Addition implements SovityMessage {

@Override
public String getType() {
return ROOT + "add";
}

@JsonProperty
public int op1;

@JsonProperty
public int op2;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.extension.sovitymessenger.demo.message;

import com.fasterxml.jackson.annotation.JsonProperty;
import de.sovity.edc.extension.messenger.api.SovityMessage;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static de.sovity.edc.extension.sovitymessenger.demo.message.Common.ROOT;

@AllArgsConstructor
@NoArgsConstructor
@Getter
public class Answer implements SovityMessage {

@Override
public String getType() {
return ROOT + "answer";
}

@JsonProperty
private double answer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.extension.sovitymessenger.demo.message;

public interface Common {
String ROOT = "de.sovity.demo.calculator.";
}
ununhexium marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.extension.sovitymessenger.demo.message;


import com.fasterxml.jackson.annotation.JsonProperty;
import de.sovity.edc.extension.messenger.api.SovityMessage;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static de.sovity.edc.extension.sovitymessenger.demo.message.Common.ROOT;

@AllArgsConstructor
@NoArgsConstructor
@Getter
public class Sqrt implements SovityMessage {

private static final String TYPE = ROOT + "sqrt";

@Override
public String getType() {
return TYPE;
}

@JsonProperty
private double value;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.extension.sovitymessenger.demo.message;

import de.sovity.edc.extension.messenger.api.SovityMessage;

public class UnregisteredMessage implements SovityMessage {

@Override
public String getType() {
return "UNREGISTERED";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de.sovity.edc.extension.sovitymessenger.demo.SovityMessengerDemo
ununhexium marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading