Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dct namespace #3914

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_FORMAT_ATTRIBUTE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DEPRECATED_DCT_FORMAT_ATTRIBUTE;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROCESS_ID;
Expand All @@ -53,6 +54,7 @@ public JsonObjectFromTransferRequestMessageTransformer(JsonBuilderFactory jsonBu
.add(ID, transferRequestMessage.getId())
.add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE)
.add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, transferRequestMessage.getContractId())
.add(DEPRECATED_DCT_FORMAT_ATTRIBUTE, format)
.add(DCT_FORMAT_ATTRIBUTE, format)
.add(DSPACE_PROPERTY_CALLBACK_ADDRESS, transferRequestMessage.getCallbackAddress())
.add(DSPACE_PROPERTY_CONSUMER_PID, transferRequestMessage.getConsumerPid())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.jetbrains.annotations.Nullable;

import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_FORMAT_ATTRIBUTE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DEPRECATED_DCT_FORMAT_ATTRIBUTE;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROCESS_ID;
Expand Down Expand Up @@ -54,7 +55,7 @@ public JsonObjectToTransferRequestMessageTransformer() {
visitProperties(messageObject, k -> switch (k) {
case DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID -> v -> builder.contractId(transformString(v, context));
case DSPACE_PROPERTY_CALLBACK_ADDRESS -> v -> builder.callbackAddress(transformString(v, context));
case DCT_FORMAT_ATTRIBUTE -> v -> builder.transferType(transformString(v, context));
case DCT_FORMAT_ATTRIBUTE, DEPRECATED_DCT_FORMAT_ATTRIBUTE -> v -> builder.transferType(transformString(v, context));
default -> doNothing();
});

Expand All @@ -67,7 +68,12 @@ public JsonObjectToTransferRequestMessageTransformer() {
private DataAddress createDataAddress(@NotNull JsonObject requestObject, @NotNull TransformerContext context) {
var dataAddressBuilder = DataAddress.Builder.newInstance();

transformString(requestObject.get(DCT_FORMAT_ATTRIBUTE), dataAddressBuilder::type, context);
var format = requestObject.get(DCT_FORMAT_ATTRIBUTE);
if (format != null) {
transformString(format, dataAddressBuilder::type, context);
} else {
transformString(requestObject.get(DEPRECATED_DCT_FORMAT_ATTRIBUTE), dataAddressBuilder::type, context);
}

var dataAddressObject = returnJsonObject(requestObject.get(DSPACE_PROPERTY_DATA_ADDRESS), context, DSPACE_PROPERTY_DATA_ADDRESS, false);
if (dataAddressObject != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_FORMAT_ATTRIBUTE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DEPRECATED_DCT_FORMAT_ATTRIBUTE;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_PROCESS_ID;
Expand Down Expand Up @@ -85,6 +86,7 @@ void transformTransferRequestMessageWithDataAddress() {
assertThat(result.getJsonString(JsonLdKeywords.TYPE).getString()).isEqualTo(DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE);
assertThat(result.getJsonString(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID).getString()).isEqualTo(contractId);
assertThat(result.getJsonString(DCT_FORMAT_ATTRIBUTE).getString()).isEqualTo(dataAddressType);
assertThat(result.getJsonString(DEPRECATED_DCT_FORMAT_ATTRIBUTE).getString()).isEqualTo(dataAddressType);
assertThat(result.getJsonString(DSPACE_PROPERTY_CALLBACK_ADDRESS).getString()).isEqualTo(callbackAddress);
assertThat(result.getJsonString(DSPACE_PROPERTY_PROCESS_ID).getString()).isEqualTo("processId");
assertThat(result.getJsonString(DSPACE_PROPERTY_CONSUMER_PID).getString()).isEqualTo("consumerPid");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DCT_FORMAT_ATTRIBUTE;
import static org.eclipse.edc.jsonld.spi.PropertyAndTypeNames.DEPRECATED_DCT_FORMAT_ATTRIBUTE;
import static org.eclipse.edc.protocol.dsp.transferprocess.transformer.to.TestInput.getExpanded;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CALLBACK_ADDRESS;
import static org.eclipse.edc.protocol.dsp.type.DspPropertyAndTypeNames.DSPACE_PROPERTY_CONSUMER_PID;
Expand Down Expand Up @@ -64,6 +65,7 @@ void jsonObjectToTransferRequestWithoutDataAddress() {

assertThat(result).isNotNull();
assertThat(result.getContractId()).isEqualTo(contractId);
assertThat(result.getTransferType()).isEqualTo(destinationType);
assertThat(result.getDataDestination().getType()).isEqualTo(destinationType);
assertThat(result.getCallbackAddress()).isEqualTo(callbackAddress);
assertThat(result.getConsumerPid()).isEqualTo("processId");
Expand All @@ -86,6 +88,7 @@ void jsonObjectToTransferRequestWithDataAddress() {

assertThat(result).isNotNull();
assertThat(result.getContractId()).isEqualTo(contractId);
assertThat(result.getTransferType()).isEqualTo(destinationType);
assertThat(result.getDataDestination().getType()).isEqualTo(destinationType);
assertThat(result.getCallbackAddress()).isEqualTo(callbackAddress);
assertThat(result.getDataDestination().getStringProperty("accessKeyId")).isEqualTo("TESTID");
Expand All @@ -94,6 +97,26 @@ void jsonObjectToTransferRequestWithDataAddress() {
verify(context, never()).reportProblem(anyString());
}

@Deprecated(since = "0.5.1")
@Test
void jsonObjectToTransferRequestWithDataAddress_withDeprecatedDctNamespace() {
var json = Json.createObjectBuilder()
.add(TYPE, DSPACE_TYPE_TRANSFER_REQUEST_MESSAGE)
.add(DSPACE_PROPERTY_CONTRACT_AGREEMENT_ID, contractId)
.add(DEPRECATED_DCT_FORMAT_ATTRIBUTE, destinationType)
.add(DSPACE_PROPERTY_DATA_ADDRESS, createDataAddress())
.add(DSPACE_PROPERTY_CALLBACK_ADDRESS, callbackAddress)
.add(DSPACE_PROPERTY_CONSUMER_PID, "processId")
.build();

var result = transformer.transform(getExpanded(json), context);

assertThat(result).isNotNull();
assertThat(result.getTransferType()).isEqualTo(destinationType);
assertThat(result.getDataDestination().getType()).isEqualTo(destinationType);
verify(context, never()).reportProblem(anyString());
}

@Test
void shouldReturnNullAndReportError_whenConsumerPidNotSet() {
when(context.problem()).thenReturn(new ProblemBuilder(context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ record CatalogSchema(
"dspace:participantId": "urn:connector:provider",
"@context": {
"@vocab": "https://w3id.org/edc/v0.0.1/ns/",
"dct": "https://purl.org/dc/terms/",
"dct": "http://purl.org/dc/terms/",
"edc": "https://w3id.org/edc/v0.0.1/ns/",
"dcat": "http://www.w3.org/ns/dcat#",
"odrl": "http://www.w3.org/ns/odrl/2/",
Expand Down Expand Up @@ -237,7 +237,7 @@ record DatasetSchema(
"id": "bcca61be-e82e-4da6-bfec-9716a56cef35",
"@context": {
"@vocab": "https://w3id.org/edc/v0.0.1/ns/",
"dct": "https://purl.org/dc/terms/",
"dct": "http://purl.org/dc/terms/",
"edc": "https://w3id.org/edc/v0.0.1/ns/",
"dcat": "http://www.w3.org/ns/dcat#",
"odrl": "http://www.w3.org/ns/odrl/2/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public interface Namespaces {
String DCAT_PREFIX = "dcat";
String DCAT_SCHEMA = "http://www.w3.org/ns/dcat#";


String DCT_PREFIX = "dct";
String DCT_SCHEMA = "https://purl.org/dc/terms/";
String DCT_SCHEMA = "http://purl.org/dc/terms/";

String DSPACE_PREFIX = "dspace";
String DSPACE_SCHEMA = "https://w3id.org/dspace/v0.8/"; // TODO to be defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public interface PropertyAndTypeNames {
String DCAT_ACCESS_SERVICE_ATTRIBUTE = DCAT_SCHEMA + "accessService";
String ODRL_POLICY_ATTRIBUTE = ODRL_SCHEMA + "hasPolicy";

@Deprecated(since = "0.5.1")
String DEPRECATED_DCT_FORMAT_ATTRIBUTE = "https://purl.org/dc/terms/format";
String DCT_FORMAT_ATTRIBUTE = DCT_SCHEMA + "format";
String DCT_TERMS_ATTRIBUTE = DCT_SCHEMA + "terms";
String DCT_ENDPOINT_URL_ATTRIBUTE = DCT_SCHEMA + "endpointUrl";
Expand Down
Loading