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

Ci: docker compose for local test scenario #24

Merged
merged 16 commits into from
Nov 3, 2023
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
3 changes: 3 additions & 0 deletions .tractusx
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ repositories:
- name: "puris"
usage: "PURIS Frontend and Backend Implementation"
url: "https://github.com/eclipse-tractusx/puris"
skipReleaseChecks:
alignedBaseImage:
- "local/vault/Dockerfile"
2 changes: 1 addition & 1 deletion DEPENDENCIES_BACKEND
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ maven/mavencentral/org.springdoc/springdoc-openapi-starter-common/2.1.0, Apache-
maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-api/2.1.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.1.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.springframework.boot/spring-boot-autoconfigure/3.1.4, Apache-2.0, approved, #9341
maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.1.4, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.1.4, Apache-2.0, approved, #11406
maven/mavencentral/org.springframework.boot/spring-boot-starter-aop/3.1.4, Apache-2.0, approved, #9338
maven/mavencentral/org.springframework.boot/spring-boot-starter-data-jpa/3.1.4, Apache-2.0, approved, #9733
maven/mavencentral/org.springframework.boot/spring-boot-starter-jdbc/3.1.4, Apache-2.0, approved, #9737
Expand Down
2 changes: 1 addition & 1 deletion backend/DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ maven/mavencentral/org.springdoc/springdoc-openapi-starter-common/2.1.0, Apache-
maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-api/2.1.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.1.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.springframework.boot/spring-boot-autoconfigure/3.1.4, Apache-2.0, approved, #9341
maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.1.4, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.1.4, Apache-2.0, approved, #11406
maven/mavencentral/org.springframework.boot/spring-boot-starter-aop/3.1.4, Apache-2.0, approved, #9338
maven/mavencentral/org.springframework.boot/spring-boot-starter-data-jpa/3.1.4, Apache-2.0, approved, #9733
maven/mavencentral/org.springframework.boot/spring-boot-starter-jdbc/3.1.4, Apache-2.0, approved, #9737
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public DataInjectionCommandLineRunner(ObjectMapper objectMapper) {

@Override
public void run(String... args) throws Exception {
createOwnPartnerEntity();
//createOwnPartnerEntity();
log.info("Creating setup for " + demoRole.toUpperCase());
if (demoRole.equals("supplier")) {
setupSupplierRole();
Expand Down Expand Up @@ -281,7 +281,7 @@ private void setupSupplierRole() {
private Partner createAndGetCustomerPartner() {
Partner customerPartnerEntity = new Partner(
"Scenario Customer",
"http://sokrates-controlplane:8084/api/v1/ids",
"http://customer-control-plane:8184/api/v1/ids",
"BPNL4444444444XX",
"BPNS4444444444XY",
"Hauptwerk Musterhausen",
Expand All @@ -306,7 +306,7 @@ private Partner createAndGetCustomerPartner() {
private Partner createAndGetSupplierPartner() {
Partner supplierPartnerEntity = new Partner(
"Scenario Supplier",
"http://plato-controlplane:8084/api/v1/ids",
"http://supplier-control-plane:9184/api/v1/ids",
"BPNL1234567890ZZ",
"BPNS1234567890XY",
"Konzernzentrale Dudelsdorf",
Expand Down Expand Up @@ -383,7 +383,8 @@ private void createRequest() throws JsonProcessingException {
messageHeader.setRespondAssetId("product-stock-response-api");
messageHeader.setContractAgreementId("some cid");
messageHeader.setSender("BPNL1234567890ZZ");
messageHeader.setSenderEdc("http://plato-controlplane:8084/api/v1/ids");
//messageHeader.setSenderEdc("http://plato-controlplane:8084/api/v1/ids");
messageHeader.setSenderEdc("http://supplier-control-plane:9184/api/v1/ids");
messageHeader.setReceiver("BPNL4444444444XX");
messageHeader.setUseCase(DT_UseCaseEnum.PURIS);
messageHeader.setCreationDate(new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
*/
package org.eclipse.tractusx.puris.backend.common.api.logic.service;

import lombok.Getter;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.datatype.DT_ApiMethodEnum;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import lombok.Getter;


@Getter
@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -36,8 +35,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
* This class contains the endpoint for receiving the authCodes from
* the counterparty's dataplane.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,17 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.squareup.okhttp.*;
import lombok.extern.slf4j.Slf4j;

import org.eclipse.tractusx.puris.backend.common.api.logic.service.VariablesService;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.CreateAssetDto;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.EDR_Dto;
import org.eclipse.tractusx.puris.backend.common.edc.logic.util.EDCRequestBodyBuilder;
import org.eclipse.tractusx.puris.backend.model.repo.OrderRepository;
import org.springframework.aot.hint.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;


import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.*;

/**
* Service Layer of EDC Adapter. Builds and sends requests to a productEDC.
Expand All @@ -65,6 +58,12 @@ public class EdcAdapterService {
@Value("${edc.controlplane.data.port}")
private Integer dataPort;

/**
* Path to data management api
*/
@Value("${edc.controlplane.data.path}")
private String dataPath;

@Value("${edc.controlplane.key}")
private String edcApiKey;

Expand Down Expand Up @@ -101,13 +100,13 @@ public boolean publishOrderAtEDC(String orderId) throws IOException {
var policyBody = edcRequestBodyBuilder.buildPolicyRequestBody(orderId);
var contractBody = edcRequestBodyBuilder.buildContractRequestBody(orderId);

var response = sendEdcRequest(assetBody, "/data/assets");
var response = sendEdcRequest(assetBody, "/assets");
var success = response.isSuccessful();
response.body().close();
response = sendEdcRequest(policyBody, "/data/policydefinitions");
response = sendEdcRequest(policyBody, "/policydefinitions");
success &= response.isSuccessful();
response.body().close();
response = sendEdcRequest(contractBody, "/data/contractdefinitions");
response = sendEdcRequest(contractBody, "/contractdefinitions");
success &= response.isSuccessful();
response.body().close();
return success;
Expand All @@ -134,15 +133,15 @@ public boolean publishAssetAtEDC(CreateAssetDto createAssetDto) throws IOExcepti
JsonNode contractBody = edcRequestBodyBuilder.buildContractRequestBody(assetId);
log.info(String.format("Contract Body: \n%s", contractBody.toPrettyString()));
log.info(String.format("Asset Body: \n%s", assetBody.toPrettyString()));
var response = sendEdcRequest(assetBody, "/data/assets");
var response = sendEdcRequest(assetBody, "/assets");
success &= response.isSuccessful();
log.info(String.format("Creation of asset was successfull: %b", success));
response.body().close();
response = sendEdcRequest(policyBody, "/data/policydefinitions");
response = sendEdcRequest(policyBody, "/policydefinitions");
log.info(String.format("Creation of policy was successfull: %b", response.isSuccessful()));
success &= response.isSuccessful();
response.body().close();
response = sendEdcRequest(contractBody, "/data/contractdefinitions");
response = sendEdcRequest(contractBody, "/contractdefinitions");
success &= response.isSuccessful();
log.info(String.format("Created Contract Definition (%b) for Asset %s", response.isSuccessful(),
objectMapper.writeValueAsString(createAssetDto)));
Expand Down Expand Up @@ -176,6 +175,8 @@ public String getCatalog(String idsUrl, Optional<Map<String, String>> filterProp
urlBuilder.scheme("http")
.host(edcHost)
.port(dataPort)
.addPathSegment("api")
.addPathSegment("v1")
.addPathSegment("data")
.addPathSegment("catalog")
.addEncodedQueryParameter("providerUrl", idsUrl + "/data");
Expand Down Expand Up @@ -243,7 +244,7 @@ public JsonNode getCatalogFilteredByAssetPropertyObjectFilter(String idsUrl, Map
/**
* Orders your own EDC Connector Controlplane to negotiate a contract with
* the owner of the given connector address for an asset (specified by the
* assetId) under conditions as stated in the contract definition with the
* assetId) under conditions as stated in the contract defintion with the
* given contractDefinitionId
* @param connectorAddress
* @param contractDefinitionId
Expand All @@ -256,7 +257,7 @@ public String startNegotiation(String connectorAddress,
var negotiationRequestBody =
edcRequestBodyBuilder.buildNegotiationRequestBody(connectorAddress,
contractDefinitionId, assetId);
var response = sendEdcRequest(negotiationRequestBody, "/data/contractnegotiations");
var response = sendEdcRequest(negotiationRequestBody, "/contractnegotiations");
String stringData = response.body().string();
response.body().close();
return stringData;
Expand All @@ -271,7 +272,7 @@ public String startNegotiation(String connectorAddress,
* @throws IOException
*/
public String getNegotiationState(String negotiationId) throws IOException {
var response = sendEdcRequest("/data/contractnegotiations/" + negotiationId);
var response = sendEdcRequest("/contractnegotiations/" + negotiationId);
String stringData = response.body().string();
response.body().close();
return stringData;
Expand All @@ -293,7 +294,7 @@ public String startTransfer(String transferId,
String orderId) throws IOException {
var transferNode = edcRequestBodyBuilder.buildTransferRequestBody(transferId, connectorAddress, contractId, orderId);
log.debug("TransferRequestBody:\n" + transferNode.toPrettyString());
var response = sendEdcRequest(transferNode, "/data/transferprocess");
var response = sendEdcRequest(transferNode, "/transferprocess");
String stringData = response.body().string();
response.body().close();
return stringData;
Expand All @@ -303,12 +304,12 @@ public String startTransfer(String transferId,
* Sends a request to the own EDC Connector Controlplane in order to receive
* the current status of the previously initiated transfer as specified by
* the parameter.
* @param transferId the id of the transfer in question
* @return the response from your Controlplane
* @param transferId
* @return
* @throws IOException
*/
public String getTransferState(String transferId) throws IOException {
var response = sendEdcRequest("/data/transferprocess/" + transferId);
var response = sendEdcRequest("/transferprocess/" + transferId);
String stringData = response.body().string();
response.body().close();
return stringData;
Expand Down Expand Up @@ -390,9 +391,9 @@ public Response sendEdcRequest(JsonNode requestBody, String urlSuffix) throws IO
.header("X-Api-Key", edcApiKey)
.header("Content-Type", "application/json")
.post(RequestBody.create(MediaType.parse("application/json"), requestBody.toString()))
.url("http://" + edcHost + ":" + dataPort + urlSuffix)
.url("http://" + edcHost + ":" + dataPort + dataPath + urlSuffix)
.build();

log.debug(String.format("Request send to url: %s", request.urlString()));
log.debug(String.format("Request body of EDC Request: %s", requestBody));
return CLIENT.newCall(request).execute();
}
Expand All @@ -410,7 +411,7 @@ public Response sendEdcRequest(String urlSuffix) throws IOException {
Request request = new Request.Builder()
.header("X-Api-Key", edcApiKey)
.header("Content-Type", "application/json")
.url("http://" + edcHost + ":" + dataPort + urlSuffix)
.url("http://" + edcHost + ":" + dataPort + dataPath + urlSuffix)
.build();
log.debug(String.format("Send Request to url: %s", request.urlString()));

Expand All @@ -430,6 +431,7 @@ public Response sendEdcRequest(String urlSuffix) throws IOException {
* @return the response from your dataplane
*/
public Response sendDataPullRequest(String url, String authKey, String authCode, String requestBodyString){
log.debug(String.format("Sending proxy call to endpoint '%s' with auth key '%s' and auth code '%s' with request body '%s'", url, authKey, authCode, requestBodyString));
try {
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), requestBodyString);
Request request = new Request.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
*/
package org.eclipse.tractusx.puris.backend.common.edc.logic.service;

import java.util.HashMap;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.EDR_Dto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
/**
* This class stores authCodes which are generated in the course of
* the contracting for the request or response api. Since authCodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
package org.eclipse.tractusx.puris.backend.masterdata.logic.dto;

import lombok.*;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.StockDto;

import java.io.Serializable;
import java.util.*;
import java.util.UUID;

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
*/
package org.eclipse.tractusx.puris.backend.stock.controller;

import java.util.UUID;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockRequest;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.datatype.DT_RequestStateEnum;
import org.eclipse.tractusx.puris.backend.common.api.logic.dto.SuccessfulRequestDto;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockResponse;
import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockRequestService;
import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockResponseApiServiceImpl;
Expand All @@ -44,9 +44,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.extern.slf4j.Slf4j;
import java.util.UUID;

/**
* This class contains the REST controller of the product-stock-response api.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@
*/
package org.eclipse.tractusx.puris.backend.stock.domain.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import jakarta.persistence.Embedded;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.MessageContent;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.MessageHeader;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.ProductStockSammDto;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
* This Response represents the message received via a Response API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import jakarta.validation.constraints.NotNull;
import lombok.ToString;

import javax.xml.datatype.XMLGregorianCalendar;
import java.util.Collection;
import java.util.Date;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.eclipse.tractusx.puris.backend.common.api.logic.dto.MessageContentDto;

import java.util.Collection;
import java.util.Objects;
import java.util.Optional;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.eclipse.tractusx.puris.backend.stock.domain.model.PartnerProductStock;
import org.eclipse.tractusx.puris.backend.stock.domain.model.measurement.MeasurementUnit;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.LocationIdTypeEnum;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;
Expand Down
5 changes: 3 additions & 2 deletions backend/src/main/resources/application-customer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ spring.jpa.hibernate.ddl-auto=create
server.servlet.context-path=${API_ROOTDIR:/catena}
# EDC Config
edc.controlplane.host=${EDC_CONTROLPLANE_HOST:192.168.49.2}
edc.controlplane.data.port=${EDC_CONTROLPLANE_DATA_PORT:30216}
edc.controlplane.data.path=/api/v1/data
edc.controlplane.data.port=${EDC_CONTROLPLANE_DATA_PORT:31944}
edc.controlplane.key=${EDC_CONTROLPLANE_KEY:password}

edc.applydataplaneworkaround=true
Expand All @@ -30,7 +31,7 @@ spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true


# Own EDC-IDS-URL
edc.idsUrl=${EDC_IDSURL:http://sokrates-controlplane:8084/api/v1/ids}
edc.idsUrl=${EDC_IDSURL:http://customer-control-plane:8184/api/v1/ids}

# Own BPNL
own.bpnl=${OWN_BPNL:BPNL4444444444XX}
Expand Down
Loading
Loading