Skip to content

Commit

Permalink
Merge branch '2024-10-02-eclipse-edc-0.7.2' of github.com:sovity/edc-…
Browse files Browse the repository at this point in the history
…extensions into 2024-10-02-eclipse-edc-0.7.2

# Conflicts:
#	extensions/policy-always-true/src/test/java/de/sovity/edc/extension/policy/AlwaysTruePolicyExtensionTest.java
#	extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/usecase/pages/catalog/UseCaseCatalogApiService.java
#	utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/junit/utils/InstancesForEachConnector.java
  • Loading branch information
richardtreier committed Oct 11, 2024
2 parents dc68f86 + 6078e97 commit c4564fc
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 37 deletions.
8 changes: 6 additions & 2 deletions docs/api/sovity-edc-api-wrapper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ paths:
description: Fetch a connector's data offers
operationId: getCatalogPageDataOffers
parameters:
- name: participantId
in: query
schema:
type: string
- name: connectorEndpoint
in: query
schema:
Expand Down Expand Up @@ -623,11 +627,11 @@ components:
DataSourceType:
type: string
description: Supported Data Source Types by UiDataSource
default: CUSTOM
enum:
- HTTP_DATA
- ON_REQUEST
- CUSTOM
default: CUSTOM
SecretValue:
type: object
properties:
Expand Down Expand Up @@ -835,14 +839,14 @@ components:
UiDataSourceHttpDataMethod:
type: string
description: Supported HTTP Methods by UiDataSource
default: GET
enum:
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
default: GET
UiDataSourceOnRequest:
required:
- contactEmail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import de.sovity.edc.extension.messenger.SovityMessengerRegistry;
import de.sovity.edc.utils.config.ConfigProps;
import lombok.val;
import org.eclipse.edc.connector.transfer.spi.observe.TransferProcessObservable;
import org.eclipse.edc.connector.controlplane.transfer.spi.observe.TransferProcessObservable;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.runtime.metamodel.annotation.Provides;
import org.eclipse.edc.spi.agent.ParticipantAgentService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ interface UiResource {
@Path("pages/catalog-page/data-offers")
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Fetch a connector's data offers")
List<UiDataOffer> getCatalogPageDataOffers(@QueryParam("connectorEndpoint") String connectorEndpoint);
// TODO: request it from the UI or add a workaround here?
List<UiDataOffer> getCatalogPageDataOffers(@QueryParam("participantId") String participantId, @QueryParam("connectorEndpoint") String connectorEndpoint);

@POST
@Path("pages/catalog-page/contract-negotiations")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import de.sovity.edc.extension.contacttermination.ContractAgreementTerminationService;
import de.sovity.edc.extension.db.directaccess.DslContextFactory;
import org.eclipse.edc.connector.api.management.configuration.ManagementApiConfiguration;
import org.eclipse.edc.connector.api.management.configuration.transform.ManagementApiTypeTransformerRegistry;
import org.eclipse.edc.connector.controlplane.contract.spi.negotiation.store.ContractNegotiationStore;
import org.eclipse.edc.connector.controlplane.contract.spi.offer.store.ContractDefinitionStore;
import org.eclipse.edc.connector.controlplane.policy.spi.store.PolicyDefinitionStore;
Expand All @@ -34,14 +32,14 @@
import org.eclipse.edc.connector.controlplane.transfer.spi.store.TransferProcessStore;
import org.eclipse.edc.jsonld.spi.JsonLd;
import org.eclipse.edc.policy.engine.spi.PolicyEngine;
import org.eclipse.edc.protocol.dsp.api.configuration.DspApiConfiguration;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.CoreConstants;
import org.eclipse.edc.spi.constants.CoreConstants;
import org.eclipse.edc.connector.controlplane.asset.spi.index.AssetIndex;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.spi.types.TypeManager;
import org.eclipse.edc.web.spi.WebService;
import org.eclipse.edc.web.spi.configuration.ApiContext;

public class WrapperExtension implements ServiceExtension {

Expand All @@ -66,10 +64,6 @@ public class WrapperExtension implements ServiceExtension {
@Inject
private DslContextFactory dslContextFactory;
@Inject
private DspApiConfiguration dspApiConfiguration;
@Inject
private ManagementApiConfiguration dataManagementApiConfiguration;
@Inject
private PolicyDefinitionStore policyDefinitionStore;
@Inject
private PolicyEngine policyEngine;
Expand All @@ -79,8 +73,9 @@ public class WrapperExtension implements ServiceExtension {
private TransferProcessStore transferProcessStore;
@Inject
private TypeManager typeManager;
@Inject
private ManagementApiTypeTransformerRegistry typeTransformerRegistry;
// TODO: was revomed, maybe replaced with ManagementApiTypeTransformerRegistryImpl between v0.5.1..v0.6.0
// @Inject
// private ManagementApiTypeTransformerRegistry typeTransformerRegistry;
@Inject
private WebService webService;
@Inject
Expand Down Expand Up @@ -120,14 +115,15 @@ public void initialize(ServiceExtensionContext context) {
policyEngine,
transferProcessService,
transferProcessStore,
typeTransformerRegistry
// TODO: what is the new value? is it necessary?
null
);

wrapperExtensionContext.managementApiResources().forEach(resource ->
webService.registerResource(dataManagementApiConfiguration.getContextAlias(), resource));
webService.registerResource(ApiContext.MANAGEMENT, resource));

wrapperExtensionContext.dspApiResources().forEach(resource ->
webService.registerResource(dspApiConfiguration.getContextAlias(), resource));
webService.registerResource(ApiContext.PROTOCOL, resource));
}

private void fixObjectMapperDateSerialization(ObjectMapper objectMapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@
package de.sovity.edc.ext.wrapper.api;

import jakarta.ws.rs.WebApplicationException;
import org.eclipse.edc.service.spi.result.ServiceResult;
import org.eclipse.edc.spi.result.Failure;

import java.util.function.Function;

/**
* Exception for handling {@link ServiceResult} {@link Failure}s.
*
* @see ServiceResult#orElseThrow(Function)
*/
public class ServiceException extends WebApplicationException {
public ServiceException(Failure failure) {
super(failure.getFailureDetail(), 500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public IdResponseDto createDataOffer(DataOfferCreationRequest dataOfferCreationR
}

@Override
public List<UiDataOffer> getCatalogPageDataOffers(String connectorEndpoint) {
return catalogApiService.fetchDataOffers(connectorEndpoint);
public List<UiDataOffer> getCatalogPageDataOffers(String participantId, String connectorEndpoint) {
return catalogApiService.fetchDataOffers(participantId, connectorEndpoint);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public IdResponseDto editAsset(String assetId, UiAssetEditRequest request) {
Objects.requireNonNull(foundAsset, "Asset with ID %s not found".formatted(assetId));
val editedAsset = assetMapper.editAsset(foundAsset, request);
val updatedAsset = assetService.update(editedAsset).orElseThrow(ServiceException::new);
assetService.update(editedAsset.getId(), editedAsset.getDataAddress());
assetService.update(editedAsset);
return new IdResponseDto(updatedAsset.getId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class CatalogApiService {
private final UiDataOfferBuilder uiDataOfferBuilder;
private final DspCatalogService dspCatalogService;

public List<UiDataOffer> fetchDataOffers(String connectorEndpoint) {
var dspCatalog = dspCatalogService.fetchDataOffers(connectorEndpoint);
public List<UiDataOffer> fetchDataOffers(String participantId, String connectorEndpoint) {
var dspCatalog = dspCatalogService.fetchDataOffers(participantId, connectorEndpoint);
return uiDataOfferBuilder.buildUiDataOffers(dspCatalog);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.HashMap;
import java.util.Map;

import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE;
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE;

public class ParameterizationCompatibilityUtils {
private static final String WORKAROUND = "https://sovity.de/workaround/proxy/param/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public ContractRequest buildContractNegotiation(ContractNegotiationRequest reque

return ContractRequest.Builder.newInstance()
.counterPartyAddress(counterPartyAddress)
.providerId(request.getCounterPartyParticipantId())
// TODO: deprecated and moved into the contractOffer.policy.assigner, set by `.contractOffer()` below
// git diff v0.5.1..v0.6.0 -- spi/control-plane/contract-spi/src/main/java/org/eclipse/edc/connector/contract/spi/types/negotiation/ContractRequest.java
// .providerId(request.getCounterPartyParticipantId())
.protocol(HttpMessageProtocol.DATASPACE_PROTOCOL_HTTP)
.contractOffer(contractOfferMapper.buildContractOffer(request))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public class UseCaseCatalogApiService {
public List<UiDataOffer> fetchDataOffers(CatalogQuery catalogQuery) {
var querySpec = buildQuerySpec(catalogQuery);

var dspCatalog = dspCatalogService.fetchDataOffersWithFilters(catalogQuery.getConnectorEndpoint(), "TODO", querySpec);
var dspCatalog = dspCatalogService.fetchDataOffersWithFilters(
catalogQuery.getParticipantId(),
catalogQuery.getConnectorEndpoint(),
querySpec);
return uiDataOfferBuilder.buildUiDataOffers(dspCatalog);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@

class DspCatalogServiceTest {
String endpoint = "http://localhost:11003/api/v1/dsp";
String participantId = "someParticipantId";

private DspCatalogService newDspCatalogService(String resultJsonFilename) {
var catalogJson = readFile(resultJsonFilename);
var catalogService = mock(CatalogService.class);

var result = CompletableFuture.completedFuture(StatusResult.success(catalogJson.getBytes(StandardCharsets.UTF_8)));
when(catalogService.requestCatalog(eq(endpoint), eq("dataspace-protocol-http"), eq(QuerySpec.max()))).thenReturn(result);
when(catalogService.requestCatalog(
eq(participantId),
eq(endpoint),
eq("dataspace-protocol-http"),
eq(QuerySpec.max()))
).thenReturn(result);

var monitor = mock(Monitor.class);
var dataOfferBuilder = new DspDataOfferBuilder(new TitaniumJsonLd(monitor));

Expand All @@ -57,7 +64,7 @@ void testCatalogMapping() {
var dspCatalogService = newDspCatalogService("catalogResponse.json");

// act
var actual = dspCatalogService.fetchDataOffers(endpoint);
var actual = dspCatalogService.fetchDataOffers(participantId, endpoint);

// assert
var offers = actual.getDataOffers();
Expand All @@ -66,7 +73,7 @@ void testCatalogMapping() {
assertThat(actual.getEndpoint()).isEqualTo(endpoint);
assertThat(actual.getParticipantId()).isEqualTo("provider");
assertThat(JsonLdUtils.id(offer.getAssetPropertiesJsonLd()))
.isEqualTo("test-1.0");
.isEqualTo("test-1.0");
assertThat(offer.getAssetPropertiesJsonLd().get(Prop.TYPE)).isNull();
assertThat(JsonLdUtils.string(offer.getAssetPropertiesJsonLd(), Prop.Dcat.VERSION)).isEqualTo("1.0");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public IdResponseDto createContractDefinition(String policyId, String assetId) {
public UiContractNegotiation negotiateAssetAndAwait(String assetId) {
val connectorEndpoint = config.getProviderProtocolApiUrl();
val participantId = config.getProviderParticipantId();
val offers = consumerClient.uiApi().getCatalogPageDataOffers(connectorEndpoint);
val offers = consumerClient.uiApi().getCatalogPageDataOffers(participantId, connectorEndpoint);

val offersContainingContract = offers.stream()
.filter(offer -> offer.getAsset().getAssetId().equals(assetId))
Expand Down

0 comments on commit c4564fc

Please sign in to comment.