diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 09c0b238f..eea160dd1 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -38,7 +38,8 @@ jobs:
run: |-
[ ! -d "edc" ] && git submodule add https://github.com/eclipse-dataspaceconnector/DataSpaceConnector.git edc
git submodule update --init
- git -C edc checkout 3305340d6a19ba919540d28a731b3cab6d23857a
+ git -C edc fetch --all
+ git -C edc checkout febacc631b4c07aaec2e76ff8a81e8564a99090d
-
name: Set up JDK 11
uses: actions/setup-java@v2
@@ -121,6 +122,41 @@ jobs:
tags: ${{ steps.edc_controlplane_cosmosdb_meta.outputs.tags }}
labels: ${{ steps.edc_controlplane_cosmosdb_meta.outputs.labels }}
+ #################################
+ ### edc-controlplane-postgresql ###
+ #################################
+ -
+ name: Build edc-controlplane-postgresql
+ run: |-
+ ./mvnw -s settings.xml -B -pl .,edc-controlplane/edc-controlplane-postgresql -am verify
+ env:
+ GITHUB_PACKAGE_USERNAME: ${{ github.actor }}
+ GITHUB_PACKAGE_PASSWORD: ${{ secrets.CXNG_GHCR_PAT }}
+ -
+ name: edc-controlplane-postgresql Docker Metadata
+ id: edc_controlplane_postgresql_meta
+ uses: docker/metadata-action@v3
+ with:
+ images: |
+ ghcr.io/catenax-ng/catena-x-edc/edc-controlplane-postgresql
+ tags: |
+ type=ref,event=branch
+ type=ref,event=pr
+ type=semver,pattern={{raw}}
+ type=match,pattern=\d.\d.\d
+ type=sha
+ -
+ name: Build edc-controlplane-postgresql Docker Image
+ uses: docker/build-push-action@v2
+ with:
+ context: .
+ file: edc-controlplane/edc-controlplane-postgresql/src/main/docker/Dockerfile
+ build-args: |
+ JAR=edc-controlplane/edc-controlplane-postgresql/target/edc-controlplane-postgresql.jar
+ push: ${{ github.event_name != 'pull_request' }}
+ tags: ${{ steps.edc_controlplane_postgresql_meta.outputs.tags }}
+ labels: ${{ steps.edc_controlplane_postgresql_meta.outputs.labels }}
+
#####################
### edc-dataplane ###
#####################
diff --git a/deployment/helm/edc-controlplane/values.yaml b/deployment/helm/edc-controlplane/values.yaml
index fb56eda05..cb5585765 100644
--- a/deployment/helm/edc-controlplane/values.yaml
+++ b/deployment/helm/edc-controlplane/values.yaml
@@ -140,7 +140,22 @@ configuration:
edc_dataplane_queue_capacity: ""
edc_dataplane_wait: ""
edc_dataplane_workers: ""
- edc_datasource_contractdefinition_name: ""
+ edc_datasource_asset_name: "default"
+ edc_datasource_contractdefinition_name: "default"
+ edc_datasource_contractnegotiation_name: "default"
+ edc_datasource_policy_name: "default"
+ edc_datasource_transferprocess_name: "default"
+ edc_datasource_default_pool_maxIdleConnections: ""
+ edc_datasource_default_pool_maxTotalConnections: ""
+ edc_datasource_default_pool_minIdleConnections: ""
+ edc_datasource_default_pool_testConnectionOnBorrow: ""
+ edc_datasource_default_pool_testConnectionOnCreate: ""
+ edc_datasource_default_pool_testConnectionOnReturn: ""
+ edc_datasource_default_pool_testConnectionWhileIdle: ""
+ edc_datasource_default_pool_testQuery: ""
+ edc_datasource_default_url: ""
+ edc_datasource_default_user: ""
+ edc_datasource_default_password: ""
edc_dpf_selector_url: ""
edc_events_topic_endpoint: ""
edc_events_topic_name: ""
diff --git a/deployment/helm/edc-dataplane/values.yaml b/deployment/helm/edc-dataplane/values.yaml
index a8f62a9b1..b979f43a2 100644
--- a/deployment/helm/edc-dataplane/values.yaml
+++ b/deployment/helm/edc-dataplane/values.yaml
@@ -137,7 +137,22 @@ configuration:
edc_dataplane_queue_capacity: ""
edc_dataplane_wait: ""
edc_dataplane_workers: ""
- edc_datasource_contractdefinition_name: ""
+ edc_datasource_asset_name: "default"
+ edc_datasource_contractdefinition_name: "default"
+ edc_datasource_contractnegotiation_name: "default"
+ edc_datasource_policy_name: "default"
+ edc_datasource_transferprocess_name: "default"
+ edc_datasource_default_pool_maxIdleConnections: ""
+ edc_datasource_default_pool_maxTotalConnections: ""
+ edc_datasource_default_pool_minIdleConnections: ""
+ edc_datasource_default_pool_testConnectionOnBorrow: ""
+ edc_datasource_default_pool_testConnectionOnCreate: ""
+ edc_datasource_default_pool_testConnectionOnReturn: ""
+ edc_datasource_default_pool_testConnectionWhileIdle: ""
+ edc_datasource_default_pool_testQuery: ""
+ edc_datasource_default_url: ""
+ edc_datasource_default_user: ""
+ edc_datasource_default_password: ""
edc_dpf_selector_url: ""
edc_events_topic_endpoint: ""
edc_events_topic_name: ""
diff --git a/edc b/edc
index 3305340d6..febacc631 160000
--- a/edc
+++ b/edc
@@ -1 +1 @@
-Subproject commit 3305340d6a19ba919540d28a731b3cab6d23857a
+Subproject commit febacc631b4c07aaec2e76ff8a81e8564a99090d
diff --git a/edc-controlplane/edc-controlplane-memory/src/main/docker/Dockerfile b/edc-controlplane/edc-controlplane-memory/src/main/docker/Dockerfile
index 773b1e06c..79440ed5d 100644
--- a/edc-controlplane/edc-controlplane-memory/src/main/docker/Dockerfile
+++ b/edc-controlplane/edc-controlplane-memory/src/main/docker/Dockerfile
@@ -1,4 +1,4 @@
-FROM alpine:3.14 as otel
+FROM alpine:3.15.4 as otel
ENV OTEL_AGENT_LOCATION "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.12.1/opentelemetry-javaagent.jar"
diff --git a/edc-controlplane/edc-controlplane-postgresql/pom.xml b/edc-controlplane/edc-controlplane-postgresql/pom.xml
new file mode 100644
index 000000000..262148bac
--- /dev/null
+++ b/edc-controlplane/edc-controlplane-postgresql/pom.xml
@@ -0,0 +1,272 @@
+
+
+
+ edc-controlplane
+ net.catenax.edc
+ 0.0.2-SNAPSHOT
+
+ 4.0.0
+
+ edc-controlplane-postgresql
+ jar
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+
+
+
+ shade
+
+
+ ${project.artifactId}
+ true
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+
+ org.eclipse.dataspaceconnector.boot.system.runtime.BaseRuntime
+
+
+
+
+ META-INF/services/org.eclipse.dataspaceconnector.spi.system.ServiceExtension
+
+
+
+
+ META-INF/services/org.eclipse.dataspaceconnector.spi.system.VaultExtension
+
+
+
+
+ META-INF/services/org.eclipse.dataspaceconnector.spi.system.ConfigurationExtension
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ net.catenax.edc.extensions
+ aas-controller
+
+
+
+
+ net.catenax.edc.extensions
+ postgresql-migration
+
+
+
+
+ org.eclipse.dataspaceconnector
+ filesystem-configuration
+
+
+
+
+ org.eclipse.dataspaceconnector
+ azure-vault
+
+
+
+
+ org.eclipse.dataspaceconnector
+ control-api
+
+
+
+ org.eclipse.dataspaceconnector
+ observability-api
+
+
+
+
+ org.eclipse.dataspaceconnector
+ ids-api-configuration
+
+
+ org.eclipse.dataspaceconnector
+ ids-api-multipart-dispatcher-v1
+
+
+ org.eclipse.dataspaceconnector
+ ids-api-multipart-endpoint-v1
+
+
+ org.eclipse.dataspaceconnector
+ ids-api-transform-v1
+
+
+ org.eclipse.dataspaceconnector
+ ids-core
+
+
+ org.eclipse.dataspaceconnector
+ ids-spi
+
+
+ org.eclipse.dataspaceconnector
+ ids-token-validation
+
+
+
+
+ org.eclipse.dataspaceconnector
+ sql-asset-index
+
+
+ org.eclipse.dataspaceconnector
+ sql-contractdefinition-store
+
+
+ org.eclipse.dataspaceconnector
+ sql-contractnegotiation-store
+
+
+ org.eclipse.dataspaceconnector
+ sql-transferprocess-store
+
+
+ org.eclipse.dataspaceconnector
+ sql-policy-store
+
+
+
+
+ org.eclipse.dataspaceconnector
+ core-base
+
+
+ org.eclipse.dataspaceconnector
+ core-boot
+
+
+ org.eclipse.dataspaceconnector
+ transfer
+
+
+ org.eclipse.dataspaceconnector
+ contract
+
+
+
+
+ org.eclipse.dataspaceconnector
+ iam-mock
+
+
+
+
+ org.eclipse.dataspaceconnector
+ core-micrometer
+
+
+ org.eclipse.dataspaceconnector
+ jersey-micrometer
+ ${org.eclipse.dataspaceconnector.version}
+
+
+ org.eclipse.dataspaceconnector
+ jetty-micrometer
+ ${org.eclipse.dataspaceconnector.version}
+
+
+
+
+ org.eclipse.dataspaceconnector
+ jdk-logger-monitor
+
+
+
+
+ org.eclipse.dataspaceconnector
+ http
+
+
+
+ org.eclipse.dataspaceconnector
+ sql-pool-apache-commons-pool
+
+
+ org.eclipse.dataspaceconnector
+ transaction-local
+
+
+
+ org.eclipse.dataspaceconnector
+ http-receiver
+
+
+
+
+ org.postgresql
+ postgresql
+
+
+ jakarta.ws.rs
+ jakarta.ws.rs-api
+
+
+
+
+
+ with-docker-image
+
+
+
+ com.spotify
+ dockerfile-maven-plugin
+
+
+ default
+ package
+
+ build
+
+
+
+
+ .
+ src/main/docker/Dockerfile
+ ${project.artifactId}
+ ${project.version}
+
+ target/${project.artifactId}.jar
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/edc-controlplane/edc-controlplane-postgresql/src/main/docker/Dockerfile b/edc-controlplane/edc-controlplane-postgresql/src/main/docker/Dockerfile
new file mode 100644
index 000000000..79440ed5d
--- /dev/null
+++ b/edc-controlplane/edc-controlplane-postgresql/src/main/docker/Dockerfile
@@ -0,0 +1,23 @@
+FROM alpine:3.15.4 as otel
+
+ENV OTEL_AGENT_LOCATION "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.12.1/opentelemetry-javaagent.jar"
+
+RUN wget ${OTEL_AGENT_LOCATION} -O /tmp/opentelemetry-javaagent.jar
+
+FROM gcr.io/distroless/java11-debian11
+ARG JAR
+
+WORKDIR /app
+
+COPY --from=otel /tmp/opentelemetry-javaagent.jar .
+COPY $JAR edc-controlplane.jar
+
+CMD ["-javaagent:/app/opentelemetry-javaagent.jar", \
+ "-Dedc.fs.config=/app/configuration.properties", \
+ "-Djava.util.logging.config.file=/app/logging.properties", \
+ "-Dotel.javaagent.configuration-file=/app/opentelemetry.properties", \
+ "-Dotel.metrics.exporter=prometheus", \
+ "-Dotel.exporter.prometheus.port=9090", \
+ "-Djava.security.edg=file:/dev/.urandom", \
+ "-jar", \
+ "edc-controlplane.jar"]
diff --git a/edc-controlplane/pom.xml b/edc-controlplane/pom.xml
index c1d6da782..ee196417b 100644
--- a/edc-controlplane/pom.xml
+++ b/edc-controlplane/pom.xml
@@ -16,5 +16,6 @@
edc-controlplane-cosmosdb
edc-controlplane-memory
+ edc-controlplane-postgresql
\ No newline at end of file
diff --git a/edc-extensions/pom.xml b/edc-extensions/pom.xml
index 8f5fa495e..194abb15b 100644
--- a/edc-extensions/pom.xml
+++ b/edc-extensions/pom.xml
@@ -14,6 +14,7 @@
aas-controller
+ postgresql-migration
\ No newline at end of file
diff --git a/edc-extensions/postgresql-migration/pom.xml b/edc-extensions/postgresql-migration/pom.xml
new file mode 100644
index 000000000..00ffa0ff1
--- /dev/null
+++ b/edc-extensions/postgresql-migration/pom.xml
@@ -0,0 +1,44 @@
+
+
+
+ edc-extensions
+ net.catenax.edc.extensions
+ 0.0.2-SNAPSHOT
+
+ 4.0.0
+
+ postgresql-migration
+ jar
+
+
+
+ org.eclipse.dataspaceconnector
+ transaction-datasource-spi
+
+
+ org.eclipse.dataspaceconnector
+ transaction-spi
+
+
+
+
+ org.eclipse.dataspaceconnector
+ sql-asset-index
+ compile
+
+
+
+
+ org.eclipse.dataspaceconnector
+ sql-common
+
+
+
+
+ org.flywaydb
+ flyway-core
+
+
+
\ No newline at end of file
diff --git a/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/AbstractPostgresqlMigrationExtension.java b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/AbstractPostgresqlMigrationExtension.java
new file mode 100644
index 000000000..871725d5d
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/AbstractPostgresqlMigrationExtension.java
@@ -0,0 +1,89 @@
+package net.catenax.edc.postgresql.migration;
+
+import java.util.Objects;
+import java.util.Properties;
+import org.eclipse.dataspaceconnector.spi.persistence.EdcPersistenceException;
+import org.eclipse.dataspaceconnector.spi.system.ServiceExtension;
+import org.eclipse.dataspaceconnector.spi.system.ServiceExtensionContext;
+import org.eclipse.dataspaceconnector.spi.system.configuration.Config;
+import org.eclipse.dataspaceconnector.sql.datasource.ConnectionFactoryDataSource;
+import org.flywaydb.core.Flyway;
+import org.flywaydb.core.api.MigrationVersion;
+import org.flywaydb.core.api.output.MigrateResult;
+
+abstract class AbstractPostgresqlMigrationExtension implements ServiceExtension {
+ protected abstract String getDataSourceNameConfigurationKey();
+
+ protected abstract String getSubsystemName();
+
+ private static final String EDC_DATASOURCE_PREFIX = "edc.datasource";
+ private static final String MIGRATION_LOCATION_BASE =
+ String.format(
+ "classpath:%s",
+ AbstractPostgresqlMigrationExtension.class.getPackageName().replaceAll("\\.", "/"));
+
+ @Override
+ public void initialize(final ServiceExtensionContext context) {
+ final String subSystemName = Objects.requireNonNull(getSubsystemName());
+
+ final String dataSourceName =
+ context.getConfig().getString(getDataSourceNameConfigurationKey(), null);
+ if (dataSourceName == null) {
+ return;
+ }
+
+ boolean enabled =
+ context
+ .getConfig()
+ .getBoolean(
+ String.format("net.catenax.edc.postgresql.migration.%s.enabled", subSystemName),
+ true);
+
+ if (!enabled) {
+ return;
+ }
+
+ Config datasourceConfiguration =
+ context.getConfig(String.join(".", EDC_DATASOURCE_PREFIX, dataSourceName));
+
+ final String jdbcUrl = Objects.requireNonNull(datasourceConfiguration.getString("url"));
+ final Properties jdbcProperties = new Properties();
+ jdbcProperties.putAll(datasourceConfiguration.getRelativeEntries());
+
+ final DriverManagerConnectionFactory driverManagerConnectionFactory =
+ new DriverManagerConnectionFactory(jdbcUrl, jdbcProperties);
+ final ConnectionFactoryDataSource dataSource =
+ new ConnectionFactoryDataSource(driverManagerConnectionFactory);
+
+ final String schemaHistoryTableName = getSchemaHistoryTableName(subSystemName);
+ final String migrationsLocation = getMigrationsLocation();
+
+ final Flyway flyway =
+ Flyway.configure()
+ .baselineVersion(MigrationVersion.fromVersion("0.0.0"))
+ .failOnMissingLocations(true)
+ .dataSource(dataSource)
+ .table(schemaHistoryTableName)
+ .locations(migrationsLocation)
+ .load();
+
+ flyway.baseline();
+
+ final MigrateResult migrateResult = flyway.migrate();
+
+ if (!migrateResult.success) {
+ throw new EdcPersistenceException(
+ String.format(
+ "Migrating DataSource %s for subsystem %s failed: %s",
+ dataSourceName, subSystemName, String.join(", ", migrateResult.warnings)));
+ }
+ }
+
+ private String getMigrationsLocation() {
+ return String.join("/", MIGRATION_LOCATION_BASE, getSubsystemName());
+ }
+
+ private String getSchemaHistoryTableName(final String subSystemName) {
+ return String.format("flyway_schema_history_%s", subSystemName);
+ }
+}
diff --git a/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/AssetPostgresqlMigrationExtension.java b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/AssetPostgresqlMigrationExtension.java
new file mode 100644
index 000000000..8f1d41702
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/AssetPostgresqlMigrationExtension.java
@@ -0,0 +1,15 @@
+package net.catenax.edc.postgresql.migration;
+
+import org.eclipse.dataspaceconnector.sql.asset.index.ConfigurationKeys;
+
+public class AssetPostgresqlMigrationExtension extends AbstractPostgresqlMigrationExtension {
+ private static final String NAME_SUBSYSTEM = "asset";
+
+ protected String getDataSourceNameConfigurationKey() {
+ return ConfigurationKeys.DATASOURCE_SETTING_NAME;
+ }
+
+ protected String getSubsystemName() {
+ return NAME_SUBSYSTEM;
+ }
+}
diff --git a/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/ContractDefinitionPostgresqlMigrationExtension.java b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/ContractDefinitionPostgresqlMigrationExtension.java
new file mode 100644
index 000000000..f2c0c40e1
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/ContractDefinitionPostgresqlMigrationExtension.java
@@ -0,0 +1,19 @@
+package net.catenax.edc.postgresql.migration;
+
+import org.eclipse.dataspaceconnector.spi.EdcSetting;
+
+public class ContractDefinitionPostgresqlMigrationExtension
+ extends AbstractPostgresqlMigrationExtension {
+ private static final String NAME_SUBSYSTEM = "contractdefinition";
+
+ @EdcSetting
+ private static final String DATASOURCE_SETTING_NAME = "edc.datasource.contractdefinition.name";
+
+ protected String getDataSourceNameConfigurationKey() {
+ return DATASOURCE_SETTING_NAME;
+ }
+
+ protected String getSubsystemName() {
+ return NAME_SUBSYSTEM;
+ }
+}
diff --git a/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/ContractNegotiationPostgresqlMigrationExtension.java b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/ContractNegotiationPostgresqlMigrationExtension.java
new file mode 100644
index 000000000..9856bacaa
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/ContractNegotiationPostgresqlMigrationExtension.java
@@ -0,0 +1,19 @@
+package net.catenax.edc.postgresql.migration;
+
+import org.eclipse.dataspaceconnector.spi.EdcSetting;
+
+public class ContractNegotiationPostgresqlMigrationExtension
+ extends AbstractPostgresqlMigrationExtension {
+ private static final String NAME_SUBSYSTEM = "contractnegotiation";
+
+ @EdcSetting
+ private static final String DATASOURCE_SETTING_NAME = "edc.datasource.contractnegotiation.name";
+
+ protected String getDataSourceNameConfigurationKey() {
+ return DATASOURCE_SETTING_NAME;
+ }
+
+ protected String getSubsystemName() {
+ return NAME_SUBSYSTEM;
+ }
+}
diff --git a/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/DriverManagerConnectionFactory.java b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/DriverManagerConnectionFactory.java
new file mode 100644
index 000000000..1c203e61c
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/DriverManagerConnectionFactory.java
@@ -0,0 +1,27 @@
+package net.catenax.edc.postgresql.migration;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.Objects;
+import java.util.Properties;
+import org.eclipse.dataspaceconnector.spi.persistence.EdcPersistenceException;
+import org.eclipse.dataspaceconnector.sql.ConnectionFactory;
+
+class DriverManagerConnectionFactory implements ConnectionFactory {
+ private final String jdbcUrl;
+ private final Properties properties;
+
+ public DriverManagerConnectionFactory(final String jdbcUrl, final Properties properties) {
+ this.jdbcUrl = Objects.requireNonNull(jdbcUrl);
+ this.properties = Objects.requireNonNull(properties);
+ }
+
+ @Override
+ public Connection create() {
+ try {
+ return DriverManager.getConnection(jdbcUrl, properties);
+ } catch (Exception exception) {
+ throw new EdcPersistenceException(exception.getMessage(), exception);
+ }
+ }
+}
diff --git a/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/PolicyPostgresqlMigrationExtension.java b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/PolicyPostgresqlMigrationExtension.java
new file mode 100644
index 000000000..24c77971c
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/PolicyPostgresqlMigrationExtension.java
@@ -0,0 +1,17 @@
+package net.catenax.edc.postgresql.migration;
+
+import org.eclipse.dataspaceconnector.spi.EdcSetting;
+
+public class PolicyPostgresqlMigrationExtension extends AbstractPostgresqlMigrationExtension {
+ private static final String NAME_SUBSYSTEM = "policy";
+
+ @EdcSetting private static final String DATASOURCE_SETTING_NAME = "edc.datasource.policy.name";
+
+ protected String getDataSourceNameConfigurationKey() {
+ return DATASOURCE_SETTING_NAME;
+ }
+
+ protected String getSubsystemName() {
+ return NAME_SUBSYSTEM;
+ }
+}
diff --git a/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/TransferProcessPostgresqlMigrationExtension.java b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/TransferProcessPostgresqlMigrationExtension.java
new file mode 100644
index 000000000..784b1d238
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/java/net/catenax/edc/postgresql/migration/TransferProcessPostgresqlMigrationExtension.java
@@ -0,0 +1,19 @@
+package net.catenax.edc.postgresql.migration;
+
+import org.eclipse.dataspaceconnector.spi.EdcSetting;
+
+public class TransferProcessPostgresqlMigrationExtension
+ extends AbstractPostgresqlMigrationExtension {
+ private static final String NAME_SUBSYSTEM = "transferprocess";
+
+ @EdcSetting
+ private static final String DATASOURCE_SETTING_NAME = "edc.datasource.transferprocess.name";
+
+ protected String getDataSourceNameConfigurationKey() {
+ return DATASOURCE_SETTING_NAME;
+ }
+
+ protected String getSubsystemName() {
+ return NAME_SUBSYSTEM;
+ }
+}
diff --git a/edc-extensions/postgresql-migration/src/main/resources/META-INF/services/org.eclipse.dataspaceconnector.spi.system.ServiceExtension b/edc-extensions/postgresql-migration/src/main/resources/META-INF/services/org.eclipse.dataspaceconnector.spi.system.ServiceExtension
new file mode 100644
index 000000000..aa8b6b5b1
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/resources/META-INF/services/org.eclipse.dataspaceconnector.spi.system.ServiceExtension
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2022 Daimler TSS 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:
+# Daimler TSS GmbH - Initial ServiceExtension file
+#
+#
+net.catenax.edc.postgresql.migration.AssetPostgresqlMigrationExtension
+net.catenax.edc.postgresql.migration.ContractDefinitionPostgresqlMigrationExtension
+net.catenax.edc.postgresql.migration.ContractNegotiationPostgresqlMigrationExtension
+net.catenax.edc.postgresql.migration.PolicyPostgresqlMigrationExtension
+net.catenax.edc.postgresql.migration.TransferProcessPostgresqlMigrationExtension
diff --git a/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/asset/V0_0_1__Init_Asset_Database_Schema.sql b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/asset/V0_0_1__Init_Asset_Database_Schema.sql
new file mode 100644
index 000000000..1a4e86f7f
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/asset/V0_0_1__Init_Asset_Database_Schema.sql
@@ -0,0 +1,55 @@
+--
+-- Copyright (c) 2022 Daimler TSS 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:
+-- Daimler TSS GmbH - Initial Database Schema
+--
+
+--
+-- table: edc_asset
+--
+CREATE TABLE IF NOT EXISTS edc_asset
+(
+ asset_id VARCHAR(255) NOT NULL,
+ PRIMARY KEY (asset_id)
+);
+
+--
+-- table: edc_asset_dataaddress
+--
+CREATE TABLE IF NOT EXISTS edc_asset_dataaddress
+(
+ asset_id VARCHAR(255) NOT NULL,
+ properties TEXT NOT NULL,
+ PRIMARY KEY (asset_id),
+ FOREIGN KEY (asset_id) REFERENCES edc_asset (asset_id) ON DELETE CASCADE
+);
+COMMENT ON COLUMN edc_asset_dataaddress.properties is 'DataAddress properties serialized as JSON';
+
+--
+-- table: edc_asset_property
+--
+CREATE TABLE IF NOT EXISTS edc_asset_property
+(
+ asset_id VARCHAR(255) NOT NULL,
+ property_name VARCHAR(255) NOT NULL,
+ property_value TEXT NOT NULL,
+ property_type VARCHAR(255) NOT NULL,
+ PRIMARY KEY (asset_id, property_name),
+ FOREIGN KEY (asset_id) REFERENCES edc_asset (asset_id) ON DELETE CASCADE
+);
+COMMENT ON COLUMN edc_asset_property.property_name IS
+ 'Asset property key';
+COMMENT ON COLUMN edc_asset_property.property_value IS
+ 'Asset property value';
+COMMENT ON COLUMN edc_asset_property.property_type IS
+ 'Asset property class name';
+
+CREATE INDEX IF NOT EXISTS idx_edc_asset_property_value
+ ON edc_asset_property (property_name, property_value);
\ No newline at end of file
diff --git a/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/contractdefinition/V0_0_1__Init_ContractDefinition_Database_Schema.sql b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/contractdefinition/V0_0_1__Init_ContractDefinition_Database_Schema.sql
new file mode 100644
index 000000000..f147f6499
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/contractdefinition/V0_0_1__Init_ContractDefinition_Database_Schema.sql
@@ -0,0 +1,24 @@
+--
+-- Copyright (c) 2022 Daimler TSS 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:
+-- Daimler TSS GmbH - Initial Database Schema
+--
+
+--
+-- table: edc_contract_definitions
+--
+CREATE TABLE IF NOT EXISTS edc_contract_definitions
+(
+ contract_definition_id VARCHAR(255) NOT NULL,
+ access_policy TEXT NOT NULL,
+ contract_policy TEXT NOT NULL,
+ selector_expression TEXT NOT NULL,
+ PRIMARY KEY (contract_definition_id)
+);
diff --git a/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/contractnegotiation/V0_0_1__Init_ContractNegotiation_Database_Schema.sql b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/contractnegotiation/V0_0_1__Init_ContractNegotiation_Database_Schema.sql
new file mode 100644
index 000000000..2eaf02e13
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/contractnegotiation/V0_0_1__Init_ContractNegotiation_Database_Schema.sql
@@ -0,0 +1,82 @@
+--
+-- Copyright (c) 2022 Daimler TSS 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:
+-- Daimler TSS GmbH - Initial Database Schema
+--
+
+--
+-- table: edc_lease
+--
+CREATE TABLE IF NOT EXISTS edc_lease
+(
+ leased_by VARCHAR(255) NOT NULL,
+ leased_at BIGINT,
+ lease_duration INTEGER DEFAULT 60000 NOT NULL,
+ lease_id VARCHAR(255) NOT NULL
+ CONSTRAINT lease_pk
+ PRIMARY KEY
+);
+COMMENT ON COLUMN edc_lease.leased_at IS 'posix timestamp of lease';
+COMMENT ON COLUMN edc_lease.lease_duration IS 'duration of lease in milliseconds';
+
+CREATE UNIQUE INDEX lease_lease_id_uindex
+ ON edc_lease (lease_id);
+
+--
+-- table: edc_contract_agreement
+--
+CREATE TABLE IF NOT EXISTS edc_contract_agreement
+(
+ id VARCHAR NOT NULL
+ CONSTRAINT contract_agreement_pk PRIMARY KEY,
+ provider_agent_id VARCHAR(255),
+ consumer_agent_id VARCHAR(255),
+ signing_date BIGINT,
+ start_date BIGINT,
+ end_date INTEGER,
+ asset_id VARCHAR(255) NOT NULL,
+ policy_id VARCHAR(255),
+ serialized_policy TEXT
+);
+
+--
+-- table: edc_contract_negotiation
+--
+CREATE TABLE IF NOT EXISTS edc_contract_negotiation
+(
+ id VARCHAR(255) NOT NULL
+ CONSTRAINT contract_negotiation_pk PRIMARY KEY,
+ correlation_id VARCHAR(255) NOT NULL,
+ counterparty_id VARCHAR(255) NOT NULL,
+ counterparty_address VARCHAR(255) NOT NULL,
+ protocol VARCHAR(255) DEFAULT 'ids-multipart':: CHARACTER VARYING NOT NULL,
+ type INTEGER DEFAULT 0 NOT NULL,
+ state INTEGER DEFAULT 0 NOT NULL,
+ state_count INTEGER DEFAULT 0,
+ state_timestamp BIGINT,
+ error_detail TEXT,
+ contract_agreement_id TEXT
+ CONSTRAINT contract_negotiation_contract_agreement_id_fk REFERENCES edc_contract_agreement,
+ contract_offers TEXT,
+ trace_context TEXT,
+ lease_id VARCHAR(255)
+ CONSTRAINT contract_negotiation_lease_lease_id_fk REFERENCES edc_lease ON DELETE SET NULL
+);
+COMMENT ON COLUMN edc_contract_negotiation.contract_agreement_id IS 'ContractAgreement serialized as JSON';
+COMMENT ON COLUMN edc_contract_negotiation.contract_offers IS 'List serialized as JSON';
+COMMENT ON COLUMN edc_contract_negotiation.trace_context IS 'Map serialized as JSON';
+
+CREATE INDEX IF NOT EXISTS contract_negotiation_correlationid_index
+ ON edc_contract_negotiation (correlation_id);
+CREATE UNIQUE INDEX IF NOT EXISTS contract_negotiation_id_uindex
+ ON edc_contract_negotiation (id);
+CREATE UNIQUE INDEX IF NOT EXISTS contract_agreement_id_uindex
+ ON edc_contract_agreement (id);
+
diff --git a/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/policy/V0_0_1__Init_Policy_Database_Schema.sql b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/policy/V0_0_1__Init_Policy_Database_Schema.sql
new file mode 100644
index 000000000..9c8ebfc74
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/policy/V0_0_1__Init_Policy_Database_Schema.sql
@@ -0,0 +1,40 @@
+--
+-- Copyright (c) 2022 ZF Friedrichshafen AG and others
+--
+-- 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:
+-- ZF Friedrichshafen AG - Initial SQL Query
+-- Daimler TSS GmbH - Value range modifications
+--
+
+--
+-- table: edc_policies
+--
+CREATE TABLE IF NOT EXISTS edc_policies
+(
+ policy_id VARCHAR(255) NOT NULL,
+ permissions TEXT,
+ prohibitions TEXT,
+ duties TEXT,
+ extensible_properties TEXT,
+ inherits_from VARCHAR(255),
+ assigner VARCHAR(255),
+ assignee VARCHAR(255),
+ target VARCHAR(255),
+ policy_type VARCHAR(255) NOT NULL,
+ PRIMARY KEY (policy_id)
+);
+
+COMMENT ON COLUMN edc_policies.permissions IS 'Java List serialized as JSON';
+COMMENT ON COLUMN edc_policies.prohibitions IS 'Java List serialized as JSON';
+COMMENT ON COLUMN edc_policies.duties IS 'Java List serialized as JSON';
+COMMENT ON COLUMN edc_policies.extensible_properties IS 'Java Map serialized as JSON';
+COMMENT ON COLUMN edc_policies.policy_type IS 'Java PolicyType serialized as JSON';
+
+CREATE UNIQUE INDEX IF NOT EXISTS edc_policies_id_uindex
+ ON edc_policies (policy_id);
diff --git a/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/transferprocess/V0_0_1__Init_TransferProcess_Database_Schema.sql b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/transferprocess/V0_0_1__Init_TransferProcess_Database_Schema.sql
new file mode 100644
index 000000000..f80c0df09
--- /dev/null
+++ b/edc-extensions/postgresql-migration/src/main/resources/net/catenax/edc/postgresql/migration/transferprocess/V0_0_1__Init_TransferProcess_Database_Schema.sql
@@ -0,0 +1,91 @@
+--
+-- Copyright (c) 2022 Daimler TSS 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:
+-- Daimler TSS GmbH - Rewrite to be SQL Init Schema
+--
+
+--
+-- table: edc_lease
+--
+CREATE TABLE IF NOT EXISTS edc_lease
+(
+ leased_by VARCHAR(255) NOT NULL,
+ leased_at BIGINT,
+ lease_duration INTEGER DEFAULT 60000 NOT NULL,
+ lease_id VARCHAR(255) NOT NULL
+ CONSTRAINT lease_pk
+ PRIMARY KEY
+);
+COMMENT ON COLUMN edc_lease.leased_at IS 'posix timestamp of lease';
+COMMENT ON COLUMN edc_lease.lease_duration IS 'duration of lease in milliseconds';
+
+CREATE UNIQUE INDEX IF NOT EXISTS lease_lease_id_uindex
+ ON edc_lease (lease_id);
+
+--
+-- table: edc_transfer_process
+--
+CREATE TABLE IF NOT EXISTS edc_transfer_process
+(
+ id VARCHAR(255) NOT NULL
+ CONSTRAINT transfer_process_pk
+ PRIMARY KEY,
+ type VARCHAR(255) NOT NULL,
+ state INTEGER NOT NULL,
+ state_count INTEGER DEFAULT 0 NOT NULL,
+ state_time_stamp BIGINT,
+ trace_context TEXT,
+ error_detail TEXT,
+ resource_manifest TEXT,
+ provisioned_resource_set TEXT,
+ lease_id VARCHAR(255)
+ CONSTRAINT transfer_process_lease_lease_id_fk
+ REFERENCES edc_lease
+ ON DELETE SET NULL
+);
+COMMENT ON COLUMN edc_transfer_process.trace_context IS 'Java Map serialized as JSON';
+COMMENT ON COLUMN edc_transfer_process.resource_manifest IS 'java ResourceManifest serialized as JSON';
+COMMENT ON COLUMN edc_transfer_process.provisioned_resource_set IS 'ProvisionedResourceSet serialized as JSON';
+
+CREATE UNIQUE INDEX IF NOT EXISTS transfer_process_id_uindex
+ ON edc_transfer_process (id);
+
+--
+-- table: edc_data_request
+--
+CREATE TABLE IF NOT EXISTS edc_data_request
+(
+ id VARCHAR(255) NOT NULL
+ CONSTRAINT data_request_pk
+ PRIMARY KEY,
+ process_id VARCHAR(255) NOT NULL,
+ connector_address VARCHAR(255) NOT NULL,
+ protocol VARCHAR(255) NOT NULL,
+ connector_id VARCHAR(255),
+ asset_id VARCHAR(255) NOT NULL,
+ contract_id VARCHAR(255) NOT NULL,
+ data_destination TEXT NOT NULL,
+ managed_resources BOOLEAN DEFAULT TRUE,
+ properties TEXT,
+ transfer_type TEXT,
+ transfer_process_id VARCHAR(255) NOT NULL
+ CONSTRAINT data_request_transfer_process_id_fk
+ REFERENCES edc_transfer_process
+ ON UPDATE RESTRICT ON DELETE CASCADE
+);
+COMMENT ON COLUMN edc_data_request.data_destination IS 'DataAddress serialized as JSON';
+COMMENT ON COLUMN edc_data_request.properties IS 'java Map serialized as JSON';
+COMMENT ON COLUMN edc_data_request.transfer_type IS 'TransferType serialized as JSON';
+
+CREATE UNIQUE INDEX IF NOT EXISTS data_request_id_uindex
+ ON edc_data_request (id);
+CREATE UNIQUE INDEX IF NOT EXISTS lease_lease_id_uindex
+ ON edc_lease (lease_id);
+
diff --git a/pom.xml b/pom.xml
index ec90f0ec6..498b3c201 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,6 +9,7 @@
edc-extensions
+
edc-controlplane
edc-dataplane
@@ -25,6 +26,8 @@
0.0.1-SNAPSHOT
1.2.0
3.0.0
+ 42.2.6
+ 8.5.5
@@ -115,23 +118,30 @@
aas-controller
${project.version}
-
-
-
- com.azure
- azure-sdk-bom
- ${com.azure.sdk.bom.version}
- pom
- import
+ net.catenax.edc.extensions
+ postgresql-migration
+ ${project.version}
-
+
jakarta.ws.rs
jakarta.ws.rs-api
${jakarta.ws.rs.api.version}
+
+ org.postgresql
+ postgresql
+ ${org.postgresql.version}
+
+
+ org.flywaydb
+ flyway-core
+ ${org.flywaydb.version}
+
+
+
org.eclipse.dataspaceconnector
api-configuration
@@ -637,6 +647,12 @@
spi
${org.eclipse.dataspaceconnector.version}
+
+
+ org.eclipse.dataspaceconnector
+ sql-asset-index
+ ${org.eclipse.dataspaceconnector.version}
+
org.eclipse.dataspaceconnector
sql-common
@@ -662,6 +678,17 @@
sql-transferprocess-store
${org.eclipse.dataspaceconnector.version}
+
+ org.eclipse.dataspaceconnector
+ sql-contractnegotiation-store
+ ${org.eclipse.dataspaceconnector.version}
+
+
+ org.eclipse.dataspaceconnector
+ sql-policy-store
+ ${org.eclipse.dataspaceconnector.version}
+
+
org.eclipse.dataspaceconnector
state-machine-lib
@@ -743,6 +770,14 @@
${org.eclipse.dataspaceconnector.version}
+
+
+ com.azure
+ azure-sdk-bom
+ ${com.azure.sdk.bom.version}
+ pom
+ import
+
\ No newline at end of file