Skip to content

Commit

Permalink
avoid '/', use '-' instead
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Oct 25, 2024
1 parent d168f2d commit b906aae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public class TransferTypeParserImpl implements TransferTypeParser {

/**
* Parses a compose transfer type string into a {@link TransferType}:
* {@code DESTTYPE-{PUSH|PULL}(/RESPONSETYPE)}, for example {@code HttpData-PULL/Websocket}
* {@code DESTTYPE-{PUSH|PULL}(-RESPONSETYPE)}, for example {@code HttpData-PULL/Websocket}
*
* @param transferType the transfer type string representation.
* @return a {@link TransferType}
*/
@Override
public Result<TransferType> parse(String transferType) {
Optional<Result<TransferType>> parsed = Optional.ofNullable(transferType)
.map(type -> type.split("[-/]"))
.map(type -> type.split("-"))
.filter(tokens -> tokens.length >= 2)
.map(tokens -> parseFlowType(tokens[1]).map(flowType -> new TransferType(tokens[0], flowType, tokens.length > 2 ? tokens[2] : null)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void shouldReturnFatalError_whenFormatIsNotCorrect() {

@Test
void shouldParseReturnChannel() {
var result = parser.parse("DestinationType-PUSH/BackChannelType");
var result = parser.parse("DestinationType-PUSH-BackChannelType");
assertThat(result).isSucceeded().satisfies(type -> assertThat(type.responseChannelType()).isEqualTo("BackChannelType"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ The required changes to the Data Plane Framework to support bidirectional data t

The `DataAddress` in the `DataFlowResponseMessage` will contain properties symmetric to front channel HTTP endpoints:

- `https://w3id.org/edc/v0.0.1/ns/responseChannel/endpoint`: the URL
- `https://w3id.org/edc/v0.0.1/ns/responseChannel/endpoint`: the type of endpoint
- `https://w3id.org/edc/v0.0.1/ns/responseChannel/authorization`: the authorization token [optional]
- `https://w3id.org/edc/v0.0.1/ns/responseChannel/authType`: the type of auth token, e.g. `"bearer"` [optional]
- `https://w3id.org/edc/v0.0.1/ns/responseChannel-endpoint`: the URL
- `https://w3id.org/edc/v0.0.1/ns/responseChannel-endpoint`: the type of endpoint
- `https://w3id.org/edc/v0.0.1/ns/responseChannel-authorization`: the authorization token [optional]
- `https://w3id.org/edc/v0.0.1/ns/responseChannel-authType`: the type of auth token, e.g. `"bearer"` [optional]

These properties will be flattened into the original `DataAddress`, since `dspace:endpointProperty` fields are defined
as strings.
Expand All @@ -75,7 +75,7 @@ The `DataPlaneManagerImpl` and its collaborators will need to be refactored to g
channel `DataAddresses`:

- `DataPlaneManagerImpl` must be modified to return an EDR in the case of a provider PUSH. This EDR will only contain
`https://w3id.org/edc/v0.0.1/ns/responseChannel/*` entries. The manager will delegate to
`https://w3id.org/edc/v0.0.1/ns/responseChannel-*` entries. The manager will delegate to
`DataPlaneAuthorizationService`
to generate the response.
- `DataPlaneAuthorizationServiceImpl` must be enhanced to support `responseChannel` generation. This should be keyed off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ private Result<DataAddress.Builder> createDataAddress(TokenRepresentation tokenR
private Result<DataAddress.Builder> addResponseChannel(DataAddress.Builder builder, TokenRepresentation tokenRepresentation, Endpoint returnChannelEndpoint) {
var map = new HashMap<String, String>() {
{
put(EDC_NAMESPACE + "responseChannel/endpoint", returnChannelEndpoint.endpoint());
put(EDC_NAMESPACE + "responseChannel/endpointType", returnChannelEndpoint.endpointType());
put(EDC_NAMESPACE + "responseChannel/authorization", tokenRepresentation.getToken());
put(EDC_NAMESPACE + "responseChannel-endpoint", returnChannelEndpoint.endpoint());
put(EDC_NAMESPACE + "responseChannel-endpointType", returnChannelEndpoint.endpointType());
put(EDC_NAMESPACE + "responseChannel-authorization", tokenRepresentation.getToken());
}
};
tokenRepresentation.getAdditional().forEach((k, v) -> map.put(k.replace(EDC_NAMESPACE, EDC_NAMESPACE + "responseChannel/"), v.toString()));
tokenRepresentation.getAdditional().forEach((k, v) -> map.put(k.replace(EDC_NAMESPACE, EDC_NAMESPACE + "responseChannel-"), v.toString()));

map.forEach(builder::property);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ void startTransfer_pull_withBidirectional() throws JsonProcessingException {
assertThat(dataAddress.getStringProperty("endpoint")).isEqualTo(DATAPLANE_PUBLIC_ENDPOINT_URL);
assertThat(dataAddress.getStringProperty("authorization")).isNotNull();
assertThat(dataAddress.getStringProperty("authType")).isEqualTo("bearer");
assertThat(dataAddress.getStringProperty("responseChannel/endpoint")).isEqualTo(DATAPLANE_PUBLIC_ENDPOINT_URL + "/responseChannel");
assertThat(dataAddress.getStringProperty("responseChannel/endpointType")).isEqualTo("https://w3id.org/idsa/v4.1/HTTP");
assertThat(dataAddress.getStringProperty("responseChannel/authType")).isEqualTo("bearer");
assertThat(dataAddress.getStringProperty("responseChannel/authorization")).isNotNull();
assertThat(dataAddress.getStringProperty("responseChannel-endpoint")).isEqualTo(DATAPLANE_PUBLIC_ENDPOINT_URL + "/responseChannel");
assertThat(dataAddress.getStringProperty("responseChannel-endpointType")).isEqualTo("https://w3id.org/idsa/v4.1/HTTP");
assertThat(dataAddress.getStringProperty("responseChannel-authType")).isEqualTo("bearer");
assertThat(dataAddress.getStringProperty("responseChannel-authorization")).isNotNull();

// verify that the data flow was created
var store = runtime.getService(DataPlaneStore.class).findById(processId);
Expand Down Expand Up @@ -261,10 +261,10 @@ void startTransfer_push_withBidirectional() throws JsonProcessingException {
assertThat(dataAddress.getStringProperty("endpoint")).isEqualTo(DATAPLANE_PUBLIC_ENDPOINT_URL);
assertThat(dataAddress.getStringProperty("authorization")).isNotNull();
assertThat(dataAddress.getStringProperty("authType")).isEqualTo("bearer");
assertThat(dataAddress.getStringProperty("responseChannel/endpoint")).isEqualTo(DATAPLANE_PUBLIC_ENDPOINT_URL + "/responseChannel");
assertThat(dataAddress.getStringProperty("responseChannel/endpointType")).isEqualTo("https://w3id.org/idsa/v4.1/HTTP");
assertThat(dataAddress.getStringProperty("responseChannel/authType")).isEqualTo("bearer");
assertThat(dataAddress.getStringProperty("responseChannel/authorization")).isNotNull();
assertThat(dataAddress.getStringProperty("responseChannel-endpoint")).isEqualTo(DATAPLANE_PUBLIC_ENDPOINT_URL + "/responseChannel");
assertThat(dataAddress.getStringProperty("responseChannel-endpointType")).isEqualTo("https://w3id.org/idsa/v4.1/HTTP");
assertThat(dataAddress.getStringProperty("responseChannel-authType")).isEqualTo("bearer");
assertThat(dataAddress.getStringProperty("responseChannel-authorization")).isNotNull();

// verify that the data flow was created
var store = runtime.getService(DataPlaneStore.class).findById(processId);
Expand Down

0 comments on commit b906aae

Please sign in to comment.