-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from catenax-ng/main
[feature]: Added BPN Discovery service integration for DDTR.
- Loading branch information
Showing
31 changed files
with
867 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
59 changes: 59 additions & 0 deletions
59
.../main/java/org/eclipse/tractusx/sde/bpndiscovery/api/IBpndiscoveryExternalServiceApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
||
} |
55 changes: 55 additions & 0 deletions
55
...c/main/java/org/eclipse/tractusx/sde/bpndiscovery/handler/BPNDiscoveryUseCaseHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
...src/main/java/org/eclipse/tractusx/sde/bpndiscovery/handler/BpnDiscoveryProxyService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...rc/main/java/org/eclipse/tractusx/sde/bpndiscovery/model/request/BpnDiscoveryRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
Oops, something went wrong.