Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #131 from eclipse-tractusx/feay/add-new-endpoints-…
Browse files Browse the repository at this point in the history
…for-negotiation

Enhance sequential negotiation process with error hand…
  • Loading branch information
fabiodmota authored May 8, 2024
2 parents 9a4a778 + 463178f commit 17b6865
Show file tree
Hide file tree
Showing 17 changed files with 890 additions and 307 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</parent>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>value-added-service</artifactId>
<version>1.3.2</version>
<version>2.0.0</version>
<name>vas-country-risk-backend</name>
<description>Project to Validate Country Risks Score</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> providers;


}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@Setter
@Getter
@ToString
public class EDRResponse {
public class EDRResponseDTO {

private String authCode;
private String endpoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class CacheEvictService {
@Autowired
ReportLogicService reportLogicService;

@Autowired
NegotiationServiceLogic negotiationServiceLogic;

@Scheduled(fixedRate = ONE_HOUR)
public void clearCacheCountry() {
countryLogicService.invalidateAllCache();
Expand Down Expand Up @@ -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.");
}
}
Loading

0 comments on commit 17b6865

Please sign in to comment.