From 7a05ec20cd2cd6e87b4f3213590cc63793969305 Mon Sep 17 00:00:00 2001 From: Oliver Heger Date: Tue, 17 Dec 2024 15:08:25 +0100 Subject: [PATCH] chore(dao): Remove obsolete `listForRepositoryUrl` function This function from `InfrastructureServiceRepository` is no longer used, since now all available infrastructure services are taken into account. Signed-off-by: Oliver Heger --- .../DaoInfrastructureServiceRepository.kt | 17 ------ .../DaoInfrastructureServiceRepositoryTest.kt | 53 ------------------- .../InfrastructureServiceRepository.kt | 8 --- 3 files changed, 78 deletions(-) diff --git a/dao/src/main/kotlin/repositories/infrastructureservice/DaoInfrastructureServiceRepository.kt b/dao/src/main/kotlin/repositories/infrastructureservice/DaoInfrastructureServiceRepository.kt index c51708f5f..f4b1d0c2e 100644 --- a/dao/src/main/kotlin/repositories/infrastructureservice/DaoInfrastructureServiceRepository.kt +++ b/dao/src/main/kotlin/repositories/infrastructureservice/DaoInfrastructureServiceRepository.kt @@ -19,8 +19,6 @@ package org.eclipse.apoapsis.ortserver.dao.repositories.infrastructureservice -import java.net.URI - import org.eclipse.apoapsis.ortserver.dao.ConditionBuilder import org.eclipse.apoapsis.ortserver.dao.blockingQuery import org.eclipse.apoapsis.ortserver.dao.findSingle @@ -173,21 +171,6 @@ class DaoInfrastructureServiceRepository(private val db: Database) : Infrastruct list(parameters) { InfrastructureServicesTable.id inSubQuery subQuery } } - override fun listForRepositoryUrl( - repositoryUrl: String, - organizationId: Long, - productId: Long - ): List = db.blockingQuery { - val repositoryHost = URI.create(repositoryUrl).host - val hostPattern = "%$repositoryHost%" - list(ListQueryParameters.DEFAULT) { - InfrastructureServicesTable.url like hostPattern and ( - (InfrastructureServicesTable.productId eq productId) or - (InfrastructureServicesTable.organizationId eq organizationId) - ) - } - } - override fun listForHierarchy( organizationId: Long, productId: Long diff --git a/dao/src/test/kotlin/repositories/infrastructureservice/DaoInfrastructureServiceRepositoryTest.kt b/dao/src/test/kotlin/repositories/infrastructureservice/DaoInfrastructureServiceRepositoryTest.kt index 6bead77da..5def7f047 100644 --- a/dao/src/test/kotlin/repositories/infrastructureservice/DaoInfrastructureServiceRepositoryTest.kt +++ b/dao/src/test/kotlin/repositories/infrastructureservice/DaoInfrastructureServiceRepositoryTest.kt @@ -488,59 +488,6 @@ class DaoInfrastructureServiceRepositoryTest : WordSpec() { } } - "listForRepositoryUrl" should { - "find all services matching the repository host" { - val repositoryUrl = "https://repo.example.org/test/repo/" - val otherProduct = fixtures.createProduct("anotherProduct") - - val match1 = createInfrastructureService("matching1", organization = fixtures.organization) - val match2 = createInfrastructureService("matching2", product = fixtures.product) - val match3 = createInfrastructureService( - "matching3", - url = "http://repo.example.org:443", - organization = fixtures.organization - ) - val match4 = createInfrastructureService( - "matching4", - url = "https://repo.example.org/test/repo/test.git", - product = fixtures.product - ) - - val noMatch1 = createInfrastructureService( - "non-matching1", - url = "https://repo2.example.org/test/repo", - organization = fixtures.organization - ) - val noMatch2 = createInfrastructureService( - name = "non-matching2", - url = repositoryUrl, - product = otherProduct - ) - - listOf(match1, match2, match3, match4, noMatch1, noMatch2).forEach { - infrastructureServicesRepository.create(it) - } - - val services = infrastructureServicesRepository.listForRepositoryUrl( - repositoryUrl, - fixtures.organization.id, - fixtures.product.id - ) - - services shouldContainExactlyInAnyOrder listOf(match1, match2, match3, match4) - } - - "throw when passed an invalid repository URL" { - shouldThrow { - infrastructureServicesRepository.listForRepositoryUrl( - "?!invalid URL!?", - fixtures.organization.id, - fixtures.product.id - ) - } - } - } - "listForHierarchy" should { "return all services for the provided IDs" { val repositoryUrl = "https://repo.example.org/test/repo/" diff --git a/model/src/commonMain/kotlin/repositories/InfrastructureServiceRepository.kt b/model/src/commonMain/kotlin/repositories/InfrastructureServiceRepository.kt index bdfb59381..3f28f6cc3 100644 --- a/model/src/commonMain/kotlin/repositories/InfrastructureServiceRepository.kt +++ b/model/src/commonMain/kotlin/repositories/InfrastructureServiceRepository.kt @@ -133,14 +133,6 @@ interface InfrastructureServiceRepository { parameters: ListQueryParameters = ListQueryParameters.DEFAULT ): List - /** - * Return a list with the [InfrastructureService]s that are associated with the given - * [organization][organizationId] or [product][productId] and whose URL matches the given [repositoryUrl]. The - * match is done via the host name of the URLs, so things like paths, protocols, or ports are ignored. - * Note: If [repositoryUrl] is not a valid URL, an exception is thrown. - */ - fun listForRepositoryUrl(repositoryUrl: String, organizationId: Long, productId: Long): List - /** * Return a list with [InfrastructureService]s that are associated with the given [organizationId], or * [productId]. If there are multiple services with the same URL, instances on a lower level of