From 18272cbec09fd982efc3cdb70f9995331a3903ee Mon Sep 17 00:00:00 2001 From: Benjamin SCHOLTES Date: Fri, 22 Mar 2024 11:47:13 +0100 Subject: [PATCH] fix: add missing IF NOT EXIST statements in SQL stores --- .../eclipse/edc/identityhub/api/PresentationApiExtension.java | 2 +- .../edc/identityhub/defaults/CredentialResourceLookup.java | 2 +- .../tests/fixtures/IdentityHubRuntimeConfiguration.java | 2 +- .../sql/identity-hub-credentials-store-sql/docs/schema.sql | 4 ++-- .../credentials/schema/postgres/CredentialJsonMapping.java | 2 +- .../store/sql/identity-hub-keypair-store-sql/docs/schema.sql | 2 +- .../identity-hub-participantcontext-store-sql/docs/schema.sql | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityhub/api/PresentationApiExtension.java b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityhub/api/PresentationApiExtension.java index e2239336a..257181ae7 100644 --- a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityhub/api/PresentationApiExtension.java +++ b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityhub/api/PresentationApiExtension.java @@ -14,7 +14,7 @@ package org.eclipse.edc.identityhub.api; -import org.eclipse.edc.core.transform.transformer.edc.to.JsonValueToGenericTypeTransformer; +import org.eclipse.edc.core.transform.transformer.to.JsonValueToGenericTypeTransformer; import org.eclipse.edc.iam.identitytrust.transform.to.JsonObjectToPresentationQueryTransformer; import org.eclipse.edc.identityhub.api.v1.PresentationApiController; import org.eclipse.edc.identityhub.api.validation.PresentationQueryValidator; diff --git a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/defaults/CredentialResourceLookup.java b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/defaults/CredentialResourceLookup.java index ab6ead459..b2aacebf5 100644 --- a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/defaults/CredentialResourceLookup.java +++ b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/defaults/CredentialResourceLookup.java @@ -17,7 +17,7 @@ import org.eclipse.edc.connector.core.store.ReflectionPropertyLookup; import org.eclipse.edc.identityhub.spi.model.VerifiableCredentialResource; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; -import org.eclipse.edc.util.reflection.PathItem; +import org.eclipse.edc.spi.types.PathItem; import org.eclipse.edc.util.reflection.ReflectionUtil; import java.time.Instant; diff --git a/e2e-tests/api-tests/src/test/java/org/eclipse/edc/identityhub/tests/fixtures/IdentityHubRuntimeConfiguration.java b/e2e-tests/api-tests/src/test/java/org/eclipse/edc/identityhub/tests/fixtures/IdentityHubRuntimeConfiguration.java index 0aa1a5981..cf95867b4 100644 --- a/e2e-tests/api-tests/src/test/java/org/eclipse/edc/identityhub/tests/fixtures/IdentityHubRuntimeConfiguration.java +++ b/e2e-tests/api-tests/src/test/java/org/eclipse/edc/identityhub/tests/fixtures/IdentityHubRuntimeConfiguration.java @@ -22,8 +22,8 @@ import java.util.Map; import static io.restassured.RestAssured.given; -import static org.eclipse.edc.boot.BootServicesExtension.PARTICIPANT_ID; import static org.eclipse.edc.junit.testfixtures.TestUtils.getFreePort; +import static org.eclipse.edc.spi.system.ServiceExtensionContext.PARTICIPANT_ID; /** * The IdentityHubRuntimeConfiguration class represents an IdentityHub Runtime configuration and provides various information, such as API endpoints diff --git a/extensions/store/sql/identity-hub-credentials-store-sql/docs/schema.sql b/extensions/store/sql/identity-hub-credentials-store-sql/docs/schema.sql index ed4fca140..4e2c182ed 100644 --- a/extensions/store/sql/identity-hub-credentials-store-sql/docs/schema.sql +++ b/extensions/store/sql/identity-hub-credentials-store-sql/docs/schema.sql @@ -13,7 +13,7 @@ */ -- only intended for and tested with Postgres! -CREATE TABLE credential_resource +CREATE TABLE IF NOT EXISTS credential_resource ( id VARCHAR PRIMARY KEY NOT NULL, -- ID of the VC, duplicated here for indexing purposes create_timestamp BIGINT NOT NULL, -- POSIX timestamp of the creation of the VC @@ -27,7 +27,7 @@ CREATE TABLE credential_resource verifiable_credential JSON NOT NULL, -- JSON-representation of the verifiable credential participant_id VARCHAR -- ID of the ParticipantContext that owns this credentisl ); -CREATE UNIQUE INDEX credential_resource_credential_id_uindex ON credential_resource USING btree (id); +CREATE UNIQUE INDEX IF NOT EXISTS credential_resource_credential_id_uindex ON credential_resource USING btree (id); COMMENT ON COLUMN credential_resource.id IS 'ID of the VC, duplicated here for indexing purposes'; COMMENT ON COLUMN credential_resource.raw_vc IS 'Representation of the VC exactly as it was received by the issuer. Can be JWT or JSON(-LD) '; COMMENT ON COLUMN credential_resource.vc_format IS '0 = JSON-LD, 1 = JWT'; diff --git a/extensions/store/sql/identity-hub-credentials-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/credentials/schema/postgres/CredentialJsonMapping.java b/extensions/store/sql/identity-hub-credentials-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/credentials/schema/postgres/CredentialJsonMapping.java index 4e56d3a84..c08823246 100644 --- a/extensions/store/sql/identity-hub-credentials-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/credentials/schema/postgres/CredentialJsonMapping.java +++ b/extensions/store/sql/identity-hub-credentials-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/credentials/schema/postgres/CredentialJsonMapping.java @@ -14,8 +14,8 @@ package org.eclipse.edc.identityhub.store.sql.credentials.schema.postgres; +import org.eclipse.edc.spi.types.PathItem; import org.eclipse.edc.sql.translation.JsonFieldTranslator; -import org.eclipse.edc.util.reflection.PathItem; import java.util.ArrayList; import java.util.HashMap; diff --git a/extensions/store/sql/identity-hub-keypair-store-sql/docs/schema.sql b/extensions/store/sql/identity-hub-keypair-store-sql/docs/schema.sql index f4a14a4e5..73c2f3cb3 100644 --- a/extensions/store/sql/identity-hub-keypair-store-sql/docs/schema.sql +++ b/extensions/store/sql/identity-hub-keypair-store-sql/docs/schema.sql @@ -13,7 +13,7 @@ */ -- only intended for and tested with Postgres! -CREATE TABLE keypair_resource +CREATE TABLE IF NOT EXISTS keypair_resource ( id VARCHAR PRIMARY KEY NOT NULL, -- primary key participant_id VARCHAR, -- ID of the owning ParticipantContext. this is a loose business key, not a FK! diff --git a/extensions/store/sql/identity-hub-participantcontext-store-sql/docs/schema.sql b/extensions/store/sql/identity-hub-participantcontext-store-sql/docs/schema.sql index 431d47b81..5522e3e4f 100644 --- a/extensions/store/sql/identity-hub-participantcontext-store-sql/docs/schema.sql +++ b/extensions/store/sql/identity-hub-participantcontext-store-sql/docs/schema.sql @@ -13,7 +13,7 @@ */ -- only intended for and tested with Postgres! -CREATE TABLE participant_context +CREATE TABLE IF NOT EXISTS participant_context ( participant_id VARCHAR PRIMARY KEY NOT NULL, -- ID of the ParticipantContext created_date BIGINT NOT NULL, -- POSIX timestamp of the creation of the PC @@ -23,5 +23,5 @@ CREATE TABLE participant_context did VARCHAR, -- the DID with which this participant is identified roles JSON -- JSON array containing all the roles a user has. may be empty ); -CREATE UNIQUE INDEX participant_context_participant_id_uindex ON participant_context USING btree (participant_id); +CREATE UNIQUE INDEX IF NOT EXISTS participant_context_participant_id_uindex ON participant_context USING btree (participant_id);