diff --git a/CHANGELOG.md b/CHANGELOG.md
index bb82f07..8fe4dc2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# Changelog
+## [2.0.0] - [unreleased]
+
+## Added
+- Implement `triggerNegotiation` function in `NegotiationServiceLogic` to handle sequential negotiation requests with external services, enhancing the negotiation process with error handling and response transformation.
+- Introduce new DTOs (`NegotiationRequestDTO`, `NegotiationResponseDTO`, `EDRResponseDTO`) to streamline the handling of negotiation data and responses.
+- Add utility functions in `EdcEndpointsMappingUtils` for parsing and extracting specific fields from JSON responses, improving data extraction reliability and code maintainability.
+
+## Changed
+- Modify `executeSequentialNegotiationRequests` logic to include additional steps in the negotiation process, ensuring the correct sequence of requests and proper handling of intermediate responses.
+- Update error handling across the negotiation process to log detailed error messages and fallback values, improving debugging and reliability.
+- Refactor `createNegotiationRequestBody` to dynamically generate request bodies based on input parameters, enhancing flexibility and readability.
+
+## Fixed
+- Address issue with incorrect extraction of `transferProcessId` by adjusting JSON path in `extractTransferProcessId` function.
+
+
## [1.3.2] - [2024-04-17]
### Changed
diff --git a/pom.xml b/pom.xml
index 08522a0..222c4e4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
org.eclipse.tractusxvalue-added-service
- 1.3.2
+ 2.0.0vas-country-risk-backendProject to Validate Country Risks Score
diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/config/EdcProperties.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/config/EdcProperties.java
new file mode 100644
index 0000000..f6288cd
--- /dev/null
+++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/config/EdcProperties.java
@@ -0,0 +1,38 @@
+/********************************************************************************
+ * Copyright (c) 2022,2024 BMW Group AG
+ * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * 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.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+package org.eclipse.tractusx.valueaddedservice.config;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.List;
+
+@Setter
+@Getter
+@Configuration
+@ConfigurationProperties(prefix = "application.edc")
+public class EdcProperties {
+
+ private List providers;
+
+
+}
diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/config/SecurityConfiguration.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/config/SecurityConfiguration.java
index 227f0b4..7198b19 100644
--- a/src/main/java/org/eclipse/tractusx/valueaddedservice/config/SecurityConfiguration.java
+++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/config/SecurityConfiguration.java
@@ -44,7 +44,7 @@ public class SecurityConfiguration {
public SecurityFilterChain securityFilterChain(final HttpSecurity httpSecurity) throws Exception {
httpSecurity.cors(withDefaults())
.authorizeHttpRequests((auth-> auth
- .requestMatchers("/error","/api/dashboard/**","/api/sharing/**","/api/edc/**")
+ .requestMatchers("/error","/api/dashboard/**","/api/sharing/**","/api/negotiation/**")
.authenticated()
.requestMatchers("/v3/api-docs/**", "/swagger-ui.html", "/swagger-ui/**","/management/**")
.permitAll()
diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/CatalogItemDTO.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/CatalogItemDTO.java
new file mode 100644
index 0000000..05fca5a
--- /dev/null
+++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/CatalogItemDTO.java
@@ -0,0 +1,48 @@
+/********************************************************************************
+ * Copyright (c) 2022,2024 BMW Group AG
+ * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * 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.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+package org.eclipse.tractusx.valueaddedservice.dto.edc;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+
+@Setter
+@Getter
+@ToString
+@AllArgsConstructor
+@NoArgsConstructor
+@Schema(description = "Represents a catalog item available for negotiation")
+public class CatalogItemDTO {
+
+ @Schema(description = "Unique identifier of the catalog item", example = "1", required = true)
+ private String id;
+
+ @Schema(description = "Identifier of the offer associated with the catalog item", example = "offer123", required = true)
+ private String offerId;
+
+ @Schema(description = "Provider of the catalog item", example = "Provider A")
+ private String provider;
+
+ @Schema(description = "Subject of the catalog item", example = "cx-taxo:ReadAccessPoolForCatenaXMember")
+ private String subject;
+
+ @Schema(description = "Description of the catalog item", example = "Grants the Catena-X Member read access to the Pool API...")
+ private String description;
+}
+
diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/EDRResponse.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/EDRResponseDTO.java
similarity index 97%
rename from src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/EDRResponse.java
rename to src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/EDRResponseDTO.java
index 09e5e57..6da4c8c 100644
--- a/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/EDRResponse.java
+++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/EDRResponseDTO.java
@@ -26,7 +26,7 @@
@Setter
@Getter
@ToString
-public class EDRResponse {
+public class EDRResponseDTO {
private String authCode;
private String endpoint;
diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/NegotiationRequestDTO.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/NegotiationRequestDTO.java
new file mode 100644
index 0000000..201c590
--- /dev/null
+++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/NegotiationRequestDTO.java
@@ -0,0 +1,39 @@
+/********************************************************************************
+ * Copyright (c) 2022,2024 BMW Group AG
+ * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * 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.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+package org.eclipse.tractusx.valueaddedservice.dto.edc;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+
+@Setter
+@Getter
+@ToString
+@AllArgsConstructor
+@NoArgsConstructor
+@Schema(description = "Data Transfer Object for initiating a negotiation request")
+public class NegotiationRequestDTO {
+
+ @Schema(description = "Unique identifier of the catalog item", example = "1", required = true)
+ private String id;
+
+ @Schema(description = "Identifier of the offer associated with the catalog item", example = "offer123", required = true)
+ private String offerId;
+
+}
diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/NegotiationResponseDTO.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/NegotiationResponseDTO.java
new file mode 100644
index 0000000..262cb7e
--- /dev/null
+++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/edc/NegotiationResponseDTO.java
@@ -0,0 +1,53 @@
+/********************************************************************************
+ * Copyright (c) 2022,2024 BMW Group AG
+ * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * 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.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ ********************************************************************************/
+package org.eclipse.tractusx.valueaddedservice.dto.edc;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+
+@Setter
+@Getter
+@ToString
+@AllArgsConstructor
+@NoArgsConstructor
+@Schema(description = "Data Transfer Object with negotiation status")
+public class NegotiationResponseDTO {
+
+ @Schema(description = "Unique identifier of the catalog item", example = "1", required = true)
+ private String id;
+
+ @Schema(description = "Identifier of the offer associated with the catalog item", example = "offer123", required = true)
+ private String offerId;
+
+ @Schema(description = "Provider of the catalog item", example = "Provider A")
+ private String provider;
+
+ @Schema(description = "Status of negotiation of the catalog item", example = "Negotiated")
+ private String status;
+
+ @JsonIgnore
+ @Schema(description = "Auth Code for requesting the endpoint", example = "utasdbvhsarpoausighasd")
+ private String authCode;
+
+ @JsonIgnore
+ @Schema(description = "Endpoint for the Final Request", example = "http://localhost:80/finalRequest")
+ private String endpoint;
+}
diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/service/CacheEvictService.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/service/CacheEvictService.java
index 20cab96..fba5e65 100644
--- a/src/main/java/org/eclipse/tractusx/valueaddedservice/service/CacheEvictService.java
+++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/service/CacheEvictService.java
@@ -47,6 +47,9 @@ public class CacheEvictService {
@Autowired
ReportLogicService reportLogicService;
+ @Autowired
+ NegotiationServiceLogic negotiationServiceLogic;
+
@Scheduled(fixedRate = ONE_HOUR)
public void clearCacheCountry() {
countryLogicService.invalidateAllCache();
@@ -76,4 +79,10 @@ public void clearCacheReports() {
reportLogicService.invalidateAllCache();
log.info("Cache for Reports cleared.");
}
+
+ @Scheduled(fixedRate = ONE_MINUTE*1)
+ public void clearCacheNegotiation() {
+ negotiationServiceLogic.invalidateAllCache();
+ log.info("Cache for Negotiation cleared.");
+ }
}
diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/EDCLogicService.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/EDCLogicService.java
deleted file mode 100644
index c6a94a5..0000000
--- a/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/EDCLogicService.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2022,2024 BMW Group AG
- * Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * 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.
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- ********************************************************************************/
-package org.eclipse.tractusx.valueaddedservice.service.logic;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.eclipse.tractusx.valueaddedservice.dto.edc.EDRResponse;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Service;
-import reactor.core.publisher.Mono;
-
-import java.io.IOException;
-import java.time.Duration;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Function;
-
-@Service
-@Slf4j
-public class EDCLogicService {
-
- @Autowired
- private InvokeService invokeService;
-
- @Value("${application.bpdm.consumerManagementUrl}")
- private String consumerManagementUrl;
-
- @Value("${application.bpdm.gateProviderProtocolUrl}")
- private String gateProviderProtocolUrl;
-
- @Value("${application.bpdm.gateProviderId}")
- private String gateProviderId;
-
- @Value("${application.bpdm.policyBpn}")
- private String policyBpn;
-
- @Value("${application.bpdm.apiKey}")
- private String apiKey;
-
- @Autowired
- ObjectMapper objectMapper;
-
- public Mono executeSequentialRequests(String assetId,Object body) {
- Map response = queryCatalog();
- String offerId = response.get("ASSET_" + assetId);
-
- if (offerId == null) {
- log.error("Offer ID is missing");
- return Mono.error(new RuntimeException("Asset ID or Offer ID is missing"));
- }
-
- return retrieveEDRsData(assetId)
- .flatMap(lastNegotiatedTransferProcessId -> {
- if (lastNegotiatedTransferProcessId.isEmpty()) {
- log.info("No negotiated transfer process ID found");
- log.info("Initiating Negotiation");
- return sendNegotiationInitiateRequest(offerId, assetId)
- .then(Mono.delay(Duration.ofSeconds(3))) // Non-blocking delay
- .then(retrieveEDRsData(assetId))
- .flatMap(this::getEDRById)
- .flatMap(responseFromEDRById -> sendFinalRequest(responseFromEDRById, body));
- } else {
- log.debug("Found negotiated transfer process ID");
- return getEDRById(lastNegotiatedTransferProcessId)
- .flatMap(responseFromEDRById -> sendFinalRequest(responseFromEDRById, body));
- }
- });
- }
-
- public Mono getEDRById(String transferProcessId) {
- return executeGetRequest(consumerManagementUrl + "/edrs/" + transferProcessId, this::parseEDRResponse);
- }
-
- public Mono sendFinalRequest(EDRResponse edrResponse, Object body) {
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- headers.set("Authorization", edrResponse.getAuthCode());
- return executePostRequest(edrResponse.getEndpoint(), body, headers, response -> response);
- }
-
-
- public Mono retrieveEDRsData(String assetId) {
- return executeGetRequest(consumerManagementUrl + "/edrs?assetId=" + assetId, this::extractLastNegotiatedTransferProcessId);
- }
-
- public Map queryCatalog() {
- HttpHeaders headers = createHttpHeaders();
- Map requestBody = createCatalogRequestBody();
- HttpEntity