-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring: avoid redundancy in message response
- Loading branch information
1 parent
e315337
commit 908a6db
Showing
8 changed files
with
68 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...java/de/sovity/edc/extension/custommessages/impl/JsonObjectFromSovityMessageResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package de.sovity.edc.extension.custommessages.impl; | ||
|
||
import de.sovity.edc.utils.jsonld.vocab.Prop; | ||
import jakarta.json.Json; | ||
import jakarta.json.JsonObject; | ||
import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; | ||
import org.eclipse.edc.transform.spi.TransformerContext; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; | ||
|
||
public class JsonObjectFromSovityMessageResponse extends AbstractJsonLdTransformer<SovityMessageResponse, JsonObject> { | ||
|
||
public JsonObjectFromSovityMessageResponse() { | ||
super(SovityMessageResponse.class, JsonObject.class); | ||
} | ||
|
||
@Override | ||
public @Nullable JsonObject transform( | ||
@NotNull SovityMessageResponse message, | ||
@NotNull TransformerContext context) { | ||
|
||
var builder = Json.createObjectBuilder(); | ||
builder.add(TYPE, Prop.SovityMessageExt.RESPONSE) | ||
.add(Prop.SovityMessageExt.HEADER, message.header()) | ||
.add(Prop.SovityMessageExt.BODY, message.body()); | ||
|
||
return builder.build(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...nger/src/main/java/de/sovity/edc/extension/custommessages/impl/SovityMessageResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.sovity.edc.extension.custommessages.impl; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import de.sovity.edc.utils.jsonld.vocab.Prop; | ||
|
||
import java.net.URL; | ||
|
||
public record SovityMessageResponse( | ||
@JsonProperty(Prop.SovityMessageExt.HEADER) | ||
String header, | ||
|
||
@JsonProperty(Prop.SovityMessageExt.BODY) | ||
String body | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters