Skip to content

Commit

Permalink
Merge pull request #25 from catenax-ng/main
Browse files Browse the repository at this point in the history
[feature]: Added BPN Discovery service integration for DDTR.
  • Loading branch information
almadigabor authored Jun 22, 2023
2 parents 4d28f80 + c256af0 commit 3635c38
Show file tree
Hide file tree
Showing 31 changed files with 867 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
uses: aquasecurity/trivy-action@master
with:
# Path to Docker image
image-ref: "ghcr.io/catenax-ng/tx-dft-backend:latest"
image-ref: "ghcr.io/catenax-ng/tx-managed-simple-data-exchanger-backend:latest"
format: "sarif"
output: "trivy-results.sarif"
exit-code: "1"
Expand Down
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# Changelog
All notable changes to this project will be documented in this file.

## [Unreleased]
- Support EDC version 4.1.
- Renamed SerialPartTypization aspect submodel to SerialPart.
- Renamed AssemblyPartRelationship aspect submodel to SingleLevelBoMAsBuilt.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [2.0.2] - 2023-06-21
### Added
- BPN Discovery service integration for DDTR.

### Fixed
- Upgradation of springboot(3.0.5-3.1.0) for security.

## [2.0.1] - 2023-05-23
- Add automatic identification of submodel for processing.

Expand Down Expand Up @@ -134,8 +146,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Compliance with Catena-X Guidelines
- Integration with Digital Twin registry service.

[unreleased]: https://github.com/eclipse-tractusx/dft-backend/compare/2.0.1...main
[2.0.1]:https://github.com/eclipse-tractusx/dft-backend/compare/2.0.0...2.0.1
[unreleased]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/dftbackend-2.0.2...main
[2.0.2]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/dftbackend-2.0.1...dftbackend-2.0.2
[2.0.1]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/dftbackend-2.0.0...dftbackend-2.0.1
[2.0.0]: https://github.com/eclipse-tractusx/dft-backend/compare/1.9.1...2.0.0
[1.9.1]: https://github.com/eclipse-tractusx/dft-backend/compare/1.9.0...1.9.1
[1.9.0]: https://github.com/eclipse-tractusx/dft-backend/compare/dft-backend-1.8.1...1.9.0
Expand Down
168 changes: 84 additions & 84 deletions DEPENDENCIES

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions charts/dftbackend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ sources:
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.0.1
version: 2.0.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "2.0.1"
appVersion: "2.0.2"

dependencies:
- condition: dftpostgresql.enabled
Expand Down
5 changes: 5 additions & 0 deletions charts/dftbackend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,8 @@ configuration:
connector.discovery.clientSecret=default
portal.backend.hostname=default
springdoc.api-docs.path=/api-docs
bpndiscovery.hostname=default
discovery.authentication.url=default
discovery.clientId=default
discovery.clientSecret=default
discovery.grantType=default
7 changes: 7 additions & 0 deletions modules/sde-core/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,11 @@ partner.pool.hostname=
## Portal Backend service URL
portal.backend.hostname=

## bpn & discovery finder
bpndiscovery.hostname=
discovery.authentication.url=
discovery.clientId=
discovery.clientSecret=
discovery.grantType=

springdoc.api-docs.path=/api-docs
69 changes: 69 additions & 0 deletions modules/sde-external-services/bpn-discovery/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!--
/********************************************************************************
* Copyright (c) 2023 T-Systems International GmbH
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>sde</artifactId>
<version>0.0.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>bpn-discovery</artifactId>
<name>bpn-discovery</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>sde-common</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.processor.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>
-Amapstruct.unmappedTargetPolicy=IGNORE
</compilerArg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/********************************************************************************
* Copyright (c) 2023 T-Systems International GmbH
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.sde.bpndiscovery.api;

import java.net.URI;
import java.util.List;

import org.eclipse.tractusx.sde.bpndiscovery.model.request.BpnDiscoveryRequest;
import org.eclipse.tractusx.sde.bpndiscovery.model.request.BpnDiscoverySearchRequest;
import org.eclipse.tractusx.sde.bpndiscovery.model.response.BpnDiscoveryBatchResponse;
import org.eclipse.tractusx.sde.bpndiscovery.model.response.BpnDiscoveryResponse;
import org.eclipse.tractusx.sde.bpndiscovery.model.response.BpnDiscoverySearchResponse;
import org.eclipse.tractusx.sde.bpndiscovery.model.response.KeycloakJWTTokenResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

@FeignClient(value = "IBpndiscoveryExternalServiceApi", url = "${bpndiscovery.hostname}")
public interface IBpndiscoveryExternalServiceApi {

@PostMapping
KeycloakJWTTokenResponse getBpnDiscoveryAuthToken(URI url, @RequestBody MultiValueMap<String, Object> body);

@PostMapping(path = "/api/administration/connectors/bpnDiscovery")
BpnDiscoveryResponse bpnDiscoveryDataByKey(@RequestBody BpnDiscoveryRequest bpnDiscoveryKey, @RequestHeader("Authorization") String bearerToken);

@PostMapping(path = "/api/administration/connectors/bpnDiscovery/batch")
List<BpnDiscoveryBatchResponse> bpnDiscoveryBatchDataByList(@RequestBody List<BpnDiscoveryRequest> bpnDiscoveryKeyList, @RequestHeader("Authorization") String bearerToken);

@PostMapping(path = "/api/administration/connectors/bpnDiscovery/search")
BpnDiscoverySearchResponse bpnDiscoverySearchData(@RequestBody BpnDiscoverySearchRequest bpnDiscoverySearchRequest, @RequestHeader("Authorization") String bearerToken);

@DeleteMapping(path = "/api/administration/connectors/bpnDiscovery/{resourceId}")
ResponseEntity<Object> deleteBpnDiscoveryData(@PathVariable String resourceId, @RequestHeader("Authorization") String bearerToken);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/********************************************************************************
* Copyright (c) 2023 T-Systems International GmbH
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.sde.bpndiscovery.handler;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.eclipse.tractusx.sde.bpndiscovery.model.request.BpnDiscoveryRequest;
import org.eclipse.tractusx.sde.common.submodel.executor.Step;
import org.springframework.stereotype.Service;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;

@Service
@RequiredArgsConstructor
public class BPNDiscoveryUseCaseHandler extends Step {

private final BpnDiscoveryProxyService bpnDiscoveryProxyService;

@SneakyThrows
public void run(Map<String, String> input) {

BpnDiscoveryRequest bpnDiscoveryRequest = new BpnDiscoveryRequest();
List<BpnDiscoveryRequest> bpnDiscoveryKeyList = new ArrayList<>();

input.entrySet().stream().forEach(e -> {
bpnDiscoveryRequest.setType(e.getKey());
bpnDiscoveryRequest.setKey(e.getValue());
bpnDiscoveryKeyList.add(bpnDiscoveryRequest);
});

bpnDiscoveryProxyService.bpnDiscoveryBatchData(bpnDiscoveryKeyList);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/********************************************************************************
* Copyright (c) 2023 T-Systems International GmbH
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.sde.bpndiscovery.handler;

import java.util.List;

import org.eclipse.tractusx.sde.bpndiscovery.api.IBpndiscoveryExternalServiceApi;
import org.eclipse.tractusx.sde.bpndiscovery.model.request.BpnDiscoveryRequest;
import org.eclipse.tractusx.sde.bpndiscovery.model.request.BpnDiscoverySearchRequest;
import org.eclipse.tractusx.sde.bpndiscovery.model.response.BpnDiscoveryBatchResponse;
import org.eclipse.tractusx.sde.bpndiscovery.model.response.BpnDiscoveryResponse;
import org.eclipse.tractusx.sde.bpndiscovery.model.response.BpnDiscoverySearchResponse;
import org.eclipse.tractusx.sde.bpndiscovery.utils.BpnDiscoveryAuthToken;
import org.springframework.stereotype.Service;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;

@Service
@RequiredArgsConstructor
public class BpnDiscoveryProxyService {

private final IBpndiscoveryExternalServiceApi bpndiscoveryExternalServiceApi;

private final BpnDiscoveryAuthToken bpnDiscoveryAuthToken;


@SneakyThrows
public BpnDiscoveryResponse bpnDiscoveryData(BpnDiscoveryRequest bpnDiscoveryRequest) {
return bpndiscoveryExternalServiceApi.bpnDiscoveryDataByKey(bpnDiscoveryRequest, bpnDiscoveryAuthToken.getToken());
}

@SneakyThrows
public BpnDiscoverySearchResponse bpnDiscoverySearchData(BpnDiscoverySearchRequest bpnDiscoverySearchRequest) {
return bpndiscoveryExternalServiceApi.bpnDiscoverySearchData(bpnDiscoverySearchRequest, bpnDiscoveryAuthToken.getToken());
}

@SneakyThrows
public List<BpnDiscoveryBatchResponse> bpnDiscoveryBatchData(List<BpnDiscoveryRequest> bpnDiscoveryKeyList) {
return bpndiscoveryExternalServiceApi.bpnDiscoveryBatchDataByList(bpnDiscoveryKeyList, bpnDiscoveryAuthToken.getToken());
}

@SneakyThrows
public void deleteBpnDiscoveryData(String resourceId) {
bpndiscoveryExternalServiceApi.deleteBpnDiscoveryData(resourceId, bpnDiscoveryAuthToken.getToken());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/********************************************************************************
* Copyright (c) 2023 T-Systems International GmbH
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

package org.eclipse.tractusx.sde.bpndiscovery.model.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class BpnDiscoveryRequest {

private String type;
private String key;

}
Loading

0 comments on commit 3635c38

Please sign in to comment.