From f201ca80f398c54341aad33f139778bc4e9fa357 Mon Sep 17 00:00:00 2001 From: albertrodriguezin2 <166031280+albertrodriguezin2@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:03:14 +0100 Subject: [PATCH] fix(infrastructure): upsert entities in scorpio instead of update (#62) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(infrastructure): upsert entities in scorpio instead of update * Update CHANGELOG.md --------- Co-authored-by: Oriol Canadés --- CHANGELOG.md | 6 ++++++ build.gradle | 2 +- .../services/broker/adapter/impl/ScorpioAdapter.java | 7 ++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca871493..b069a567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Retry mechanism for Blockchain Adapter and Context Broker. - Recover after a failure mechanism for Blockchain Adapter and Context Broker. +## [Released]: v1.0.2 +- Change the update entity to allow adding new attributes to the entity. + +## [Released]: v1.0.1 +- Set startDateTime as non required + ## [Released]: v1.0.0 - DOME Participant validation - P2P synchronization diff --git a/build.gradle b/build.gradle index 472e3cf9..4b90bb37 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ plugins { } group = 'es.in2' -version = '1.0.1' +version = '1.0.2' java { sourceCompatibility = '17' diff --git a/src/main/java/es/in2/desmos/domain/services/broker/adapter/impl/ScorpioAdapter.java b/src/main/java/es/in2/desmos/domain/services/broker/adapter/impl/ScorpioAdapter.java index b2598c80..d9b08ed7 100644 --- a/src/main/java/es/in2/desmos/domain/services/broker/adapter/impl/ScorpioAdapter.java +++ b/src/main/java/es/in2/desmos/domain/services/broker/adapter/impl/ScorpioAdapter.java @@ -100,14 +100,15 @@ public Mono getEntityById(String processId, String entityId) { @Override public Mono updateEntity(String processId, String requestBody) { + String requestBodyAsArray = "[" + requestBody + "]"; return extractEntityIdFromRequestBody(processId, requestBody) .flatMap(entityId -> { MediaType mediaType = getContentTypeAndAcceptMediaType(requestBody); - return webClient.patch() - .uri(brokerConfig.getEntitiesPath() + "/" + entityId + "/attrs") + return webClient.post() + .uri(brokerConfig.getEntityOperationsPath() + "/upsert") .accept(mediaType) .contentType(mediaType) - .bodyValue(requestBody) + .bodyValue(requestBodyAsArray) .retrieve() .bodyToMono(Void.class) .retry(3);