Skip to content

Commit

Permalink
feat(policy-api): [eclipse-tractusx#803] fix missing import
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmf committed Jul 15, 2024
1 parent 74b99ef commit 5febbe8
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.time.OffsetDateTime;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -82,7 +83,6 @@ public class PolicyStoreService implements AcceptedPoliciesProvider {

private static final String DEFAULT = "default";


/**
* Constants for the configured default policy.
*/
Expand Down Expand Up @@ -141,20 +141,17 @@ public Policy registerPolicy(final CreatePolicyRequest request) {

/**
* Find a policy by policy ID.
*
* @param policyId the policy ID
* @return Returns the policy including a list of associated business partner numbers.
*/
public Optional<GetPolicyByIdResponse> getPolicyById(final String policyId) {
final Map<String, List<Policy>> policies = getPolicies(null);
return policies.values()
.stream()
.flatMap(Collection::stream)
.filter(p -> p.getPolicyId().equals(policyId))
return policies.values().stream().flatMap(Collection::stream).filter(p -> p.getPolicyId().equals(policyId))
// In MinIO we store the policy per BPN.
// Therefore, we can simply take the first one and collect the keys to get all the
// business partner numbers to which the policy is assigned.
.findFirst()
.map(p -> GetPolicyByIdResponse.from(p, policies.keySet().stream().toList()));
.findFirst().map(p -> GetPolicyByIdResponse.from(p, policies.keySet().stream().toList()));
}

/**
Expand Down

0 comments on commit 5febbe8

Please sign in to comment.