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

chore: Remove unused references and dead code #3707

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import jakarta.json.JsonObject;
import okhttp3.Response;
import org.eclipse.edc.catalog.spi.CatalogRequestMessage;
import org.eclipse.edc.protocol.dsp.spi.dispatcher.DspHttpDispatcherDelegate;
import org.eclipse.edc.spi.EdcException;

Expand All @@ -27,7 +26,7 @@
* Delegate for dispatching catalog requests as defined in the
* <a href="https://docs.internationaldataspaces.org/dataspace-protocol/catalog/catalog.binding.https">dataspace protocol specification</a>
*/
public class CatalogRequestHttpRawDelegate extends DspHttpDispatcherDelegate<CatalogRequestMessage, byte[]> {
public class CatalogRequestHttpRawDelegate extends DspHttpDispatcherDelegate<byte[]> {

public CatalogRequestHttpRawDelegate() {
super();
Expand All @@ -43,6 +42,7 @@ public CatalogRequestHttpRawDelegate() {
public Function<Response, byte[]> parseResponse() {
return response -> {
try {
assert response.body() != null;
return response.body().bytes();

} catch (NullPointerException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import jakarta.json.JsonObject;
import okhttp3.Response;
import org.eclipse.edc.catalog.spi.DatasetRequestMessage;
import org.eclipse.edc.protocol.dsp.spi.dispatcher.DspHttpDispatcherDelegate;
import org.eclipse.edc.spi.EdcException;

Expand All @@ -27,7 +26,7 @@
* Delegate for dispatching catalog requests as defined in the
* <a href="https://docs.internationaldataspaces.org/dataspace-protocol/catalog/catalog.binding.https">dataspace protocol specification</a>
*/
public class DatasetRequestHttpRawDelegate extends DspHttpDispatcherDelegate<DatasetRequestMessage, byte[]> {
public class DatasetRequestHttpRawDelegate extends DspHttpDispatcherDelegate<byte[]> {

public DatasetRequestHttpRawDelegate() {
super();
Expand All @@ -43,6 +42,7 @@ public DatasetRequestHttpRawDelegate() {
public Function<Response, byte[]> parseResponse() {
return response -> {
try {
assert response.body() != null;
jimmarino marked this conversation as resolved.
Show resolved Hide resolved
return response.body().bytes();

} catch (NullPointerException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void parseResponse_responseBodyNull_throwException() {
}

@Override
protected DspHttpDispatcherDelegate<CatalogRequestMessage, ?> delegate() {
protected DspHttpDispatcherDelegate<?> delegate() {
return delegate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void parseResponse_responseBodyNull_throwException() {
}

@Override
protected DspHttpDispatcherDelegate<DatasetRequestMessage, ?> delegate() {
protected DspHttpDispatcherDelegate<?> delegate() {
return delegate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public <M extends RemoteMessage> void registerPolicyScope(Class<M> messageClass,
}

@Override
public <M extends RemoteMessage, R> void registerMessage(Class<M> clazz, DspHttpRequestFactory<M> requestFactory, DspHttpDispatcherDelegate<M, R> delegate) {
public <M extends RemoteMessage, R> void registerMessage(Class<M> clazz, DspHttpRequestFactory<M> requestFactory, DspHttpDispatcherDelegate<R> delegate) {
handlers.put(clazz, new Handlers<>(requestFactory, delegate));
}

private record Handlers<M extends RemoteMessage, R>(DspHttpRequestFactory<M> requestFactory, DspHttpDispatcherDelegate<M, R> delegate) { }
private record Handlers<M extends RemoteMessage, R>(DspHttpRequestFactory<M> requestFactory, DspHttpDispatcherDelegate<R> delegate) { }

private record PolicyScope<M extends RemoteMessage>(Class<M> messageClass, String scope, Function<M, Policy> policyProvider) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class DspHttpRemoteMessageDispatcherImplTest {
private final PolicyEngine policyEngine = mock();
private final TokenDecorator tokenDecorator = mock();
private final DspHttpRequestFactory<TestMessage> requestFactory = mock();
private final DspHttpDispatcherDelegate<TestMessage, String> delegate = mock();
private final DspHttpDispatcherDelegate<String> delegate = mock();
private final Duration timeout = Duration.of(5, SECONDS);

private DspHttpRemoteMessageDispatcher dispatcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
/**
* Delegate for sending a specific type of {@link RemoteMessage} using the dataspace protocol.
*
* @param <M> the type of message
* @param <R> the response type
*/
public abstract class DspHttpDispatcherDelegate<M extends RemoteMessage, R> {
public abstract class DspHttpDispatcherDelegate<R> {

protected DspHttpDispatcherDelegate() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface DspHttpRemoteMessageDispatcher extends RemoteMessageDispatcher
* @param <M> the type of message
* @param <R> the response type
*/
<M extends RemoteMessage, R> void registerMessage(Class<M> clazz, DspHttpRequestFactory<M> requestFactory, DspHttpDispatcherDelegate<M, R> delegate);
<M extends RemoteMessage, R> void registerMessage(Class<M> clazz, DspHttpRequestFactory<M> requestFactory, DspHttpDispatcherDelegate<R> delegate);

/**
* Registers a {@link Policy} scope to be evaluated for certain types of messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ public Response from(ServiceFailure failure) {
return internalBuild(code, failure.getMessages());
}

public Response unauthorized() {
return internalBuild(Response.Status.UNAUTHORIZED, List.of("Token validation failed."));
}

public Response badRequest() {
return internalBuild(Response.Status.BAD_REQUEST, List.of("Bad request."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import okhttp3.ResponseBody;
import org.eclipse.edc.protocol.dsp.spi.serialization.JsonLdRemoteMessageSerializer;
import org.eclipse.edc.spi.response.ResponseFailure;
import org.eclipse.edc.spi.types.domain.message.RemoteMessage;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -88,7 +87,7 @@ void handleResponse_shouldReturnRetryError_whenResponseIsServerError() {
verifyNoInteractions(parser);
}

private class TestDspHttpDispatcherDelegate extends DspHttpDispatcherDelegate<RemoteMessage, Object> {
private class TestDspHttpDispatcherDelegate extends DspHttpDispatcherDelegate<Object> {

TestDspHttpDispatcherDelegate() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public abstract class DspHttpDispatcherDelegateTestBase<M extends RemoteMessage>
*
* @return the delegate
*/
protected abstract DspHttpDispatcherDelegate<M, ?> delegate();
protected abstract DspHttpDispatcherDelegate<?> delegate();

/**
* Checks that a delegate throws an exception when the response body is missing. Only relevant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ public void initialize(ServiceExtensionContext context) {
messageDispatcher.registerMessage(
ContractAgreementMessage.class,
new PostDspHttpRequestFactory<>(remoteMessageSerializer, m -> BASE_PATH + m.getProcessId() + AGREEMENT),
new ContractAgreementMessageHttpDelegate(remoteMessageSerializer)
new ContractAgreementMessageHttpDelegate()
);
messageDispatcher.registerMessage(
ContractAgreementVerificationMessage.class,
new PostDspHttpRequestFactory<>(remoteMessageSerializer, m -> BASE_PATH + m.getProcessId() + AGREEMENT + VERIFICATION),
new ContractAgreementVerificationMessageHttpDelegate(remoteMessageSerializer)
new ContractAgreementVerificationMessageHttpDelegate()
);
messageDispatcher.registerMessage(
ContractNegotiationEventMessage.class,
new PostDspHttpRequestFactory<>(remoteMessageSerializer, m -> BASE_PATH + m.getProcessId() + EVENT),
new ContractNegotiationEventMessageHttpDelegate(remoteMessageSerializer)
new ContractNegotiationEventMessageHttpDelegate()
);
messageDispatcher.registerMessage(
ContractNegotiationTerminationMessage.class,
new PostDspHttpRequestFactory<>(remoteMessageSerializer, m -> BASE_PATH + m.getProcessId() + TERMINATION),
new ContractNegotiationTerminationMessageHttpDelegate(remoteMessageSerializer)
new ContractNegotiationTerminationMessageHttpDelegate()
);
messageDispatcher.registerMessage(
ContractRequestMessage.class,
Expand All @@ -96,12 +96,12 @@ public void initialize(ServiceExtensionContext context) {
return BASE_PATH + m.getProcessId() + CONTRACT_REQUEST;
}
}),
new ContractRequestMessageHttpDelegate(remoteMessageSerializer, typeManager.getMapper(JSON_LD), jsonLdService)
new ContractRequestMessageHttpDelegate(typeManager.getMapper(JSON_LD), jsonLdService)
);
messageDispatcher.registerMessage(
ContractOfferMessage.class,
new PostDspHttpRequestFactory<>(remoteMessageSerializer, m -> BASE_PATH + m.getProcessId() + CONTRACT_OFFER),
new ContractOfferMessageHttpDelegate(remoteMessageSerializer)
new ContractOfferMessageHttpDelegate()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
package org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate;

import okhttp3.Response;
import org.eclipse.edc.connector.contract.spi.types.agreement.ContractAgreementMessage;
import org.eclipse.edc.protocol.dsp.spi.dispatcher.DspHttpDispatcherDelegate;
import org.eclipse.edc.protocol.dsp.spi.serialization.JsonLdRemoteMessageSerializer;

import java.util.function.Function;

/**
* Delegate for dispatching contract agreement message as defined in the dataspace protocol specification.
*/
public class ContractAgreementMessageHttpDelegate extends DspHttpDispatcherDelegate<ContractAgreementMessage, Object> {
public class ContractAgreementMessageHttpDelegate extends DspHttpDispatcherDelegate<Object> {

public ContractAgreementMessageHttpDelegate(JsonLdRemoteMessageSerializer serializer) {
public ContractAgreementMessageHttpDelegate() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
package org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate;

import okhttp3.Response;
import org.eclipse.edc.connector.contract.spi.types.agreement.ContractAgreementVerificationMessage;
import org.eclipse.edc.protocol.dsp.spi.dispatcher.DspHttpDispatcherDelegate;
import org.eclipse.edc.protocol.dsp.spi.serialization.JsonLdRemoteMessageSerializer;

import java.util.function.Function;

/**
* Delegate for dispatching contract agreement verification message as defined in the dataspace protocol specification.
*/
public class ContractAgreementVerificationMessageHttpDelegate extends DspHttpDispatcherDelegate<ContractAgreementVerificationMessage, Object> {
public class ContractAgreementVerificationMessageHttpDelegate extends DspHttpDispatcherDelegate<Object> {

public ContractAgreementVerificationMessageHttpDelegate(JsonLdRemoteMessageSerializer serializer) {
public ContractAgreementVerificationMessageHttpDelegate() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
package org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate;

import okhttp3.Response;
import org.eclipse.edc.connector.contract.spi.types.agreement.ContractNegotiationEventMessage;
import org.eclipse.edc.protocol.dsp.spi.dispatcher.DspHttpDispatcherDelegate;
import org.eclipse.edc.protocol.dsp.spi.serialization.JsonLdRemoteMessageSerializer;

import java.util.function.Function;

/**
* Delegate for dispatching contract negotiation event message as defined in the dataspace protocol specification.
*/
public class ContractNegotiationEventMessageHttpDelegate extends DspHttpDispatcherDelegate<ContractNegotiationEventMessage, Object> {
public class ContractNegotiationEventMessageHttpDelegate extends DspHttpDispatcherDelegate<Object> {

public ContractNegotiationEventMessageHttpDelegate(JsonLdRemoteMessageSerializer serializer) {
public ContractNegotiationEventMessageHttpDelegate() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
package org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate;

import okhttp3.Response;
import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiationTerminationMessage;
import org.eclipse.edc.protocol.dsp.spi.dispatcher.DspHttpDispatcherDelegate;
import org.eclipse.edc.protocol.dsp.spi.serialization.JsonLdRemoteMessageSerializer;

import java.util.function.Function;

/**
* Delegate for dispatching contract negotiation termination message as defined in the dataspace protocol specification.
*/
public class ContractNegotiationTerminationMessageHttpDelegate extends DspHttpDispatcherDelegate<ContractNegotiationTerminationMessage, Object> {
public class ContractNegotiationTerminationMessageHttpDelegate extends DspHttpDispatcherDelegate<Object> {

public ContractNegotiationTerminationMessageHttpDelegate(JsonLdRemoteMessageSerializer serializer) {
public ContractNegotiationTerminationMessageHttpDelegate() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
package org.eclipse.edc.protocol.dsp.negotiation.dispatcher.delegate;

import okhttp3.Response;
import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractOfferMessage;
import org.eclipse.edc.protocol.dsp.spi.dispatcher.DspHttpDispatcherDelegate;
import org.eclipse.edc.protocol.dsp.spi.serialization.JsonLdRemoteMessageSerializer;

import java.util.function.Function;

/**
* Delegate for dispatching contract offer message as defined in the dataspace protocol specification.
*/
public class ContractOfferMessageHttpDelegate extends DspHttpDispatcherDelegate<ContractOfferMessage, Object> {
public ContractOfferMessageHttpDelegate(JsonLdRemoteMessageSerializer serializer) {
public class ContractOfferMessageHttpDelegate extends DspHttpDispatcherDelegate<Object> {

public ContractOfferMessageHttpDelegate() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.json.JsonObject;
import okhttp3.Response;
import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractRequestMessage;
import org.eclipse.edc.jsonld.spi.JsonLd;
import org.eclipse.edc.protocol.dsp.spi.dispatcher.DspHttpDispatcherDelegate;
import org.eclipse.edc.protocol.dsp.spi.serialization.JsonLdRemoteMessageSerializer;
import org.eclipse.edc.spi.EdcException;

import java.io.IOException;
Expand All @@ -29,13 +27,13 @@
/**
* Delegate for dispatching contract request message as defined in the dataspace protocol specification.
*/
public class ContractRequestMessageHttpDelegate extends DspHttpDispatcherDelegate<ContractRequestMessage, Object> {
public class ContractRequestMessageHttpDelegate extends DspHttpDispatcherDelegate<Object> {

private final ObjectMapper mapper;
private final JsonLd jsonLdService;


public ContractRequestMessageHttpDelegate(JsonLdRemoteMessageSerializer serializer, ObjectMapper mapper, JsonLd jsonLdService) {
public ContractRequestMessageHttpDelegate(ObjectMapper mapper, JsonLd jsonLdService) {
super();
this.mapper = mapper;
this.jsonLdService = jsonLdService;
Expand All @@ -45,6 +43,7 @@ public ContractRequestMessageHttpDelegate(JsonLdRemoteMessageSerializer serializ
public Function<Response, Object> parseResponse() {
return response -> {
try {
assert response.body() != null;
var jsonObject = mapper.readValue(response.body().bytes(), JsonObject.class);
return jsonLdService.expand(jsonObject).map(jo -> jo).orElseThrow(failure -> new EdcException(failure.getFailureDetail()));
} catch (NullPointerException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ContractAgreementMessageHttpDelegateTest extends DspHttpDispatcherDelegate

@BeforeEach
void setUp() {
delegate = new ContractAgreementMessageHttpDelegate(serializer);
delegate = new ContractAgreementMessageHttpDelegate();
}

@Test
Expand All @@ -35,7 +35,7 @@ void parseResponse_returnNull() {
}

@Override
protected DspHttpDispatcherDelegate<ContractAgreementMessage, ?> delegate() {
protected DspHttpDispatcherDelegate<?> delegate() {
return delegate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import org.junit.jupiter.api.Test;

class ContractAgreementVerificationMessageHttpDelegateTest extends DspHttpDispatcherDelegateTestBase<ContractAgreementVerificationMessage> {

private ContractAgreementVerificationMessageHttpDelegate delegate;

@BeforeEach
void setUp() {
delegate = new ContractAgreementVerificationMessageHttpDelegate(serializer);
delegate = new ContractAgreementVerificationMessageHttpDelegate();
}

@Test
Expand All @@ -35,7 +35,7 @@ void parseResponse_returnNull() {
}

@Override
protected DspHttpDispatcherDelegate<ContractAgreementVerificationMessage, ?> delegate() {
protected DspHttpDispatcherDelegate<?> delegate() {
return delegate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import org.junit.jupiter.api.Test;

class ContractNegotiationEventMessageHttpDelegateTest extends DspHttpDispatcherDelegateTestBase<ContractNegotiationEventMessage> {

private ContractNegotiationEventMessageHttpDelegate delegate;

@BeforeEach
void setUp() {
delegate = new ContractNegotiationEventMessageHttpDelegate(serializer);
delegate = new ContractNegotiationEventMessageHttpDelegate();
}

@Test
Expand All @@ -35,7 +35,7 @@ void parseResponse_returnNull() {
}

@Override
protected DspHttpDispatcherDelegate<ContractNegotiationEventMessage, ?> delegate() {
protected DspHttpDispatcherDelegate<?> delegate() {
return delegate;
}
}