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

Feature/420 add contractagreements #453

Merged
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 @@ -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
Loading