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

Feat/setting up transfer history page model #355

Closed
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
16637e1
feat: reworking lastcommitinfo extension
AnurosePrakash May 2, 2023
b46c712
chore: refactor
AnurosePrakash May 5, 2023
bf44f8d
Merge branch 'main' into feat/rework_lastcommitinfo_extension
AnurosePrakash May 5, 2023
cefe67b
feat: adding last build date values of edc env and jar to the last co…
AnurosePrakash May 8, 2023
56c82f0
feat oauth2 client credentials auth flow (Java API Wrapper Client Lib…
richardtreier May 5, 2023
893e301
build(deps): bump io.quarkus from 2.16.6.Final to 3.0.2.Final (#314)
dependabot[bot] May 8, 2023
b876961
Merge remote-tracking branch 'origin/main'
AnurosePrakash May 8, 2023
e6b8ee9
chore refactor
AnurosePrakash May 9, 2023
27b4c40
chore refactor
AnurosePrakash May 9, 2023
5ff92ec
chore refactor
AnurosePrakash May 9, 2023
be4f787
Merge remote-tracking branch 'origin/main'
AnurosePrakash May 14, 2023
e1cfd19
Merge branch 'main' into feat/rework_lastcommitinfo_extension
SebastianOpriel May 16, 2023
46601b9
Merge remote-tracking branch 'origin/main'
AnurosePrakash May 25, 2023
8b49936
feat: Adding Transfer History Page Model(WIP)
AnurosePrakash May 26, 2023
1a7606c
feat: Adding Transfer History Page Model
AnurosePrakash May 30, 2023
b65ef8d
build(deps): bump org.projectlombok:lombok from 1.18.26 to 1.18.28 (#…
dependabot[bot] May 30, 2023
51c3410
Merge remote-tracking branch 'origin/main'
AnurosePrakash May 30, 2023
17ee012
Merge branch 'main' into feat/rework_lastcommitinfo_extension
AnurosePrakash May 30, 2023
a875802
Merge remote-tracking branch 'origin/feat/rework_lastcommitinfo_exten…
AnurosePrakash May 30, 2023
fee26c5
feat: updated data model of transfer
AnurosePrakash May 31, 2023
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
3 changes: 3 additions & 0 deletions extensions/last-commit-info/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ plugins {
}

dependencies {
annotationProcessor("org.projectlombok:lombok:1.18.26")
compileOnly("org.projectlombok:lombok:1.18.26")

api("${edcGroup}:core-spi:${edcVersion}")
api("${edcGroup}:control-plane-spi:${edcVersion}")
implementation("${edcGroup}:api-core:${edcVersion}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2022 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*
*/

package de.sovity.edc.extension;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class LastCommitInfo {

private String envLastCommitInfo;
private String envLastBuildDate;
private String jarLastCommitInfo;
private String jarLastBuildDate;


}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import java.io.IOException;

@Produces({MediaType.APPLICATION_JSON})
@Path("/last-commit-info")
public class LastCommitInfoController {
Expand All @@ -29,7 +31,8 @@ public LastCommitInfoController(LastCommitInfoService lastCommitInfoService) {
}

@GET
public String getLastCommitInfo() {
@Produces(MediaType.APPLICATION_JSON)
public LastCommitInfo getLastCommitInfo() throws IOException {
return lastCommitInfoService.getLastCommitInfo();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,56 @@

import org.eclipse.edc.spi.system.ServiceExtensionContext;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;
import java.util.jar.Attributes;
import java.util.jar.Manifest;

public class LastCommitInfoService {

private final ServiceExtensionContext context;


public LastCommitInfoService(ServiceExtensionContext context) {
this.context = context;
}

public String getLastCommitInfo() {
var result = "";

if (!getEnvLastCommitInfo().equals("")) {
result += "Env Last Commit Info: \n";
result += getEnvLastCommitInfo() + "\n";
}

if (!getEnvLastCommitInfo().equals(getJarLastCommitInfo())) {
result += "Jar Last Commit Info: \n";
result += getJarLastCommitInfo();
}
public LastCommitInfo getLastCommitInfo() throws IOException {
var result = new LastCommitInfo();
result.setEnvLastCommitInfo(getEnvLastCommitInfo());
result.setEnvLastBuildDate(getEnvLastCommitDate());

result.setJarLastCommitInfo(getJarInfo().get(0));
result.setJarLastBuildDate(getJarInfo().get(1));
return result;
}

public String getJarLastCommitInfo() {
public List<String> getJarInfo() throws IOException {

var jarInfo = new ArrayList<String>();
var classLoader = Thread.currentThread().getContextClassLoader();
var is = classLoader.getResourceAsStream("jar-last-commit-info.txt");
var scanner = new Scanner(Objects.requireNonNull(is), StandardCharsets.UTF_8).useDelimiter("\\A");
return scanner.hasNext() ? scanner.next() : "";
jarInfo.add(scanner.hasNext() ? scanner.next() : "");

Manifest manifest = new Manifest(is);
Attributes attributes = manifest.getMainAttributes();
jarInfo.add(attributes.getValue("Build-Date"));

return jarInfo;
}

public String getEnvLastCommitInfo() {
return context.getSetting("edc.last.commit.info", "");
}

public String getEnvLastCommitDate() {
return context.getSetting("edc.env.last.commit.date", "");
}


}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2023 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*
*/

package de.sovity.edc.extension.version.controller;

import io.restassured.http.ContentType;
import org.eclipse.edc.junit.annotations.ApiTest;
import org.eclipse.edc.junit.extensions.EdcExtension;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.util.Map;

import static io.restassured.RestAssured.given;
import static org.eclipse.edc.junit.testfixtures.TestUtils.getFreePort;
import static org.hamcrest.Matchers.equalTo;

@ApiTest
@ExtendWith(EdcExtension.class)
class LastCommitInfoTest {

@BeforeEach
void setUp(EdcExtension extension) {
extension.setConfiguration(Map.of(
"web.http.port", String.valueOf(getFreePort()),
"web.http.path", "/api",
"web.http.management.port", String.valueOf(TestUtils.DATA_PORT),
"web.http.management.path", "/api/v1/data",
"edc.api.auth.key", TestUtils.AUTH_KEY,
"edc.last.commit.info", "test env commit message",
"edc.env.last.commit.date", "2023-05-08T15:30:00Z"));
}

@Test
void testEnvAndJar() {
var request = given()
.baseUri("http://localhost:" + TestUtils.DATA_PORT)
.basePath("/api/v1/data")
.header("x-api-key", TestUtils.AUTH_KEY)
.when()
.contentType(ContentType.JSON)
.get("/last-commit-info")
.then()
.statusCode(200)
.contentType(ContentType.JSON);

request.assertThat().body("envLastCommitInfo", equalTo("test env commit message"))
.body("envLastBuildDate", equalTo("2023-05-08T15:30:00Z"))
.body("jarLastCommitInfo", equalTo("test jar commit message\n"));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,12 @@

package de.sovity.edc.extension.version.controller;

import io.restassured.http.ContentType;
import io.restassured.response.ValidatableResponse;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

import static io.restassured.RestAssured.given;
import static org.eclipse.edc.junit.testfixtures.TestUtils.getFreePort;

public class TestUtils {

private static final int DATA_PORT = getFreePort();
private static final String AUTH_KEY = "123456";

@NotNull
static Map<String, String> createConfiguration(String commitInfo) {
return Map.of(
"web.http.port", String.valueOf(getFreePort()),
"web.http.path", "/api",
"web.http.management.port", String.valueOf(DATA_PORT),
"web.http.management.path", "/api/v1/data",
"edc.api.auth.key", AUTH_KEY,
"edc.last.commit.info", commitInfo);
}
public static final int DATA_PORT = getFreePort();
public static final String AUTH_KEY = "123456";

static ValidatableResponse mockRequest() {
return given()
.baseUri("http://localhost:" + DATA_PORT)
.basePath("/api/v1/data")
.header("x-api-key", AUTH_KEY)
.when()
.contentType(ContentType.TEXT)
.get(String.format("/last-commit-info"))
.then()
.statusCode(200)
.contentType(ContentType.JSON);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test jar commit message
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package de.sovity.edc.ext.wrapper.api.ui.model;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
@Schema(description = "Data Destination Properties of Data Transfer")
public class DataDestinationProperties {

@Schema(description = "Base Url", requiredMode = Schema.RequiredMode.REQUIRED)
private String baseUrl;

@Schema(description = "EDC Receiver HTTP Dynamic Auth Code", requiredMode = Schema.RequiredMode.REQUIRED)
private String edcReceiverHttpDynamicAuthCode;

@Schema(description = "EDC Receiver HTTP Dynamic Endpoint", requiredMode = Schema.RequiredMode.REQUIRED)
private String edcReceiverHttpDynamicEndpoint;

@Schema(description = "EDC Receiver HTTP Dynamic Auth Key", requiredMode = Schema.RequiredMode.REQUIRED)
private String edcReceiverHttpDynamicAuthKey;

@Schema(description = "Method Name", requiredMode = Schema.RequiredMode.REQUIRED)
private String method;

@Schema(description = "EDC Receiver HTTP Endpoint", requiredMode = Schema.RequiredMode.REQUIRED)
private String receiverHttpEndpoint;

@Schema(description = "Method Type", requiredMode = Schema.RequiredMode.REQUIRED)
private String type;

}
Loading