diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/config/DtrConfig.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/config/DtrConfig.java index 28eaea104..4b0557509 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/config/DtrConfig.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/config/DtrConfig.java @@ -49,10 +49,24 @@ public class DtrConfig { String endpointInterface; String dspEndpointKey; + String semanticIdTypeKey; /** CONSTRUCTOR(S) **/ public DtrConfig() { } + public DtrConfig(Boolean central, String centralUrl, String internalDtr, Timeouts timeouts, Boolean temporaryStorage, DecentralApis decentralApis, String assetId, String endpointInterface, String dspEndpointKey, String semanticIdTypeKey) { + this.central = central; + this.centralUrl = centralUrl; + this.internalDtr = internalDtr; + this.timeouts = timeouts; + this.temporaryStorage = temporaryStorage; + this.decentralApis = decentralApis; + this.assetId = assetId; + this.endpointInterface = endpointInterface; + this.dspEndpointKey = dspEndpointKey; + this.semanticIdTypeKey = semanticIdTypeKey; + } + /** GETTERS AND SETTERS **/ public DecentralApis getDecentralApis() { return decentralApis; @@ -113,6 +127,14 @@ public void setAssetId(String assetId) { this.assetId = assetId; } + public String getSemanticIdTypeKey() { + return semanticIdTypeKey; + } + + public void setSemanticIdTypeKey(String semanticIdTypeKey) { + this.semanticIdTypeKey = semanticIdTypeKey; + } + /** INNER CLASSES **/ /** diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/AppController.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/AppController.java index 37268bed8..efb88f1a2 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/AppController.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/AppController.java @@ -183,7 +183,7 @@ public Response getDigitalTwin(@RequestBody Object body, @PathVariable String pr try { digitalTwin = digitalTwinRegistry.getDigitalTwin(); subModel = digitalTwinRegistry.getSubModel(); - semanticId = Objects.requireNonNull(subModel.getSemanticId().getKeys().stream().filter(k -> k.getType().equalsIgnoreCase("Submodel") || k.getType().equalsIgnoreCase("GlobalReference")).findFirst().orElse(null)).getValue(); + semanticId = Objects.requireNonNull(subModel.getSemanticId().getKeys().stream().filter(k -> k.getType().equalsIgnoreCase(this.dtrConfig.getSemanticIdTypeKey())).findFirst().orElse(null)).getValue(); connectorId = subModel.getIdShort(); EndPoint3 endpoint = subModel.getEndpoints().stream().filter(obj -> obj.getInterfaceName().equals(dtrConfig.getEndpointInterface())).findFirst().orElse(null); if (endpoint == null) { diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ApiController.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ApiController.java index 8e3acdcbc..25cb2e9b8 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ApiController.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ApiController.java @@ -99,14 +99,14 @@ Response index() throws Exception { * @return this {@code Response} HTTP response with status. * */ - @RequestMapping(value = "/passport", method = {RequestMethod.POST}) - @Operation(summary = "Returns versioned product passport by id", responses = { + @RequestMapping(value = "/data", method = {RequestMethod.POST}) + @Operation(summary = "Returns the data negotiated and transferred", responses = { @ApiResponse(description = "Default Response Structure", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Response.class))), @ApiResponse(description = "Content of Data Field in Response", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = PassportResponse.class))), }) - public Response getPassport(@Valid @RequestBody TokenRequest tokenRequestBody) { + public Response getData(@Valid @RequestBody TokenRequest tokenRequestBody) { Response response = httpUtil.getInternalError(); // Check for authentication @@ -169,13 +169,13 @@ public Response getPassport(@Valid @RequestBody TokenRequest tokenRequestBody) { return httpUtil.buildResponse(response, httpResponse); } - if (!status.historyExists("passport-received")) { - response = httpUtil.getNotFound("The passport is not available!"); + if (!status.historyExists("data-received")) { + response = httpUtil.getNotFound("The data is not available!"); return httpUtil.buildResponse(response, httpResponse); } - if (status.historyExists("passport-retrieved")) { - response = httpUtil.getNotFound("The passport was already retrieved and is no longer available!"); + if (status.historyExists("data-retrieved")) { + response = httpUtil.getNotFound("The data was already retrieved and is no longer available!"); return httpUtil.buildResponse(response, httpResponse); } String semanticId = status.getSemanticId(); diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ContractController.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ContractController.java index 60885df06..5133284db 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ContractController.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ContractController.java @@ -463,7 +463,7 @@ public Response cancel(@Valid @RequestBody TokenRequest tokenRequestBody) { return httpUtil.buildResponse(response, httpResponse); } - if (status.getStatus().equals("COMPLETED") || status.getStatus().equals("RETRIEVED") || status.historyExists("transfer-request") || status.historyExists("transfer-completed") || status.historyExists("passport-received") || status.historyExists("passport-retrieved")) { + if (status.getStatus().equals("COMPLETED") || status.getStatus().equals("RETRIEVED") || status.historyExists("transfer-request") || status.historyExists("transfer-completed") || status.historyExists("data-received") || status.historyExists("data-retrieved")) { response = httpUtil.getForbiddenResponse("This negotiation can not be canceled! It was already transferred!"); return httpUtil.buildResponse(response, httpResponse); } diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/managers/ProcessManager.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/managers/ProcessManager.java index 254972b7b..4cd51c9f7 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/managers/ProcessManager.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/managers/ProcessManager.java @@ -964,7 +964,7 @@ public String saveProcessPayload(String processId, Object payload, String fileNa this.setStatus(processId, eventKey, history); String path = this.getProcessFilePath(processId, fileName); String returnPath = ""; - if(eventKey.equals("passport-received") && encrypt) { + if(eventKey.equals("data-received") && encrypt) { returnPath = fileUtil.toFile(path, payload.toString(), false); }else { returnPath = jsonUtil.toJsonFile(path, payload, processConfig.getIndent()); @@ -1239,7 +1239,7 @@ public JsonNode loadPassport(String processId){ LogUtil.printStatus("[PROCESS " + processId +"] Failed to delete passport file!"); } - this.setStatus(processId,"passport-retrieved", history); + this.setStatus(processId,"data-retrieved", history); return passport; } catch (Exception e) { throw new ManagerException(this.getClass().getName(), e, "It was not possible to load the passport!"); @@ -1285,7 +1285,7 @@ public String savePassport(String processId, DataPlaneEndpoint endpointData, Jso this.passportFileName, endpointData.getId(), "RECEIVED", - "passport-received"); + "data-received"); } catch (Exception e) { throw new ManagerException(this.getClass().getName(), e, "It was not possible to save the digital product passport!"); } diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java index 026c8b791..4c6af1c0e 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/services/AasService.java @@ -61,11 +61,12 @@ @Service public class AasService extends BaseService { - private final String submodelTypeKey = "Submodel"; /** ATTRIBUTES **/ public String registryUrl; public Boolean central; + public String semanticIdTypeKey; + private final HttpUtil httpUtil; private final JsonUtil jsonUtil; private final DtrConfig dtrConfig; @@ -77,6 +78,7 @@ public class AasService extends BaseService { private PassportConfig passportConfig; + /** CONSTRUCTOR(S) **/ @Autowired public AasService(Environment env, HttpUtil httpUtil, JsonUtil jsonUtil, AuthenticationService authService, DtrConfig dtrConfig, DtrSearchManager dtrSearchManager, ProcessManager processManager, DataTransferService dataService, PassportConfig passportConfig) throws ServiceInitializationException { @@ -108,6 +110,7 @@ public void init(Environment env) { "subModel", "/submodel-descriptors" ); } + this.semanticIdTypeKey = dtrConfig.getSemanticIdTypeKey(); this.apis = Map.of( "central", Map.of( "search", "/lookup/shells", @@ -608,7 +611,9 @@ public SubModel3 getSubModel3BySemanticId(DigitalTwin3 digitalTwin) { SubModel3 subModel = null; // Search for first subModel with matching semanticId, if it fails gives null for (String semanticId: passportConfig.getAspects()) { - subModel = subModels.stream().filter(s -> s.getSemanticId().getKeys().stream().filter(k -> k.getType().equalsIgnoreCase(submodelTypeKey) && k.getValue().equalsIgnoreCase(semanticId)) != null).findFirst().orElse(null); + subModel = subModels.stream().filter(s -> s.getSemanticId().getKeys().stream().anyMatch( + k -> (k.getType().equalsIgnoreCase(this.semanticIdTypeKey) && k.getValue().equalsIgnoreCase(semanticId)) + )).findFirst().orElse(null); if (subModel != null) { return subModel; // Return subModel if found } @@ -627,7 +632,7 @@ public SubModel3 getSubModel3BySemanticId(DigitalTwin3 digitalTwin) { *

* @param digitalTwin * the {@code DigitalTwin3} object with its submodels. - * @param semanticId + * @param aspectSemanticId * the {@code String} semantic id of the intended submodel. * * @return a {@code Submodel3} object with the submodel found, if exists. @@ -635,7 +640,7 @@ public SubModel3 getSubModel3BySemanticId(DigitalTwin3 digitalTwin) { * @throws ServiceException * if unable to find a the {@code Submodel3} for the given semantic id. */ - public SubModel3 getSubModel3BySemanticId(DigitalTwin3 digitalTwin, String semanticId) { + public SubModel3 getSubModel3BySemanticId(DigitalTwin3 digitalTwin, String aspectSemanticId) { try { ArrayList subModels = digitalTwin.getSubmodelDescriptors(); if (subModels.size() < 1) { @@ -644,7 +649,10 @@ public SubModel3 getSubModel3BySemanticId(DigitalTwin3 digitalTwin, String seman } SubModel3 subModel = null; // Search for first subModel with matching semanticId, if it fails gives null - subModel = subModels.stream().filter(s -> s.getSemanticId().getKeys().stream().filter(k -> k.getType().equalsIgnoreCase(submodelTypeKey) && k.getValue().equalsIgnoreCase(semanticId)) != null).findFirst().orElse(null); + subModel = subModels.stream().filter( + s -> s.getSemanticId().getKeys().stream().anyMatch( + k -> (k.getType().equalsIgnoreCase(this.semanticIdTypeKey) && k.getValue().equalsIgnoreCase(aspectSemanticId)) + )).findFirst().orElse(null); if (subModel != null) { return subModel; // Return subModel if found } diff --git a/consumer-backend/productpass/src/main/resources/application.yml b/consumer-backend/productpass/src/main/resources/application.yml index 48ef6484b..074e743b5 100644 --- a/consumer-backend/productpass/src/main/resources/application.yml +++ b/consumer-backend/productpass/src/main/resources/application.yml @@ -67,6 +67,7 @@ configuration: endpointInterface: 'SUBMODEL-3.0' dspEndpointKey: 'dspEndpoint' internalDtr: "https://materialpass.int.demo.catena-x.net/BPNL000000000000" # -- If there is an internal DTR available it can be referenced here and will be injected in the list of DTRs + semanticIdTypeKey: 'Submodel' decentralApis: search: "/lookup/shells" digitalTwin: "/shell-descriptors" diff --git a/src/components/general/LoadingComponent.vue b/src/components/general/LoadingComponent.vue index bc847c981..4ca3ef6dd 100644 --- a/src/components/general/LoadingComponent.vue +++ b/src/components/general/LoadingComponent.vue @@ -37,7 +37,7 @@ (statusData.data.history['transfer-request'] ? this.stepsNames.contractTransfer.progressValue : 0) + - (statusData.data.history['passport-received'] + (statusData.data.history['data-received'] ? this.stepsNames.passportRetrieval.progressValue : 0) " @@ -116,7 +116,7 @@ />