Skip to content

Commit

Permalink
Merge pull request #447 from catenax-ng/bug/412-asset-creation-produc…
Browse files Browse the repository at this point in the history
…ing-bad-request-in-edc

feature(irs-edc-client): #412 fix properties transforming for notific…
  • Loading branch information
ds-jhartmann authored Feb 26, 2024
2 parents b5bafbd + 8f3a0a4 commit 7b3a60b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public class EdcAssetService {
private static final String ASSET_CREATION_DATA_ADDRESS_PROXY_PATH = "https://w3id.org/edc/v0.0.1/ns/proxyPath";
private static final String ASSET_CREATION_DATA_ADDRESS_PROXY_QUERY_PARAMS = "https://w3id.org/edc/v0.0.1/ns/proxyQueryParams";
private static final String ASSET_CREATION_DATA_ADDRESS_METHOD = "https://w3id.org/edc/v0.0.1/ns/method";
private static final String ASSET_CREATION_PROPERTY_DESCRIPTION = "https://w3id.org/edc/v0.0.1/ns/description";
private static final String ASSET_CREATION_PROPERTY_CONTENT_TYPE = "https://w3id.org/edc/v0.0.1/ns/contenttype";
private static final String ASSET_CREATION_PROPERTY_POLICY_ID = "https://w3id.org/edc/v0.0.1/ns/policy-id";
private static final String ASSET_CREATION_PROPERTY_TYPE = "https://w3id.org/edc/v0.0.1/ns/type";
private static final String ASSET_CREATION_PROPERTY_NOTIFICATION_TYPE = "https://w3id.org/edc/v0.0.1/ns/notificationtype";
private static final String ASSET_CREATION_PROPERTY_NOTIFICATION_METHOD = "https://w3id.org/edc/v0.0.1/ns/notificationmethod";

private final EdcTransformer edcTransformer;
private final EdcConfiguration config;
Expand Down Expand Up @@ -115,9 +121,12 @@ public void deleteAsset(final String assetId) throws DeleteEdcAssetException {
private Asset createNotificationAssetRequest(final String assetName, final String baseUrl,
final NotificationMethod notificationMethod, final NotificationType notificationType) {
final String assetId = UUID.randomUUID().toString();
final Map<String, Object> properties = Map.of("description", assetName, "contenttype", DEFAULT_CONTENT_TYPE,
"policy-id", DEFAULT_POLICY_ID, "type", notificationType.getValue(), "notificationtype",
notificationType.getValue(), "notificationmethod", notificationMethod.getValue());
final Map<String, Object> properties = Map.of(ASSET_CREATION_PROPERTY_DESCRIPTION, assetName,
ASSET_CREATION_PROPERTY_CONTENT_TYPE, DEFAULT_CONTENT_TYPE,
ASSET_CREATION_PROPERTY_POLICY_ID, DEFAULT_POLICY_ID, ASSET_CREATION_PROPERTY_TYPE,
notificationType.getValue(), ASSET_CREATION_PROPERTY_NOTIFICATION_TYPE,
notificationType.getValue(), ASSET_CREATION_PROPERTY_NOTIFICATION_METHOD,
notificationMethod.getValue());

final DataAddress dataAddress = DataAddress.Builder.newInstance()
.type(HTTP_DATA)
Expand All @@ -139,7 +148,7 @@ private Asset createNotificationAssetRequest(final String assetName, final Strin

private Asset createDtrAssetRequest(final String assetName, final String baseUrl) {
final String assetId = UUID.randomUUID().toString();
final Map<String, Object> properties = Map.of("description", assetName, "type",
final Map<String, Object> properties = Map.of(ASSET_CREATION_PROPERTY_DESCRIPTION, assetName, ASSET_CREATION_PROPERTY_TYPE,
"data.core.digitalTwinRegistry");

final DataAddress dataAddress = DataAddress.Builder.newInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ void setUp() {
@Test
void testAssetCreateRequestStructure() throws JSONException, JsonProcessingException {

Map<String, Object> properties = Map.of("description", "endpoint to qualityinvestigation receive",
"contenttype", "application/json", "policy-id", "use-eu", "type", "receive", "notificationtype",
"qualityinvestigation", "notificationmethod", "receive");
Map<String, Object> properties = Map.of("https://w3id.org/edc/v0.0.1/ns/description", "endpoint to qualityinvestigation receive",
"https://w3id.org/edc/v0.0.1/ns/contenttype", "application/json", "https://w3id.org/edc/v0.0.1/ns/policy-id", "use-eu", "https://w3id.org/edc/v0.0.1/ns/type", "receive", "https://w3id.org/edc/v0.0.1/ns/notificationtype",
"qualityinvestigation", "https://w3id.org/edc/v0.0.1/ns/notificationmethod", "receive");

DataAddress dataAddress = DataAddress.Builder.newInstance()
.type(HTTP_DATA)
Expand Down Expand Up @@ -124,23 +124,28 @@ void testAssetCreateRequestStructure() throws JSONException, JsonProcessingExcep
"@id": "Asset1",
"@type": "edc:Asset",
"edc:properties": {
"edc:type": "receive",
"edc:notificationtype": "qualityinvestigation",
"edc:policy-id": "use-eu",
"edc:description": "endpoint to qualityinvestigation receive",
"edc:id": "Asset1",
"edc:contenttype": "Asset"
"edc:contenttype": "application/json",
"edc:notificationmethod": "receive"
},
"edc:dataAddress": {
"@type": "edc:DataAddress",
"edc:method": "POST",
"edc:type": "HttpData",
"edc:proxyMethod": "true",
"edc:proxyBody": "true",
"edc:baseUrl": "https://traceability.dev.demo.catena-x.net/api/qualitynotifications/receive",
"edc:method": "POST",
"edc:proxyMethod": "true"
"edc:baseUrl": "https://traceability.dev.demo.catena-x.net/api/qualitynotifications/receive"
},
"@context": {
"dct": "https://purl.org/dc/terms/",
"tx": "https://w3id.org/tractusx/v0.0.1/ns/",
"edc": "https://w3id.org/edc/v0.0.1/ns/",
"dcat": "https://www.w3.org/ns/dcat/",
"odrl": "http://www.w3.org/ns/odrl/2/",
"dcat": "https://www.w3.org/ns/dcat/",
"dspace": "https://w3id.org/dspace/v0.8/"
}
}
Expand Down

0 comments on commit 7b3a60b

Please sign in to comment.