Skip to content

Commit

Permalink
Merge pull request eclipse-tractusx#93 from FraunhoferISST/refactor/m…
Browse files Browse the repository at this point in the history
…igrate_to_edc_0.5.x

Refactor/migrate to edc 0.5.x
  • Loading branch information
tom-rm-meyer-ISST authored Dec 3, 2023
2 parents fbcc6b7 + 85ab47e commit fa4b736
Show file tree
Hide file tree
Showing 51 changed files with 3,934 additions and 1,549 deletions.
2 changes: 1 addition & 1 deletion DEPENDENCIES_BACKEND
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.13, Apache-2.0
maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-el/10.1.13, Apache-2.0, approved, #6997
maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-websocket/10.1.13, Apache-2.0, approved, #7920
maven/mavencentral/org.apiguardian/apiguardian-api/1.1.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.aspectj/aspectjweaver/1.9.20, EPL-1.0, approved, tools.aspectj
maven/mavencentral/org.aspectj/aspectjweaver/1.9.20, Apache-2.0 AND BSD-3-Clause AND EPL-1.0 AND BSD-3-Clause AND Apache-1.1, approved, #7695
maven/mavencentral/org.assertj/assertj-core/3.24.2, Apache-2.0, approved, #6161
maven/mavencentral/org.eclipse.angus/angus-activation/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.angus
maven/mavencentral/org.glassfish.jaxb/jaxb-core/4.0.3, BSD-3-Clause, approved, ee4j.jaxb
Expand Down
6 changes: 6 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ This project leverages the following third party content.
See `DEPENDENCIES_FRONTEND` and `DEPENDENCIES_BACKEND` file. Further, the following third-party content is used that
isn't listed in any DEPENDENCIES file:

Keycloak initial realm setup
* SPDX-License-Identifier: Apache-2.0
* SPDX-FileCopyrightText: https://github.com/eclipse-tractusx/managed-identity-wallet/blob/main/LICENSE
* Source URL: https://github.com/eclipse-tractusx/managed-identity-wallet


feather (4.29)
* License: MIT License
* Licence Path: https://github.com/feathericons/feather/blob/master/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion backend/DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.13, Apache-2.0
maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-el/10.1.13, Apache-2.0, approved, #6997
maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-websocket/10.1.13, Apache-2.0, approved, #7920
maven/mavencentral/org.apiguardian/apiguardian-api/1.1.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.aspectj/aspectjweaver/1.9.20, EPL-1.0, approved, tools.aspectj
maven/mavencentral/org.aspectj/aspectjweaver/1.9.20, Apache-2.0 AND BSD-3-Clause AND EPL-1.0 AND BSD-3-Clause AND Apache-1.1, approved, #7695
maven/mavencentral/org.assertj/assertj-core/3.24.2, Apache-2.0, approved, #6161
maven/mavencentral/org.eclipse.angus/angus-activation/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.angus
maven/mavencentral/org.glassfish.jaxb/jaxb-core/4.0.3, BSD-3-Clause, approved, ee4j.jaxb
Expand Down
46 changes: 22 additions & 24 deletions backend/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,26 @@ The first steps are always the same:

Depending on your needs of deployment, follow the following steps

### Running using mvn (local develpment)
3. Change the `src/main/resources/application.properties` or the respective environment
### Running using mvn (local development) and infrastructure services in kubernetes
1. Change the `src/main/resources/application.properties` or the respective environment
variables to configure the port, the URL of the EDC control plane, backend application etc.
4. Run the application:
```shell
# build and run the generated .jar file
mvn install
2. Run the application:
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.config.location="./src/main/resources/application.properties"

3. It is highly suggested to install, configure and run the PURIS frontend afterward

# run for demo or development puroposes
# customer role
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.config.location="./src/main/resources/application-customer.properties"
### Running using docker (deployment)

# supplier role
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.config.location="./src/main/resources/application-supplier.properties"
1. First build a docker image:
```
5. Done! The Swagger UI should be available at
- (Java & Docker) `http://YOURIP:8081/catena/swagger-ui/index.html`
- (Kubernetes) `http://CLUSTERIP:30001/catena/swagger-ui/index.html`
6. It is highly suggested to install and run the PURIS frontend afterward
cd backend
### Running using docker (deployment)
3. Optional (one can set properties via environment variables to docker): Change the `src/main/resources/application.properties` or the respective environment
docker build -t puris-backend:dev .
```

2. Optionally (one can set properties via environment variables to docker): Change the `src/main/resources/application.properties` or the respective environment
variables to configure the port, the URL of the EDC control plane, backend application etc.
4. Run the application:
3. Run the application:
```shell
cd backend

Expand All @@ -39,21 +35,23 @@ docker build -t puris-backend:dev .
docker run -d --rm -p 8081:8081 --name backend -e server.port=8082 puris-backend:dev CONTAINERID

# B use docker-compose
cd ..
cd local
docker-compose up
```
5. Done! The Swagger UI should be available at
4. Done! The Swagger UI should be available at
- (Java & Docker) `http://YOURIP:8081/catena/swagger-ui/index.html`
- (Kubernetes) `http://CLUSTERIP:30001/catena/swagger-ui/index.html`
6. It is highly suggested to install and run the PURIS frontend afterward
5. It is highly suggested to install and run the PURIS frontend afterward (unless you're using local/docker-compose.yaml)

### Running using helm (deployment)
3. Run the application:
1. Run the application:

```shell
cd charts/puris/charts/backend

helm install backend --namespace puris --create-namespace . --set ingress.enabled=true
```
4. Done! The Swagger UI should be available at
2. Done! The Swagger UI should be available at
- (Java & Docker) `http://YOURIP:8081/catena/swagger-ui/index.html`
- (Kubernetes) `http://CLUSTERIP:30001/catena/swagger-ui/index.html`
5. It is highly suggested to install and run the PURIS frontend afterward
3. It is highly suggested to install and run the PURIS frontend afterward
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
*/
package org.eclipse.tractusx.puris.backend;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.CreateAssetDto;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.datatype.DT_ApiMethodEnum;
import org.eclipse.tractusx.puris.backend.common.edc.logic.service.EdcAdapterService;
import org.eclipse.tractusx.puris.backend.common.edc.logic.util.EDCRequestBodyBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

Expand All @@ -39,49 +34,14 @@ public class AssetCreatorCommandLineRunner implements CommandLineRunner {
@Autowired
private EdcAdapterService edcAdapterService;

@Value("${request.serverendpoint}")
private String requestApiBaseUrl;

@Value("${response.serverendpoint}")
private String responseApiBaseUrl;

private ObjectMapper objectMapper;

@Autowired
private EDCRequestBodyBuilder edcRequestBodyBuilder;

public AssetCreatorCommandLineRunner(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

@Override
public void run(String... args) throws Exception {

registerResponseAndRequestApiAsset();

}

private void registerResponseAndRequestApiAsset() {

// Create Request Api Asset
CreateAssetDto createRequestApiAssetDto =
edcRequestBodyBuilder.buildCreateAssetDtoForApi(DT_ApiMethodEnum.REQUEST,
requestApiBaseUrl);

CreateAssetDto createResponseApiAssetDto =
edcRequestBodyBuilder.buildCreateAssetDtoForApi(DT_ApiMethodEnum.RESPONSE,
responseApiBaseUrl);

try {
edcAdapterService.publishAssetAtEDC(createResponseApiAssetDto);
edcAdapterService.publishAssetAtEDC(createRequestApiAssetDto);
log.info("Published sample RequestAndResponseAssetData");
} catch (Exception e) {
log.error("FAILED TO REGISTER REQUEST/RESPONSE ASSETS");
log.error(e.getMessage());
if (!edcAdapterService.doInitialAssetRegistration()) {
// retry
int retryDelaySeconds = 3;
log.warn("retrying initial asset registration in " + retryDelaySeconds + " seconds");
Thread.sleep(retryDelaySeconds * 1000);
log.warn("retry successful: " + edcAdapterService.doInitialAssetRegistration());
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockRequestService;
import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -83,10 +82,6 @@ public class DataInjectionCommandLineRunner implements CommandLineRunner {
@Autowired
private VariablesService variablesService;


@Value("${puris.demonstrator.role}")
private String demoRole;

private ObjectMapper objectMapper;

private final String semiconductorMatNbrCustomer = "MNR-7307-AU340474.002";
Expand All @@ -99,11 +94,11 @@ public DataInjectionCommandLineRunner(ObjectMapper objectMapper) {

@Override
public void run(String... args) throws Exception {
//createOwnPartnerEntity();
log.info("Creating setup for " + demoRole.toUpperCase());
if (demoRole.equals("supplier")) {
createOwnPartnerEntity();
log.info("Creating setup for " + variablesService.getDemoRole().toUpperCase());
if (variablesService.getDemoRole().equals("supplier")) {
setupSupplierRole();
} else if (demoRole.equals(("customer"))) {
} else if (variablesService.getDemoRole().equals(("customer"))) {
setupCustomerRole();
createRequest();
} else {
Expand All @@ -120,7 +115,7 @@ private void createOwnPartnerEntity() {
Partner mySelf;
if(variablesService.getOwnDefaultBpns()!= null && variablesService.getOwnDefaultBpns().length()!=0) {
mySelf = new Partner(variablesService.getOwnName(),
variablesService.getOwnEdcIdsUrl(),
variablesService.getEdcProtocolUrl(),
variablesService.getOwnBpnl(),
variablesService.getOwnDefaultBpns(),
variablesService.getOwnDefaultSiteName(),
Expand All @@ -130,7 +125,7 @@ private void createOwnPartnerEntity() {
variablesService.getOwnDefaultCountry());
} else {
mySelf = new Partner(variablesService.getOwnName(),
variablesService.getOwnEdcIdsUrl(),
variablesService.getEdcProtocolUrl(),
variablesService.getOwnBpnl(),
variablesService.getOwnDefaultBpna(),
variablesService.getOwnDefaultStreetAndNumber(),
Expand Down Expand Up @@ -281,9 +276,9 @@ private void setupSupplierRole() {
private Partner createAndGetCustomerPartner() {
Partner customerPartnerEntity = new Partner(
"Scenario Customer",
"http://customer-control-plane:8184/api/v1/ids",
"http://customer-control-plane:8184/api/v1/dsp",
"BPNL4444444444XX",
"BPNS4444444444XY",
"BPNS4444444444XX",
"Hauptwerk Musterhausen",
"BPNA4444444444ZZ",
"Musterstraße 35b",
Expand All @@ -306,9 +301,9 @@ private Partner createAndGetCustomerPartner() {
private Partner createAndGetSupplierPartner() {
Partner supplierPartnerEntity = new Partner(
"Scenario Supplier",
"http://supplier-control-plane:9184/api/v1/ids",
"http://supplier-control-plane:9184/api/v1/dsp",
"BPNL1234567890ZZ",
"BPNS1234567890XY",
"BPNS1234567890ZZ",
"Konzernzentrale Dudelsdorf",
"BPNA1234567890AA",
"Heinrich-Supplier-Straße 1",
Expand All @@ -331,7 +326,7 @@ private Partner createAndGetSupplierPartner() {
private Partner createAndGetNonScenarioCustomer() {
Partner nonScenarioCustomer = new Partner(
"Non-Scenario Customer",
"http://nonscenario-customer.com/api/v1/ids",
"http://nonscenario-customer.com/api/v1/dsp",
"BPNL2222222222RR",
"BPNA2222222222XZ",
"Fichtenweg 23",
Expand Down Expand Up @@ -383,8 +378,7 @@ 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://supplier-control-plane:9184/api/v1/ids");
messageHeader.setSenderEdc("http://supplier-controlplane:8084/api/v1/dsp");
messageHeader.setReceiver("BPNL4444444444XX");
messageHeader.setUseCase(DT_UseCaseEnum.PURIS);
messageHeader.setCreationDate(new Date());
Expand Down
Loading

0 comments on commit fa4b736

Please sign in to comment.