Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
eschrewe committed Jul 24, 2024
2 parents 585346e + 260c08e commit 148704a
Show file tree
Hide file tree
Showing 22 changed files with 319 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Beside the dependencies provided in the Helm Chart, the following dependencies h

| Application | App Version | Chart Version |
|-------------------------------------------------------------------------------------------------------------------|-------------|---------------|
| [Tractus-X Connector](https://github.com/eclipse-tractusx/tractusx-edc/tree/main/charts/tractusx-connector) | 0.7.2 | 0.7.2 |
| [Tractus-X Connector](https://github.com/eclipse-tractusx/tractusx-edc/tree/main/charts/tractusx-connector) | 0.7.3 | 0.7.3 |
| [Digital Twin Registry](https://github.com/eclipse-tractusx/sldt-digital-twin-registry/tree/main/charts/registry) | 0.5.0 | 0.5.0 |

## Known Knows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public boolean createPolicyAndContractDefForPartner(Partner partner) {

private boolean createSubmodelContractDefinitionForPartner(String semanticId, String assetId, Partner partner) {
var body = edcRequestBodyBuilder.buildSubmodelContractDefinitionWithBpnRestrictedPolicy(assetId, partner);
try (var response = sendPostRequest(body, List.of("v2", "contractdefinitions"))) {
try (var response = sendPostRequest(body, List.of("v3", "contractdefinitions"))) {
if (!response.isSuccessful()) {
log.warn("Contract definition registration failed for partner " + partner.getBpnl() + " and {} Submodel", semanticId);
if (response.body() != null) {
Expand All @@ -217,7 +217,7 @@ private boolean createSubmodelContractDefinitionForPartner(String semanticId, St

private boolean createDtrContractDefinitionForPartner(Partner partner) {
var body = edcRequestBodyBuilder.buildDtrContractDefinitionForPartner(partner);
try (var response = sendPostRequest(body, List.of("v2", "contractdefinitions"))) {
try (var response = sendPostRequest(body, List.of("v3", "contractdefinitions"))) {
if (!response.isSuccessful()) {
log.warn("Contract definition registration failed for partner " + partner.getBpnl() + " and DTR");
return false;
Expand All @@ -239,7 +239,7 @@ private boolean createDtrContractDefinitionForPartner(Partner partner) {
*/
private boolean createBpnlAndMembershipPolicyDefinitionForPartner(Partner partner) {
var body = edcRequestBodyBuilder.buildBpnAndMembershipRestrictedPolicy(partner);
try (var response = sendPostRequest(body, List.of("v2", "policydefinitions"))) {
try (var response = sendPostRequest(body, List.of("v3", "policydefinitions"))) {
if (!response.isSuccessful()) {
log.warn("Policy Registration failed");
if (response.body() != null) {
Expand All @@ -261,7 +261,7 @@ private boolean createBpnlAndMembershipPolicyDefinitionForPartner(Partner partne
*/
private boolean createContractPolicy() {
var body = edcRequestBodyBuilder.buildFrameworkPolicy();
try (var response = sendPostRequest(body, List.of("v2", "policydefinitions"))) {
try (var response = sendPostRequest(body, List.of("v3", "policydefinitions"))) {
if (!response.isSuccessful()) {
log.warn("Framework Policy Registration failed");
if (response.body() != null) {
Expand Down Expand Up @@ -323,7 +323,7 @@ private boolean sendAssetRegistrationRequest(JsonNode body, String assetId) {
* @return The response containing the full catalog, if successful
*/
public Response getCatalogResponse(String dspUrl, String partnerBpnl, Map<String, String> filter) throws IOException {
return sendPostRequest(edcRequestBodyBuilder.buildBasicCatalogRequestBody(dspUrl, partnerBpnl, filter), List.of("v2", "catalog", "request"));
return sendPostRequest(edcRequestBodyBuilder.buildBasicCatalogRequestBody(dspUrl, partnerBpnl, filter), List.of("v3", "catalog", "request"));
}

/**
Expand Down Expand Up @@ -374,7 +374,7 @@ private JsonNode initiateNegotiation(Partner partner, JsonNode catalogItem, Stri
// use dspUrl as provided, if set - else use partner
dspUrl = dspUrl != null && !dspUrl.isEmpty() ? dspUrl : partner.getEdcUrl();
var requestBody = edcRequestBodyBuilder.buildAssetNegotiationBody(partner, catalogItem, dspUrl);
try (Response response = sendPostRequest(requestBody, List.of("v2", "contractnegotiations"))) {
try (Response response = sendPostRequest(requestBody, List.of("v3", "contractnegotiations"))) {
JsonNode responseNode = objectMapper.readTree(response.body().string());
log.debug("Result from negotiation {}", responseNode.toPrettyString());
return responseNode;
Expand All @@ -391,7 +391,7 @@ private JsonNode initiateNegotiation(Partner partner, JsonNode catalogItem, Stri
* @throws IOException If the connection to your control plane fails
*/
public JsonNode getNegotiationState(String negotiationId) throws IOException {
try (var response = sendGetRequest(List.of("v2", "contractnegotiations", negotiationId))) {
try (var response = sendGetRequest(List.of("v3", "contractnegotiations", negotiationId))) {
String stringData = response.body().string();
return objectMapper.readTree(stringData);
}
Expand All @@ -406,7 +406,7 @@ public JsonNode getNegotiationState(String negotiationId) throws IOException {
*/
public Response getAllNegotiations() throws IOException {
var requestBody = edcRequestBodyBuilder.buildNegotiationsRequestBody();
return sendPostRequest(requestBody, List.of("v2", "contractnegotiations", "request"));
return sendPostRequest(requestBody, List.of("v3", "contractnegotiations", "request"));
}

/**
Expand All @@ -421,7 +421,7 @@ public Response getAllNegotiations() throws IOException {
*/
public JsonNode initiateProxyPullTransfer(Partner partner, String contractId, String assetId, String partnerEdcUrl) throws IOException {
var body = edcRequestBodyBuilder.buildProxyPullRequestBody(partner, contractId, assetId, partnerEdcUrl);
try (var response = sendPostRequest(body, List.of("v2", "transferprocesses"))) {
try (var response = sendPostRequest(body, List.of("v3", "transferprocesses"))) {
String data = response.body().string();
JsonNode result = objectMapper.readTree(data);
log.debug("Got response from Proxy pull transfer init: {}", result.toPrettyString());
Expand All @@ -443,7 +443,7 @@ public JsonNode initiateProxyPullTransfer(Partner partner, String contractId, St
* @throws IOException If the connection to your control plane fails
*/
public JsonNode getTransferState(String transferId) throws IOException {
try (var response = sendGetRequest(List.of("v2", "transferprocesses", transferId))) {
try (var response = sendGetRequest(List.of("v3", "transferprocesses", transferId))) {
String data = response.body().string();
return objectMapper.readTree(data);
}
Expand All @@ -459,7 +459,7 @@ public JsonNode getTransferState(String transferId) throws IOException {
public Response getAllTransfers() throws IOException {
var requestBody = edcRequestBodyBuilder.buildTransfersRequestBody();
log.debug("GetAllTransfers Request: {}", requestBody.toPrettyString());
return sendPostRequest(requestBody, List.of("v2", "transferprocesses", "request"));
return sendPostRequest(requestBody, List.of("v3", "transferprocesses", "request"));
}

/**
Expand All @@ -471,7 +471,7 @@ public Response getAllTransfers() throws IOException {
* @throws IOException If the connection to your control plane fails
*/
public String getContractAgreement(String contractAgreementId) throws IOException {
try (var response = sendGetRequest(List.of("v2", "contractagreements", contractAgreementId))) {
try (var response = sendGetRequest(List.of("v3", "contractagreements", contractAgreementId))) {
return response.body().string();
}
}
Expand Down Expand Up @@ -985,7 +985,7 @@ private void terminateTransfer(String transferProcessId) {

JsonNode body = edcRequestBodyBuilder.buildTransferProcessTerminationBody("Transfer done.");

try (Response response = sendPostRequest(body, List.of("v2", "transferprocesses", transferProcessId, "terminate"))) {
try (Response response = sendPostRequest(body, List.of("v3", "transferprocesses", transferProcessId, "terminate"))) {

JsonNode resultNode = objectMapper.readTree(response.body().string());
if (!response.isSuccessful()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
*/
package org.eclipse.tractusx.puris.backend.demandandcapacitynotification.controller;

import com.fasterxml.jackson.databind.JsonNode;
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.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -50,24 +53,26 @@ public class DemandAndCapacityNotificationRequestApiController {

@Operation(summary = "This endpoint receives the DemandAndCapacityNotification 2.0.0 requests")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error")
@ApiResponse(responseCode = "200", description = "Ok", content = @Content),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content)
})
@PostMapping("request")
public ResponseEntity<DemandAndCapacityNotificationSamm> postDemandAndCapacityNotification(
public ResponseEntity<?> postDemandAndCapacityNotification(
@RequestHeader("edc-bpn") String bpnl,
@RequestBody String body)
@io.swagger.v3.oas.annotations.parameters.RequestBody(content = {@Content(examples = {
@ExampleObject(sample)
})})
@RequestBody JsonNode body)
{
if (!bpnlPattern.matcher(bpnl).matches()) {
log.warn("Rejecting request at DemandAndCapacityNotification request 2.0.0 endpoint. Invalid BPNL");
return ResponseEntity.badRequest().build();
}
try {
var data = objectMapper.readTree(body);
log.info("Received POST request for DemandAndCapacityNotification 2.0.0 with BPNL: " + bpnl);
var notification = objectMapper.readValue(
data.get("content").get("demandAndCapacityNotification").toString(),
body.get("content").get("demandAndCapacityNotification").toString(),
DemandAndCapacityNotificationSamm.class);
demandAndCapacityNotificationRequestApiService.handleIncomingNotification(bpnl, notification);
} catch (Exception e) {
Expand All @@ -76,4 +81,44 @@ public ResponseEntity<DemandAndCapacityNotificationSamm> postDemandAndCapacityNo
}
return ResponseEntity.ok(null);
}

final static String sample = "{\n" +
" \"header\": {\n" +
" \"senderBpn\": \"BPNL7588787849VQ\",\n" +
" \"context\": \"CX-DemandAndCapacityNotification:2.0\",\n" +
" \"messageId\": \"3b4edc05-e214-47a1-b0c2-1d831cdd9ba9\",\n" +
" \"receiverBpn\": \"BPNL6666787765VQ\",\n" +
" \"sentDateTime\": \"2023-06-19T21:24:00+07:00\",\n" +
" \"version\": \"3.0.0\"\n" +
" },\n" +
" \"content\": {\n" +
" \"demandAndCapacityNotification\": {\n" +
" \"affectedSitesSender\": [\n" +
" \"BPNS7588787849VQ\"\n" +
" ],\n" +
" \"affectedSitesRecipient\": [\n" +
" \"BPNS6666787765VQ\"\n" +
" ],\n" +
" \"materialNumberSupplier\": [\n" +
" \"MNR-8101-ID146955.001\"\n" +
" ],\n" +
" \"contentChangedAt\": \"2023-12-13T15:00:00+01:00\",\n" +
" \"startDateOfEffect\": \"2023-12-13T15:00:00+01:00\",\n" +
" \"relatedNotificationId\": \"urn:uuid:d05cef4a-b692-45bf-87cc-eda2d84e4c04\",\n" +
" \"materialNumberCustomer\": [\n" +
" \"MNR-7307-AU340474.002\"\n" +
" ],\n" +
" \"leadingRootCause\": \"strike\",\n" +
" \"materialGlobalAssetId\": [\n" +
" \"urn:uuid:48878d48-6f1d-47f5-8ded-a441d0d879df\"\n" +
" ],\n" +
" \"effect\": \"demand-reduction\",\n" +
" \"notificationId\": \"urn:uuid:d9452f24-3bf3-4134-b3eb-68858f1b2362\",\n" +
" \"text\": \"Capacity reduction due to ongoing strike.\",\n" +
" \"expectedEndDateOfEffect\": \"2023-12-17T08:00:00+01:00\",\n" +
" \"sourceNotificationId\": \"urn:uuid:c69cb3e4-16ad-43c3-82b9-0deac75ecf9e\",\n" +
" \"status\": \"resolved\"\n" +
" }\n" +
" }\n" +
"}";
}
3 changes: 2 additions & 1 deletion charts/puris/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ dependencies:
| frontend.autoscaling.minReplicas | int | `1` | Number of minimum replica pods for autoscaling |
| frontend.autoscaling.targetCPUUtilizationPercentage | int | `80` | Value of CPU usage in percentage for autoscaling decisions |
| frontend.env | object | `{}` | Extra environment variables that will be passed onto the frontend deployment pods |
| frontend.image.pullPolicy | string | `"IfNotPresent"` | THe policy for the image pull process |
| frontend.image.pullPolicy | string | `"Always"` | THe policy for the image pull process |
| frontend.image.repository | string | `"tractusx/app-puris-frontend"` | Repository of the docker image |
| frontend.image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. |
| frontend.imagePullSecrets | list | `[]` | List of used secrets |
Expand All @@ -172,6 +172,7 @@ dependencies:
| frontend.puris.endpointCustomer | string | `"stockView/customer?ownMaterialNumber="` | The endpoint for the customers who buy a material identified via the own material number for the stock view |
| frontend.puris.endpointDelivery | string | `"delivery"` | The endpoint for the delivery submodel |
| frontend.puris.endpointDemand | string | `"demand"` | The endpoint for the demand submodel |
| frontend.puris.endpointErpScheduleUpdate | string | `"erp-adapter/trigger"` | The endpoint for scheduling an update of erp data (currently only stock supported) |
| frontend.puris.endpointMaterialStocks | string | `"stockView/material-stocks"` | The endpoint for material stocks for the stock view |
| frontend.puris.endpointMaterials | string | `"stockView/materials"` | The endpoint for materials for the stock view |
| frontend.puris.endpointPartners | string | `"partners"` | The endpoint for partner information |
Expand Down
2 changes: 2 additions & 0 deletions charts/puris/templates/frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ spec:
value: "{{ .Values.frontend.puris.endpointUpdateReportedMaterialStocks }}"
- name: ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS
value: "{{ .Values.frontend.puris.endpointUpdateReportedProductStocks }}"
- name: ENDPOINT_ERP_SCHEDULE_UPDATE
value: "{{ .Values.frontend.puris.endpointErpScheduleUpdate }}"
- name: ENDPOINT_PARTNER
value: "{{ .Values.frontend.puris.endpointPartners }}"
- name: ENDPOINT_DEMAND
Expand Down
4 changes: 3 additions & 1 deletion charts/puris/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ frontend:
# -- Repository of the docker image
repository: tractusx/app-puris-frontend
# -- THe policy for the image pull process
pullPolicy: IfNotPresent
pullPolicy: Always
# -- Overrides the image tag whose default is the chart appVersion.
tag: ""

Expand Down Expand Up @@ -183,6 +183,8 @@ frontend:
endpointUpdateReportedMaterialStocks: stockView/update-reported-material-stocks?ownMaterialNumber=
# -- The endpoint for triggering an update of your product stocks on your partners side
endpointUpdateReportedProductStocks: stockView/update-reported-product-stocks?ownMaterialNumber=
# -- The endpoint for scheduling an update of erp data (currently only stock supported)
endpointErpScheduleUpdate: erp-adapter/trigger
# -- The endpoint for partner information
endpointPartners: partners
# -- The endpoint for the demand submodel
Expand Down
1 change: 1 addition & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ VITE_ENDPOINT_REPORTED_MATERIAL_STOCKS=stockView/reported-material-stocks?ownMat
VITE_ENDPOINT_REPORTED_PRODUCT_STOCKS=stockView/reported-product-stocks?ownMaterialNumber=
VITE_ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS=stockView/update-reported-material-stocks?ownMaterialNumber=
VITE_ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS=stockView/update-reported-product-stocks?ownMaterialNumber=
VITE_ENDPOINT_ERP_SCHEDULE_UPDATE=erp-adapter/trigger
VITE_ENDPOINT_PARTNER=partners
VITE_ENDPOINT_DEMAND=demand
VITE_ENDPOINT_PRODUCTION=production
Expand Down
1 change: 1 addition & 0 deletions frontend/.env.dockerbuild
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ VITE_ENDPOINT_REPORTED_MATERIAL_STOCKS=\$ENDPOINT_REPORTED_MATERIAL_STOCKS
VITE_ENDPOINT_REPORTED_PRODUCT_STOCKS=\$ENDPOINT_REPORTED_PRODUCT_STOCKS
VITE_ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS=\$ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS
VITE_ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS=\$ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS
VITE_ENDPOINT_ERP_SCHEDULE_UPDATE=\$ENDPOINT_ERP_SCHEDULE_UPDATE
VITE_ENDPOINT_PARTNER=\$ENDPOINT_PARTNER
VITE_ENDPOINT_DEMAND=\$ENDPOINT_DEMAND
VITE_ENDPOINT_PRODUCTION=\$ENDPOINT_PRODUCTION
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# SPDX-License-Identifier: Apache-2.0
#
FROM node:lts-alpine as build
FROM node:lts-alpine AS build

ARG NPM_BUILD_MODE=dockerbuild

Expand Down
1 change: 1 addition & 0 deletions frontend/src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"ENDPOINT_REPORTED_PRODUCT_STOCKS": "$ENDPOINT_REPORTED_PRODUCT_STOCKS",
"ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS":"$ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS",
"ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS":"$ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS",
"ENDPOINT_ERP_SCHEDULE_UPDATE":"$ENDPOINT_ERP_SCHEDULE_UPDATE",
"ENDPOINT_PARTNER": "$ENDPOINT_PARTNER",
"ENDPOINT_DEMAND": "$ENDPOINT_DEMAND",
"ENDPOINT_PRODUCTION": "$ENDPOINT_PRODUCTION",
Expand Down
Loading

0 comments on commit 148704a

Please sign in to comment.