Skip to content

Commit

Permalink
Merge pull request #453 from catenax-ng/feature/420-add-contractagree…
Browse files Browse the repository at this point in the history
…ments

Feature/420 add contractagreements
  • Loading branch information
ds-jhartmann authored Feb 28, 2024
2 parents d702c1f + f146aa9 commit 2325052
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,29 @@
import org.eclipse.tractusx.irs.edc.client.EdcConfiguration;
import org.eclipse.tractusx.irs.edc.client.contract.model.EdcContractAgreementsResponse;
import org.eclipse.tractusx.irs.edc.client.contract.model.exception.ContractAgreementException;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
* EdcContractAgreementService used for contract agreements and contract agreement negotiation details
*/
@Slf4j
@RequiredArgsConstructor
@Service("irsEdcClientEdcContractAgreementService")
public class EdcContractAgreementService {

public static final String EDC_REQUEST_SUFFIX = "/request";
public static final String EDC_ASSET_ID = "https://w3id.org/edc/v0.0.1/ns/assetId";
private final EdcConfiguration config;
private final RestTemplate restTemplate;
private final @Qualifier("edcClientRestTemplate") RestTemplate edcRestTemplate;

public List<ContractAgreement> getContractAgreements(final String... contractAgreementIds)
throws ContractAgreementException {

final QuerySpec querySpec = buildQuerySpec(contractAgreementIds);
final ResponseEntity<EdcContractAgreementsResponse> edcContractAgreementListResponseEntity = restTemplate.postForEntity(
final ResponseEntity<EdcContractAgreementsResponse> edcContractAgreementListResponseEntity = edcRestTemplate.postForEntity(
config.getControlplane().getEndpoint().getContractAgreements() + EDC_REQUEST_SUFFIX, querySpec,
EdcContractAgreementsResponse.class);

Expand All @@ -65,7 +68,7 @@ public List<ContractAgreement> getContractAgreements(final String... contractAgr
}

public ContractNegotiation getContractAgreementNegotiation(final String contractAgreementId) {
final ResponseEntity<ContractNegotiation> contractNegotiationResponseEntity = restTemplate.getForEntity(
final ResponseEntity<ContractNegotiation> contractNegotiationResponseEntity = edcRestTemplate.getForEntity(
config.getControlplane().getEndpoint().getContractAgreements() + "/" + contractAgreementId
+ "/negotiation", ContractNegotiation.class);
return contractNegotiationResponseEntity.getBody();
Expand Down

0 comments on commit 2325052

Please sign in to comment.