-
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 #64 from catenax-ng/support_edc_edr_api_use
[feat|sde] support edr api for the consume data.
- Loading branch information
Showing
13 changed files
with
410 additions
and
15 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
28 changes: 28 additions & 0 deletions
28
modules/sde-core/src/main/resources/flyway/V22__add_new_role_for_download.sql
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,28 @@ | ||
/******************************************************************************** | ||
* 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 | ||
********************************************************************************/ | ||
INSERT INTO sde_permission (sde_permission,description) | ||
VALUES ('consumer_download_data','Allows consumer user to download data'); | ||
|
||
INSERT INTO sde_role_permission_mapping (sde_permission,sde_role) | ||
VALUES ('consumer_download_data','User'); | ||
|
||
INSERT INTO sde_role_permission_mapping (sde_permission,sde_role) | ||
VALUES ('consumer_download_data','Creator'); | ||
|
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
59 changes: 59 additions & 0 deletions
59
...sde-external-services/edc/src/main/java/org/eclipse/tractusx/sde/edc/api/EDRApiProxy.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.edc.api; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.tractusx.sde.edc.model.contractnegotiation.AcknowledgementId; | ||
import org.eclipse.tractusx.sde.edc.model.contractnegotiation.ContractNegotiations; | ||
import org.eclipse.tractusx.sde.edc.model.edr.EDRCachedByIdResponse; | ||
import org.eclipse.tractusx.sde.edc.model.edr.EDRCachedResponse; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
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; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
@FeignClient(value = "EDRApiProxy", url = "placeholder") | ||
public interface EDRApiProxy { | ||
|
||
@PostMapping(path = "/edrs", consumes = MediaType.APPLICATION_JSON_VALUE) | ||
AcknowledgementId edrCacheCreate(URI url, @RequestBody ContractNegotiations requestBody, | ||
@RequestHeader Map<String, String> requestHeader); | ||
|
||
@GetMapping(path = "/edrs", consumes = MediaType.APPLICATION_JSON_VALUE) | ||
List<EDRCachedResponse> getEDRCachedByAsset(URI url, @RequestParam("assetId") String assetId, | ||
@RequestHeader Map<String, String> requestHeader); | ||
|
||
@GetMapping(path = "/edrs/{transferProcessId}") | ||
EDRCachedByIdResponse getEDRCachedByTransferProcessId(URI url, | ||
@PathVariable("transferProcessId") String transferProcessId, | ||
@RequestHeader Map<String, String> requestHeader); | ||
|
||
@GetMapping | ||
Object getActualDataFromProviderDataPlane(URI url, @RequestHeader Map<String, String> requestHeader); | ||
|
||
} |
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
76 changes: 76 additions & 0 deletions
76
...services/edc/src/main/java/org/eclipse/tractusx/sde/edc/facilitator/EDRRequestHelper.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,76 @@ | ||
/******************************************************************************** | ||
* 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.edc.facilitator; | ||
|
||
import java.net.URI; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.tractusx.sde.edc.api.EDRApiProxy; | ||
import org.eclipse.tractusx.sde.edc.entities.request.policies.ActionRequest; | ||
import org.eclipse.tractusx.sde.edc.mapper.ContractMapper; | ||
import org.eclipse.tractusx.sde.edc.model.contractnegotiation.AcknowledgementId; | ||
import org.eclipse.tractusx.sde.edc.model.contractnegotiation.ContractNegotiations; | ||
import org.eclipse.tractusx.sde.edc.model.edr.EDRCachedByIdResponse; | ||
import org.eclipse.tractusx.sde.edc.model.edr.EDRCachedResponse; | ||
import org.springframework.stereotype.Service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.SneakyThrows; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class EDRRequestHelper extends AbstractEDCStepsHelper { | ||
|
||
private final EDRApiProxy edrApiProxy; | ||
private final ContractMapper contractMapper; | ||
|
||
@SneakyThrows | ||
public String edrRequestInitiate(String providerUrl, String providerId, String offerId, String assetId, | ||
ActionRequest action, Map<String, String> extensibleProperty) { | ||
|
||
ContractNegotiations contractNegotiations = contractMapper | ||
.prepareContractNegotiations(providerUrl + protocolPath, offerId, assetId, providerId, action); | ||
|
||
AcknowledgementId acknowledgementId = edrApiProxy.edrCacheCreate(new URI(consumerHostWithDataPath), contractNegotiations, | ||
getAuthHeader()); | ||
return acknowledgementId.getId(); | ||
} | ||
|
||
@SneakyThrows | ||
public List<EDRCachedResponse> getEDRCachedByAsset(String assetId) { | ||
return edrApiProxy.getEDRCachedByAsset(new URI(consumerHostWithDataPath), assetId, getAuthHeader()); | ||
} | ||
|
||
@SneakyThrows | ||
public EDRCachedByIdResponse getEDRCachedByTransferProcessId(String transferProcessId) { | ||
return edrApiProxy.getEDRCachedByTransferProcessId(new URI(consumerHostWithDataPath), transferProcessId, getAuthHeader()); | ||
} | ||
|
||
@SneakyThrows | ||
public Object getDataFromProvider(EDRCachedByIdResponse authorizationToken) { | ||
Map<String, String> authHeader = new HashMap<>(); | ||
authHeader.put(authorizationToken.getAuthKey(), authorizationToken.getAuthCode()); | ||
return edrApiProxy.getActualDataFromProviderDataPlane(new URI(authorizationToken.getEndpoint()), authHeader); | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...vices/edc/src/main/java/org/eclipse/tractusx/sde/edc/model/edr/EDRCachedByIdResponse.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,56 @@ | ||
/******************************************************************************** | ||
* 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.edc.model.edr; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(Include.NON_NULL) | ||
public class EDRCachedByIdResponse { | ||
|
||
@JsonProperty("edc:type") | ||
private String type; | ||
|
||
@JsonProperty("edc:authCode") | ||
private String authCode; | ||
|
||
@JsonProperty("edc:endpoint") | ||
private String endpoint; | ||
|
||
@JsonProperty("edc:id") | ||
private String id; | ||
|
||
@JsonProperty("edc:authKey") | ||
private String authKey; | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
...-services/edc/src/main/java/org/eclipse/tractusx/sde/edc/model/edr/EDRCachedResponse.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.edc.model.edr; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(Include.NON_NULL) | ||
public class EDRCachedResponse { | ||
|
||
@JsonProperty("@type") | ||
private String type; | ||
|
||
@JsonProperty("@context") | ||
private Object context; | ||
|
||
@JsonProperty("edc:agreementId") | ||
private String agreementId; | ||
|
||
@JsonProperty("edc:transferProcessId") | ||
private String transferProcessId; | ||
|
||
@JsonProperty("edc:assetId") | ||
private String assetId; | ||
|
||
@JsonProperty("edc:providerId") | ||
private String providerId; | ||
|
||
@JsonProperty("tx:edrState") | ||
private String edrState; | ||
|
||
@JsonProperty("tx:expirationDate") | ||
private String expirationDate; | ||
|
||
} |
Oops, something went wrong.