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

bug: eclipse-tractusx/traceability-foss#639 update policy expired err… #774

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ private CompletableFuture<NegotiationResponse> startNewNegotiation(final String

if (policyCheckerService.isExpired(catalogItem.getPolicy(), bpn)) {
log.warn("Policy is expired, canceling negotiation.");
throw new UsagePolicyExpiredException(catalogItem.getPolicy(),
throw new UsagePolicyExpiredException(policyCheckerService.getValidStoredPolicies(catalogItem.getConnectorId()),
catalogItem.getPolicy(),
catalogItem.getConnectorId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
********************************************************************************/
package org.eclipse.tractusx.irs.edc.client.exceptions;

import java.util.List;

import lombok.Getter;
import org.eclipse.edc.policy.model.Policy;
import org.eclipse.tractusx.irs.edc.client.policy.AcceptedPolicy;

/**
* Usage Policy Expired Exception errors in the contract negotiation.
Expand All @@ -31,9 +34,11 @@ public class UsagePolicyExpiredException extends EdcClientException {
private final transient Policy policy;
private final String businessPartnerNumber;

public UsagePolicyExpiredException(final Policy policy, final String businessPartnerNumber) {
super("Policy from " + businessPartnerNumber + " has expired.");
this.policy = policy;
public UsagePolicyExpiredException(final List<AcceptedPolicy> acceptedPolicies,
final Policy providedCatalogItemPolicy, final String businessPartnerNumber) {
super("Policy " + acceptedPolicies.stream().map(policy -> policy.policy().getPolicyId()).toList()
+ " has expired.");
this.policy = providedCatalogItemPolicy;
this.businessPartnerNumber = businessPartnerNumber;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class UsagePolicyPermissionException extends EdcClientException {

public UsagePolicyPermissionException(final List<AcceptedPolicy> acceptedPolicies,
final Policy providedCatalogItemPolicy, final String businessPartnerNumber) {
super("Policies "
+ acceptedPolicies.stream().map(policy -> policy.policy().getPolicyId()).toList()
super("Policies " + acceptedPolicies.stream().map(policy -> policy.policy().getPolicyId()).toList()
+ " did not match with policy from " + businessPartnerNumber + ".");

this.policy = providedCatalogItemPolicy;
Expand Down
Loading