Skip to content

Commit

Permalink
chore(dao): Remove obsolete listForRepositoryUrl function
Browse files Browse the repository at this point in the history
This function from `InfrastructureServiceRepository` is no longer
used, since now all available infrastructure services are taken into
account.

Signed-off-by: Oliver Heger <[email protected]>
  • Loading branch information
oheger-bosch committed Jan 7, 2025
1 parent 274721f commit 7a05ec2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<InfrastructureService> = 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IllegalArgumentException> {
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/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,6 @@ interface InfrastructureServiceRepository {
parameters: ListQueryParameters = ListQueryParameters.DEFAULT
): List<InfrastructureService>

/**
* 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<InfrastructureService>

/**
* 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
Expand Down

0 comments on commit 7a05ec2

Please sign in to comment.