From a331f4194c67daf2517a57af84e056e7691272e1 Mon Sep 17 00:00:00 2001 From: dzikoysk Date: Fri, 1 Nov 2024 20:24:35 +0100 Subject: [PATCH] GH-2254 Convert current implementation of repositories into Maven-specific sources --- .../kotlin/com/reposilite/ReposiliteRunner.kt | 6 +- .../com/reposilite/ReposiliteSpecification.kt | 14 +-- .../configuration/SettingsIntegrationTest.kt | 2 +- .../kotlin/com/reposilite/packages}/.gitkeep | 0 .../maven/MavenApiIntegrationTest.kt | 4 +- .../maven/MavenIntegrationTest.kt | 4 +- .../maven/MavenMirrorsIntegrationTest.kt | 6 +- .../MavenIntegrationSpecification.kt | 2 +- .../statistics/StatisticsIntegrationTest.kt | 2 +- .../StatisticsIntegrationSpecification.kt | 2 +- .../javadocs/JavadocContainerService.kt | 34 +++--- .../com/reposilite/javadocs/JavadocFacade.kt | 26 ++--- .../reposilite/javadocs/api/JavadocsApi.kt | 6 +- .../javadocs/application/JavadocPlugin.kt | 6 +- .../infrastructure/JavadocEndpoints.kt | 2 +- .../kotlin/com/reposilite/packages/.gitkeep | 0 .../com/reposilite/packages/Repository.kt | 4 + .../{ => packages}/maven/LatestService.kt | 22 ++-- .../{ => packages}/maven/MavenFacade.kt | 62 +++++------ .../maven/MavenRepository.kt} | 12 +-- .../maven/MavenRepositoryFactory.kt} | 18 ++-- .../maven/MavenRepositoryLoopbackClient.kt} | 12 +-- .../maven/MavenRepositoryProvider.kt} | 28 ++--- .../maven/MavenRepositorySecurityProvider.kt} | 38 +++---- .../maven/MavenRepositoryService.kt} | 100 +++++++++--------- .../maven/MavenRepositoryVisibility.kt} | 4 +- .../{ => packages}/maven/MetadataService.kt | 52 ++++----- .../{ => packages}/maven/MirrorHost.kt | 4 +- .../{ => packages}/maven/MirrorService.kt | 42 ++++---- .../maven/PreservedBuildsListener.kt | 6 +- .../{ => packages}/maven/api/Checksum.kt | 2 +- .../{ => packages}/maven/api/DeleteApi.kt | 6 +- .../{ => packages}/maven/api/DeploymentApi.kt | 8 +- .../{ => packages}/maven/api/Identifier.kt | 2 +- .../{ => packages}/maven/api/LatestApi.kt | 12 +-- .../{ => packages}/maven/api/LookupApi.kt | 10 +- .../{ => packages}/maven/api/Metadata.kt | 2 +- .../{ => packages}/maven/api/MetadataApi.kt | 8 +- .../maven/application/MavenComponents.kt | 39 ++++--- .../maven/application/MavenPlugin.kt | 12 +-- .../maven/application/MavenSettings.kt | 12 +-- .../infrastructure/DirectoryIndexPage.kt | 2 +- .../maven/infrastructure/MavenApiEndpoints.kt | 18 ++-- .../maven/infrastructure/MavenEndpoints.kt | 10 +- .../infrastructure/MavenLatestApiEndpoints.kt | 27 +++-- .../maven/infrastructure/MavenRoutes.kt | 10 +- .../com/reposilite/packages/npm/.gitkeep | 0 .../com/reposilite/packages/oci/.gitkeep | 0 .../reposilite/statistics/StatisticsFacade.kt | 2 +- .../statistics/StatisticsRepository.kt | 2 +- .../reposilite/statistics/api/ResolvedApi.kt | 2 +- .../InMemoryStatisticsRepository.kt | 2 +- .../infrastructure/SqlStatisticsRepository.kt | 6 +- ...com.reposilite.plugin.api.ReposilitePlugin | 2 +- .../kotlin/com/reposilite/packages/.gitkeep | 0 .../{ => packages}/maven/MavenFacadeTest.kt | 48 ++++----- .../maven/PreservedBuildsListenerTest.kt | 20 ++-- .../{ => packages}/maven/ResolveEventTest.kt | 10 +- .../maven/specification/MavenSpecification.kt | 28 ++--- .../specification/StatisticsSpecification.kt | 2 +- .../plugin/checksum/ChecksumPlugin.kt | 6 +- .../plugin/prometheus/PrometheusPlugin.kt | 4 +- 62 files changed, 418 insertions(+), 416 deletions(-) rename reposilite-backend/src/{main/kotlin/com/reposilite/frontend => integration/kotlin/com/reposilite/packages}/.gitkeep (100%) rename reposilite-backend/src/integration/kotlin/com/reposilite/{ => packages}/maven/MavenApiIntegrationTest.kt (98%) rename reposilite-backend/src/integration/kotlin/com/reposilite/{ => packages}/maven/MavenIntegrationTest.kt (98%) rename reposilite-backend/src/integration/kotlin/com/reposilite/{ => packages}/maven/MavenMirrorsIntegrationTest.kt (94%) rename reposilite-backend/src/integration/kotlin/com/reposilite/{ => packages}/maven/specification/MavenIntegrationSpecification.kt (96%) create mode 100644 reposilite-backend/src/main/kotlin/com/reposilite/packages/.gitkeep create mode 100644 reposilite-backend/src/main/kotlin/com/reposilite/packages/Repository.kt rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/LatestService.kt (76%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/MavenFacade.kt (62%) rename reposilite-backend/src/main/kotlin/com/reposilite/{maven/Repository.kt => packages/maven/MavenRepository.kt} (93%) rename reposilite-backend/src/main/kotlin/com/reposilite/{maven/RepositoryFactory.kt => packages/maven/MavenRepositoryFactory.kt} (88%) rename reposilite-backend/src/main/kotlin/com/reposilite/{maven/RepositoryLoopbackClient.kt => packages/maven/MavenRepositoryLoopbackClient.kt} (90%) rename reposilite-backend/src/main/kotlin/com/reposilite/{maven/RepositoryProvider.kt => packages/maven/MavenRepositoryProvider.kt} (77%) rename reposilite-backend/src/main/kotlin/com/reposilite/{maven/RepositorySecurityProvider.kt => packages/maven/MavenRepositorySecurityProvider.kt} (54%) rename reposilite-backend/src/main/kotlin/com/reposilite/{maven/RepositoryService.kt => packages/maven/MavenRepositoryService.kt} (64%) rename reposilite-backend/src/main/kotlin/com/reposilite/{maven/RepositoryVisibility.kt => packages/maven/MavenRepositoryVisibility.kt} (89%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/MetadataService.kt (75%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/MirrorHost.kt (88%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/MirrorService.kt (62%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/PreservedBuildsListener.kt (93%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/api/Checksum.kt (89%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/api/DeleteApi.kt (85%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/api/DeploymentApi.kt (84%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/api/Identifier.kt (97%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/api/LatestApi.kt (86%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/api/LookupApi.kt (88%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/api/Metadata.kt (98%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/api/MetadataApi.kt (84%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/application/MavenComponents.kt (70%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/application/MavenPlugin.kt (89%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/application/MavenSettings.kt (94%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/infrastructure/DirectoryIndexPage.kt (97%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/infrastructure/MavenApiEndpoints.kt (91%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/infrastructure/MavenEndpoints.kt (96%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/infrastructure/MavenLatestApiEndpoints.kt (91%) rename reposilite-backend/src/main/kotlin/com/reposilite/{ => packages}/maven/infrastructure/MavenRoutes.kt (82%) create mode 100644 reposilite-backend/src/main/kotlin/com/reposilite/packages/npm/.gitkeep create mode 100644 reposilite-backend/src/main/kotlin/com/reposilite/packages/oci/.gitkeep create mode 100644 reposilite-backend/src/test/kotlin/com/reposilite/packages/.gitkeep rename reposilite-backend/src/test/kotlin/com/reposilite/{ => packages}/maven/MavenFacadeTest.kt (91%) rename reposilite-backend/src/test/kotlin/com/reposilite/{ => packages}/maven/PreservedBuildsListenerTest.kt (85%) rename reposilite-backend/src/test/kotlin/com/reposilite/{ => packages}/maven/ResolveEventTest.kt (85%) rename reposilite-backend/src/test/kotlin/com/reposilite/{ => packages}/maven/specification/MavenSpecification.kt (89%) diff --git a/reposilite-backend/src/integration/kotlin/com/reposilite/ReposiliteRunner.kt b/reposilite-backend/src/integration/kotlin/com/reposilite/ReposiliteRunner.kt index af23b464e..f25054d13 100644 --- a/reposilite-backend/src/integration/kotlin/com/reposilite/ReposiliteRunner.kt +++ b/reposilite-backend/src/integration/kotlin/com/reposilite/ReposiliteRunner.kt @@ -22,9 +22,9 @@ import com.reposilite.configuration.shared.SharedConfigurationFacade import com.reposilite.journalist.Channel import com.reposilite.journalist.Logger import com.reposilite.journalist.backend.PrintStreamLogger -import com.reposilite.maven.application.MavenSettings -import com.reposilite.maven.application.MirroredRepositorySettings -import com.reposilite.maven.application.RepositorySettings +import com.reposilite.packages.maven.application.MavenSettings +import com.reposilite.packages.maven.application.MirroredRepositorySettings +import com.reposilite.packages.maven.application.RepositorySettings import com.reposilite.storage.StorageProviderSettings import io.javalin.util.JavalinBindException import net.dzikoysk.cdn.KCdnFactory diff --git a/reposilite-backend/src/integration/kotlin/com/reposilite/ReposiliteSpecification.kt b/reposilite-backend/src/integration/kotlin/com/reposilite/ReposiliteSpecification.kt index 7804e9db6..1a85198eb 100644 --- a/reposilite-backend/src/integration/kotlin/com/reposilite/ReposiliteSpecification.kt +++ b/reposilite-backend/src/integration/kotlin/com/reposilite/ReposiliteSpecification.kt @@ -16,11 +16,11 @@ package com.reposilite -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.api.DeployRequest -import com.reposilite.maven.api.Metadata -import com.reposilite.maven.api.SaveMetadataRequest -import com.reposilite.maven.api.Versioning +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.api.DeployRequest +import com.reposilite.packages.maven.api.Metadata +import com.reposilite.packages.maven.api.SaveMetadataRequest +import com.reposilite.packages.maven.api.Versioning import com.reposilite.plugin.api.Facade import com.reposilite.shared.ErrorResponse import com.reposilite.storage.VersionComparator @@ -121,7 +121,7 @@ internal abstract class ReposiliteSpecification : ReposiliteRunner() { if (store) { mavenFacade.deployFile( DeployRequest( - repository = mavenFacade.getRepository(repository)!!, + mavenRepository = mavenFacade.getRepository(repository)!!, gav = "$gav/$file".toLocation(), by = "junit", content = content.byteInputStream(Charsets.UTF_8), @@ -147,7 +147,7 @@ internal abstract class ReposiliteSpecification : ReposiliteRunner() { return repository to mavenFacade.saveMetadata( SaveMetadataRequest( - repository = mavenFacade.getRepository(repository)!!, + mavenRepository = mavenFacade.getRepository(repository)!!, gav = "$groupId.$artifactId".replace(".", "/").toLocation(), metadata = metadata ) diff --git a/reposilite-backend/src/integration/kotlin/com/reposilite/configuration/SettingsIntegrationTest.kt b/reposilite-backend/src/integration/kotlin/com/reposilite/configuration/SettingsIntegrationTest.kt index cb07935a8..5eaeb5765 100644 --- a/reposilite-backend/src/integration/kotlin/com/reposilite/configuration/SettingsIntegrationTest.kt +++ b/reposilite-backend/src/integration/kotlin/com/reposilite/configuration/SettingsIntegrationTest.kt @@ -25,7 +25,7 @@ import com.reposilite.auth.application.AuthenticationSettings import com.reposilite.auth.application.LdapSettings import com.reposilite.configuration.shared.SharedConfigurationFacade import com.reposilite.configuration.specification.SettingsIntegrationSpecification -import com.reposilite.maven.application.MavenSettings +import com.reposilite.packages.maven.application.MavenSettings import com.reposilite.shared.ErrorResponse import com.reposilite.statistics.api.ResolvedRequestsInterval.YEARLY import com.reposilite.statistics.application.StatisticsSettings diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/frontend/.gitkeep b/reposilite-backend/src/integration/kotlin/com/reposilite/packages/.gitkeep similarity index 100% rename from reposilite-backend/src/main/kotlin/com/reposilite/frontend/.gitkeep rename to reposilite-backend/src/integration/kotlin/com/reposilite/packages/.gitkeep diff --git a/reposilite-backend/src/integration/kotlin/com/reposilite/maven/MavenApiIntegrationTest.kt b/reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/MavenApiIntegrationTest.kt similarity index 98% rename from reposilite-backend/src/integration/kotlin/com/reposilite/maven/MavenApiIntegrationTest.kt rename to reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/MavenApiIntegrationTest.kt index 8e0c7432f..c775aa061 100644 --- a/reposilite-backend/src/integration/kotlin/com/reposilite/maven/MavenApiIntegrationTest.kt +++ b/reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/MavenApiIntegrationTest.kt @@ -16,11 +16,11 @@ @file:Suppress("FunctionName") -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.RecommendedLocalSpecificationJunitExtension import com.reposilite.RecommendedRemoteSpecificationJunitExtension -import com.reposilite.maven.specification.MavenIntegrationSpecification +import com.reposilite.packages.maven.specification.MavenIntegrationSpecification import com.reposilite.token.RoutePermission.READ import io.javalin.http.HttpStatus.UNAUTHORIZED import kong.unirest.core.Unirest.get diff --git a/reposilite-backend/src/integration/kotlin/com/reposilite/maven/MavenIntegrationTest.kt b/reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/MavenIntegrationTest.kt similarity index 98% rename from reposilite-backend/src/integration/kotlin/com/reposilite/maven/MavenIntegrationTest.kt rename to reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/MavenIntegrationTest.kt index 692328144..31d9c5b31 100644 --- a/reposilite-backend/src/integration/kotlin/com/reposilite/maven/MavenIntegrationTest.kt +++ b/reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/MavenIntegrationTest.kt @@ -16,12 +16,12 @@ @file:Suppress("FunctionName") -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.RecommendedLocalSpecificationJunitExtension import com.reposilite.RecommendedRemoteSpecificationJunitExtension import com.reposilite.configuration.local.LocalConfiguration -import com.reposilite.maven.specification.MavenIntegrationSpecification +import com.reposilite.packages.maven.specification.MavenIntegrationSpecification import com.reposilite.shared.ErrorResponse import com.reposilite.shared.extensions.maxAge import com.reposilite.storage.api.DocumentInfo diff --git a/reposilite-backend/src/integration/kotlin/com/reposilite/maven/MavenMirrorsIntegrationTest.kt b/reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/MavenMirrorsIntegrationTest.kt similarity index 94% rename from reposilite-backend/src/integration/kotlin/com/reposilite/maven/MavenMirrorsIntegrationTest.kt rename to reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/MavenMirrorsIntegrationTest.kt index 14ff3184e..dac9c634a 100644 --- a/reposilite-backend/src/integration/kotlin/com/reposilite/maven/MavenMirrorsIntegrationTest.kt +++ b/reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/MavenMirrorsIntegrationTest.kt @@ -1,11 +1,11 @@ @file:Suppress("FunctionName") -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.RecommendedLocalSpecificationJunitExtension import com.reposilite.RecommendedRemoteSpecificationJunitExtension -import com.reposilite.maven.api.LookupRequest -import com.reposilite.maven.specification.MavenIntegrationSpecification +import com.reposilite.packages.maven.api.LookupRequest +import com.reposilite.packages.maven.specification.MavenIntegrationSpecification import com.reposilite.storage.api.toLocation import kong.unirest.core.Unirest.get import kotlinx.coroutines.runBlocking diff --git a/reposilite-backend/src/integration/kotlin/com/reposilite/maven/specification/MavenIntegrationSpecification.kt b/reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/specification/MavenIntegrationSpecification.kt similarity index 96% rename from reposilite-backend/src/integration/kotlin/com/reposilite/maven/specification/MavenIntegrationSpecification.kt rename to reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/specification/MavenIntegrationSpecification.kt index 5d28c4419..1b7a85717 100644 --- a/reposilite-backend/src/integration/kotlin/com/reposilite/maven/specification/MavenIntegrationSpecification.kt +++ b/reposilite-backend/src/integration/kotlin/com/reposilite/packages/maven/specification/MavenIntegrationSpecification.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.reposilite.maven.specification +package com.reposilite.packages.maven.specification import com.reposilite.ReposiliteSpecification import io.javalin.Javalin diff --git a/reposilite-backend/src/integration/kotlin/com/reposilite/statistics/StatisticsIntegrationTest.kt b/reposilite-backend/src/integration/kotlin/com/reposilite/statistics/StatisticsIntegrationTest.kt index f08c2587b..9b9ac9636 100644 --- a/reposilite-backend/src/integration/kotlin/com/reposilite/statistics/StatisticsIntegrationTest.kt +++ b/reposilite-backend/src/integration/kotlin/com/reposilite/statistics/StatisticsIntegrationTest.kt @@ -22,7 +22,7 @@ import com.reposilite.ExperimentalLocalSpecificationJunitExtension import com.reposilite.ExperimentalRemoteSpecficiationJunitExtension import com.reposilite.RecommendedLocalSpecificationJunitExtension import com.reposilite.RecommendedRemoteSpecificationJunitExtension -import com.reposilite.maven.api.Identifier +import com.reposilite.packages.maven.api.Identifier import com.reposilite.statistics.api.AllResolvedResponse import com.reposilite.statistics.api.IntervalRecord import com.reposilite.statistics.api.RepositoryStatistics diff --git a/reposilite-backend/src/integration/kotlin/com/reposilite/statistics/specification/StatisticsIntegrationSpecification.kt b/reposilite-backend/src/integration/kotlin/com/reposilite/statistics/specification/StatisticsIntegrationSpecification.kt index 2c49dd159..be35e8f44 100644 --- a/reposilite-backend/src/integration/kotlin/com/reposilite/statistics/specification/StatisticsIntegrationSpecification.kt +++ b/reposilite-backend/src/integration/kotlin/com/reposilite/statistics/specification/StatisticsIntegrationSpecification.kt @@ -17,7 +17,7 @@ package com.reposilite.statistics.specification import com.reposilite.ReposiliteSpecification -import com.reposilite.maven.api.Identifier +import com.reposilite.packages.maven.api.Identifier import com.reposilite.statistics.StatisticsFacade import io.javalin.http.HttpStatus.OK import kong.unirest.core.Unirest.get diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocContainerService.kt b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocContainerService.kt index 05143bf2e..edf5e9af9 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocContainerService.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocContainerService.kt @@ -1,8 +1,8 @@ package com.reposilite.javadocs -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.Repository -import com.reposilite.maven.api.LookupRequest +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.MavenRepository +import com.reposilite.packages.maven.api.LookupRequest import com.reposilite.shared.ErrorResponse import com.reposilite.shared.badRequest import com.reposilite.shared.badRequestError @@ -39,22 +39,22 @@ internal class JavadocContainerService( private val javadocFolder: Path ) { - fun loadContainer(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Result { - val javadocJar = this.resolveJavadocJar(repository, gav) ?: return badRequestError("Invalid GAV") + fun loadContainer(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Result { + val javadocJar = this.resolveJavadocJar(mavenRepository, gav) ?: return badRequestError("Invalid GAV") - return mavenFacade.findDetails(LookupRequest(accessToken, repository.name, javadocJar)) + return mavenFacade.findDetails(LookupRequest(accessToken, mavenRepository.name, javadocJar)) .filter({ it.type === FILE }, { badRequest("Invalid request") }) .filter({ isJavadocJar(it.name) }, { notFound("Please do not provide a direct link to a non javadoc file! GAV must be pointing to a directory or a javadoc file!") }) - .flatMap { loadJavadocJarContainer(accessToken, repository, javadocJar) } + .flatMap { loadJavadocJarContainer(accessToken, mavenRepository, javadocJar) } } - private fun resolveJavadocJar(repository: Repository, gav: Location): Location? = when { + private fun resolveJavadocJar(mavenRepository: MavenRepository, gav: Location): Location? = when { gav.endsWith(".jar") -> gav - gav.endsWith("/$INDEX_FILE") -> resolveIndexGav(repository, gav) - else -> resolveJavadocJar(repository, gav.resolve(INDEX_FILE)) + gav.endsWith("/$INDEX_FILE") -> resolveIndexGav(mavenRepository, gav) + else -> resolveJavadocJar(mavenRepository, gav.resolve(INDEX_FILE)) } - private fun resolveIndexGav(repository: Repository, gav: Location): Location? { + private fun resolveIndexGav(mavenRepository: MavenRepository, gav: Location): Location? { val rootGav = gav.locationBeforeLast("/$INDEX_FILE") val elements = rootGav.toString().split("/") @@ -66,7 +66,7 @@ internal class JavadocContainerService( var version = elements[elements.size - 1] if (version.contains("-SNAPSHOT")) { - val metadataResult = mavenFacade.findMetadata(repository, rootGav) + val metadataResult = mavenFacade.findMetadata(mavenRepository, rootGav) val snapshot = if (metadataResult.isOk) metadataResult.get().versioning?.snapshot else null if (snapshot?.timestamp != null && snapshot.buildNumber != null) { @@ -77,8 +77,8 @@ internal class JavadocContainerService( return rootGav.resolve("${name}-${version}-javadoc.jar") } - private fun loadJavadocJarContainer(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Result { - val container: JavadocContainer = createContainer(javadocFolder, repository, gav) + private fun loadJavadocJarContainer(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Result { + val container: JavadocContainer = createContainer(javadocFolder, mavenRepository, gav) if (Files.exists(container.javadocContainerIndex)) { return Result.ok(container) @@ -89,16 +89,16 @@ internal class JavadocContainerService( Files.createDirectories(javadocUnpackPath) val copyJarPath = javadocUnpackPath.resolve("javadoc.jar") - return mavenFacade.findFile(LookupRequest(accessToken, repository.name, gav)) + return mavenFacade.findFile(LookupRequest(accessToken, mavenRepository.name, gav)) .peek { (_, originInput) -> this.copyJavadocJar(originInput, copyJarPath) } .flatMap { this.unpackJavadocJar(copyJarPath, javadocUnpackPath) } .peek { this.createDocIndexHtml(container) } .map { container } } - internal fun createContainer(javadocFolder: Path, repository: Repository, jarLocation: Location): JavadocContainer { + internal fun createContainer(javadocFolder: Path, mavenRepository: MavenRepository, jarLocation: Location): JavadocContainer { val javadocContainerPath = javadocFolder - .resolve(repository.name) + .resolve(mavenRepository.name) .resolve(jarLocation.locationBeforeLast("/").toString()) .resolve(".cache") diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocFacade.kt b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocFacade.kt index 1525796b5..65f6548c6 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocFacade.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocFacade.kt @@ -22,9 +22,9 @@ import com.reposilite.javadocs.api.JavadocRawResponse import com.reposilite.javadocs.api.JavadocResponse import com.reposilite.journalist.Journalist import com.reposilite.journalist.Logger -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.Repository -import com.reposilite.maven.api.VersionLookupRequest +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.MavenRepository +import com.reposilite.packages.maven.api.VersionLookupRequest import com.reposilite.plugin.api.Facade import com.reposilite.shared.ErrorResponse import com.reposilite.shared.notFound @@ -65,15 +65,15 @@ class JavadocFacade internal constructor( fun findJavadocPage(request: JavadocPageRequest): Result = with (request) { - mavenFacade.canAccessResource(accessToken, repository, gav) - .flatMap { createPage(accessToken, repository, resolveGav(request)) } + mavenFacade.canAccessResource(accessToken, mavenRepository, gav) + .flatMap { createPage(accessToken, mavenRepository, resolveGav(request)) } .onError { logger.error("Cannot extract javadoc: ${it.message} (${it.status})}") } } fun findRawJavadocResource(request: JavadocRawRequest): Result = with (request) { - mavenFacade.canAccessResource(accessToken, repository, gav) - .flatMap { javadocContainerService.loadContainer(accessToken, repository, gav) } + mavenFacade.canAccessResource(accessToken, mavenRepository, gav) + .flatMap { javadocContainerService.loadContainer(accessToken, mavenRepository, gav) } .filter({ Files.exists(it.javadocUnpackPath.resolve(resource.toString())) }, { notFound("Resource $resource not found") }) .map { JavadocRawResponse( @@ -83,8 +83,8 @@ class JavadocFacade internal constructor( } } - private fun createPage(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Result { - val resourcesFile = createPlainFile(javadocFolder, repository, gav) + private fun createPage(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Result { + val resourcesFile = createPlainFile(javadocFolder, mavenRepository, gav) return when { /* File not found */ @@ -103,14 +103,14 @@ class JavadocFacade internal constructor( /* Load resource */ else -> javadocContainerService - .loadContainer(accessToken, repository, gav) + .loadContainer(accessToken, mavenRepository, gav) .map { JavadocResponse(ContentType.HTML, readFile(it.javadocContainerIndex)) } } } - private fun createPlainFile(javadocFolder: Path, repository: Repository, gav: Location): JavadocPlainFile? = + private fun createPlainFile(javadocFolder: Path, mavenRepository: MavenRepository, gav: Location): JavadocPlainFile? = javadocFolder - .resolve(repository.name) + .resolve(mavenRepository.name) .resolve(gav.toString()) .let { targetPath -> targetPath to supportedExtensions[gav.getExtension()] } .takeIf { (_, contentType) -> contentType != null } @@ -123,7 +123,7 @@ class JavadocFacade internal constructor( request.gav .takeIf { it.contains("/latest") } ?.let { request.gav.locationBeforeLast("/latest") } - ?.let { gavWithoutVersion -> VersionLookupRequest(request.accessToken, request.repository, gavWithoutVersion) } + ?.let { gavWithoutVersion -> VersionLookupRequest(request.accessToken, request.mavenRepository, gavWithoutVersion) } ?.let { mavenFacade.findLatestVersion(it) } ?.map { request.gav.replace(LATEST_PATTERN, "/%s".format(it.version)) } ?.orNull() diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/api/JavadocsApi.kt b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/api/JavadocsApi.kt index c512af883..ec7f87c20 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/api/JavadocsApi.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/api/JavadocsApi.kt @@ -1,6 +1,6 @@ package com.reposilite.javadocs.api -import com.reposilite.maven.Repository +import com.reposilite.packages.maven.MavenRepository import com.reposilite.storage.api.Location import com.reposilite.token.AccessTokenIdentifier import io.javalin.http.ContentType @@ -8,13 +8,13 @@ import java.io.InputStream data class JavadocPageRequest( val accessToken: AccessTokenIdentifier?, - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location ) data class JavadocRawRequest( val accessToken: AccessTokenIdentifier?, - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location, val resource: Location ) diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/application/JavadocPlugin.kt b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/application/JavadocPlugin.kt index d4bfff53b..848ef27ab 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/application/JavadocPlugin.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/application/JavadocPlugin.kt @@ -19,8 +19,8 @@ package com.reposilite.javadocs.application import com.reposilite.javadocs.JavadocContainerService import com.reposilite.javadocs.JavadocFacade import com.reposilite.javadocs.infrastructure.JavadocEndpoints -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.api.DeployEvent +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.api.DeployEvent import com.reposilite.plugin.api.Facade import com.reposilite.plugin.api.Plugin import com.reposilite.plugin.api.ReposilitePlugin @@ -56,7 +56,7 @@ internal class JavadocPlugin : ReposilitePlugin() { .takeIf { it.toString().endsWith("-javadoc.jar") } ?: return@event - val container = javadocContainerService.createContainer(javadocFolder, event.repository, gav) + val container = javadocContainerService.createContainer(javadocFolder, event.mavenRepository, gav) val javadocDirectory = container.javadocContainerPath.toFile() if (javadocDirectory.exists()) { diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/infrastructure/JavadocEndpoints.kt b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/infrastructure/JavadocEndpoints.kt index e839da87e..d66713112 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/infrastructure/JavadocEndpoints.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/infrastructure/JavadocEndpoints.kt @@ -19,7 +19,7 @@ package com.reposilite.javadocs.infrastructure import com.reposilite.javadocs.JavadocFacade import com.reposilite.javadocs.api.JavadocPageRequest import com.reposilite.javadocs.api.JavadocRawRequest -import com.reposilite.maven.infrastructure.MavenRoutes +import com.reposilite.packages.maven.infrastructure.MavenRoutes import com.reposilite.shared.extensions.encoding import com.reposilite.storage.api.toLocation import com.reposilite.web.api.ReposiliteRoute diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/packages/.gitkeep b/reposilite-backend/src/main/kotlin/com/reposilite/packages/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/packages/Repository.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/Repository.kt new file mode 100644 index 000000000..fa544a6b6 --- /dev/null +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/Repository.kt @@ -0,0 +1,4 @@ +package com.reposilite.packages + +interface Repository { +} \ No newline at end of file diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/LatestService.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/LatestService.kt similarity index 76% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/LatestService.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/LatestService.kt index 198fc6d78..f29090e43 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/LatestService.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/LatestService.kt @@ -14,14 +14,14 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven -import com.reposilite.maven.api.LatestArtifactQuery -import com.reposilite.maven.api.LatestArtifactQueryRequest -import com.reposilite.maven.api.LatestBadgeRequest -import com.reposilite.maven.api.LatestVersionResponse -import com.reposilite.maven.api.LookupRequest -import com.reposilite.maven.api.VersionLookupRequest +import com.reposilite.packages.maven.api.LatestArtifactQuery +import com.reposilite.packages.maven.api.LatestArtifactQueryRequest +import com.reposilite.packages.maven.api.LatestBadgeRequest +import com.reposilite.packages.maven.api.LatestVersionResponse +import com.reposilite.packages.maven.api.LookupRequest +import com.reposilite.packages.maven.api.VersionLookupRequest import com.reposilite.shared.BadgeGenerator import com.reposilite.shared.ErrorResponse import com.reposilite.storage.api.Location @@ -46,14 +46,14 @@ internal class LatestService(private val repositoryId: Reference) { optionalColor = request.color ) - fun queryLatestArtifact(request: LatestArtifactQueryRequest, supplier: LatestVersionSupplier, handler: MatchedVersionHandler): Result = + fun queryLatestArtifact(request: LatestArtifactQueryRequest, supplier: com.reposilite.packages.maven.LatestVersionSupplier, handler: com.reposilite.packages.maven.MatchedVersionHandler): Result = supplier.findLatestVersion(request.toVersionLookupRequest()) .map { (isSnapshot, version) -> createLatestArtifactLocation(request.query, isSnapshot, version) } .flatMap { (version, fileLocation) -> matchLocation(request, supplier, handler, version, fileLocation) } - private fun matchLocation(request: LatestArtifactQueryRequest, supplier: LatestVersionSupplier, handler: MatchedVersionHandler, version: String, fileLocation: Location) = + private fun matchLocation(request: LatestArtifactQueryRequest, supplier: com.reposilite.packages.maven.LatestVersionSupplier, handler: com.reposilite.packages.maven.MatchedVersionHandler, version: String, fileLocation: Location) = handler - .onMatch(LookupRequest(request.accessToken, request.repository.name, fileLocation)) + .onMatch(LookupRequest(request.accessToken, request.mavenRepository.name, fileLocation)) .flatMapErr { version .takeIf { version.contains("-SNAPSHOT", ignoreCase = true) } @@ -61,7 +61,7 @@ internal class LatestService(private val repositoryId: Reference) { ?: Result.error(it) } - private fun matchSnapshotLocation(request: LatestArtifactQueryRequest, supplier: LatestVersionSupplier, handler: MatchedVersionHandler, version: String) = + private fun matchSnapshotLocation(request: LatestArtifactQueryRequest, supplier: com.reposilite.packages.maven.LatestVersionSupplier, handler: com.reposilite.packages.maven.MatchedVersionHandler, version: String) = queryLatestArtifact( request = request.copy( query = request.query.copy( diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MavenFacade.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenFacade.kt similarity index 62% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/MavenFacade.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenFacade.kt index e789c2d97..0383ab760 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MavenFacade.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenFacade.kt @@ -14,22 +14,22 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.journalist.Journalist import com.reposilite.journalist.Logger -import com.reposilite.maven.api.DeleteRequest -import com.reposilite.maven.api.DeployRequest -import com.reposilite.maven.api.GeneratePomRequest -import com.reposilite.maven.api.LatestArtifactQueryRequest -import com.reposilite.maven.api.LatestBadgeRequest -import com.reposilite.maven.api.LatestVersionResponse -import com.reposilite.maven.api.LookupRequest -import com.reposilite.maven.api.Metadata -import com.reposilite.maven.api.ResolvedDocument -import com.reposilite.maven.api.SaveMetadataRequest -import com.reposilite.maven.api.VersionLookupRequest -import com.reposilite.maven.api.VersionsResponse +import com.reposilite.packages.maven.api.DeleteRequest +import com.reposilite.packages.maven.api.DeployRequest +import com.reposilite.packages.maven.api.GeneratePomRequest +import com.reposilite.packages.maven.api.LatestArtifactQueryRequest +import com.reposilite.packages.maven.api.LatestBadgeRequest +import com.reposilite.packages.maven.api.LatestVersionResponse +import com.reposilite.packages.maven.api.LookupRequest +import com.reposilite.packages.maven.api.Metadata +import com.reposilite.packages.maven.api.ResolvedDocument +import com.reposilite.packages.maven.api.SaveMetadataRequest +import com.reposilite.packages.maven.api.VersionLookupRequest +import com.reposilite.packages.maven.api.VersionsResponse import com.reposilite.plugin.api.Facade import com.reposilite.shared.ErrorResponse import com.reposilite.storage.api.DirectoryInfo @@ -41,13 +41,13 @@ import java.io.InputStream class MavenFacade internal constructor( private val journalist: Journalist, - private val repositorySecurityProvider: RepositorySecurityProvider, - private val repositoryProvider: RepositoryProvider, + private val mavenRepositorySecurityProvider: MavenRepositorySecurityProvider, + private val mavenRepositoryProvider: MavenRepositoryProvider, private val metadataService: MetadataService, - private val latestService: LatestService, + private val latestService: com.reposilite.packages.maven.LatestService, ) : Journalist, Facade { - private val repositoryService = repositoryProvider.repositoryService + private val repositoryService = mavenRepositoryProvider.mavenRepositoryService fun findDetails(lookupRequest: LookupRequest): Result = repositoryService.findDetails(lookupRequest) @@ -70,18 +70,18 @@ class MavenFacade internal constructor( fun generatePom(generatePomRequest: GeneratePomRequest): Result = metadataService.generatePom(generatePomRequest) - fun findMetadata(repository: Repository, gav: Location): Result = - metadataService.findMetadata(repository, gav) + fun findMetadata(mavenRepository: MavenRepository, gav: Location): Result = + metadataService.findMetadata(mavenRepository, gav) fun findVersions(lookupRequest: VersionLookupRequest): Result = - repositorySecurityProvider.canAccessResource(lookupRequest.accessToken, lookupRequest.repository, lookupRequest.gav) - .flatMap { metadataService.findVersions(lookupRequest.repository, lookupRequest.gav, lookupRequest.filter) } + mavenRepositorySecurityProvider.canAccessResource(lookupRequest.accessToken, lookupRequest.mavenRepository, lookupRequest.gav) + .flatMap { metadataService.findVersions(lookupRequest.mavenRepository, lookupRequest.gav, lookupRequest.filter) } fun findLatestVersion(lookupRequest: VersionLookupRequest): Result = - repositorySecurityProvider.canAccessResource(lookupRequest.accessToken, lookupRequest.repository, lookupRequest.gav) - .flatMap { metadataService.findLatestVersion(lookupRequest.repository, lookupRequest.gav, lookupRequest.filter) } + mavenRepositorySecurityProvider.canAccessResource(lookupRequest.accessToken, lookupRequest.mavenRepository, lookupRequest.gav) + .flatMap { metadataService.findLatestVersion(lookupRequest.mavenRepository, lookupRequest.gav, lookupRequest.filter) } - fun findLatestVersionFile(latestArtifactQueryRequest: LatestArtifactQueryRequest, handler: MatchedVersionHandler): Result = + fun findLatestVersionFile(latestArtifactQueryRequest: LatestArtifactQueryRequest, handler: com.reposilite.packages.maven.MatchedVersionHandler): Result = latestService.queryLatestArtifact( request = latestArtifactQueryRequest, supplier = { findLatestVersion(it) }, @@ -91,9 +91,9 @@ class MavenFacade internal constructor( fun getAvailableFiles(request: LookupRequest, directoryInfo: DirectoryInfo): List = getRepository(request.repository)!!.let { repository -> directoryInfo.files.filter { - repositorySecurityProvider.canBrowseResource( + mavenRepositorySecurityProvider.canBrowseResource( accessToken = request.accessToken, - repository = repository, + mavenRepository = repository, gav = request.gav.resolve(it.name) ).isOk } @@ -106,17 +106,17 @@ class MavenFacade internal constructor( fun acceptsCachingOf(request: LookupRequest): Boolean = getRepository(request.repository)?.acceptsCachingOf(request.gav) ?: false - fun canAccessResource(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Result = - repositorySecurityProvider.canAccessResource(accessToken, repository, gav) + fun canAccessResource(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Result = + mavenRepositorySecurityProvider.canAccessResource(accessToken, mavenRepository, gav) fun findRepositories(accessToken: AccessTokenIdentifier?): DirectoryInfo = repositoryService.getRootDirectory(accessToken) fun getRepository(name: String) = - repositoryService.repositoryProvider.getRepository(name) + repositoryService.mavenRepositoryProvider.getRepository(name) - fun getRepositories(): Collection = - repositoryService.repositoryProvider.getRepositories() + fun getRepositories(): Collection = + repositoryService.mavenRepositoryProvider.getRepositories() override fun getLogger(): Logger = journalist.logger diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/Repository.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepository.kt similarity index 93% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/Repository.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepository.kt index e201e2730..1f00ea954 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/Repository.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepository.kt @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven -import com.reposilite.maven.api.Checksum -import com.reposilite.maven.api.METADATA_FILE -import com.reposilite.maven.api.REPOSITORY_NAME_MAX_LENGTH +import com.reposilite.packages.maven.api.Checksum +import com.reposilite.packages.maven.api.METADATA_FILE +import com.reposilite.packages.maven.api.REPOSITORY_NAME_MAX_LENGTH import com.reposilite.shared.ErrorResponse import com.reposilite.storage.StorageProvider import com.reposilite.storage.api.FileDetails @@ -28,9 +28,9 @@ import java.nio.file.attribute.FileTime import panda.std.Result @Suppress("DeprecatedCallableAddReplaceWith") -class Repository internal constructor( +class MavenRepository internal constructor( val name: String, - val visibility: RepositoryVisibility, + val visibility: MavenRepositoryVisibility, val redeployment: Boolean, val preserveSnapshots: Boolean, val mirrorHosts: List, diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryFactory.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryFactory.kt similarity index 88% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryFactory.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryFactory.kt index aedbb02c1..9d090e222 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryFactory.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryFactory.kt @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.auth.AuthenticationFacade import com.reposilite.journalist.Journalist -import com.reposilite.maven.application.MirroredRepositorySettings -import com.reposilite.maven.application.RepositorySettings +import com.reposilite.packages.maven.application.MirroredRepositorySettings +import com.reposilite.packages.maven.application.RepositorySettings import com.reposilite.shared.http.RemoteClientProvider import com.reposilite.shared.http.createHttpProxy import com.reposilite.status.FailureFacade @@ -28,12 +28,12 @@ import java.nio.file.Path import java.nio.file.Paths import java.util.UUID -internal class RepositoryFactory( +internal class MavenRepositoryFactory( private val journalist: Journalist, private val workingDirectory: Path, private val authenticationFacade: AuthenticationFacade, private val remoteClientProvider: RemoteClientProvider, - private val repositoryService: RepositoryService, + private val mavenRepositoryService: MavenRepositoryService, private val failureFacade: FailureFacade, private val storageFacade: StorageFacade, private val repositoriesNames: Collection, @@ -41,8 +41,8 @@ internal class RepositoryFactory( private val repositoriesDirectory = Paths.get("repositories") - fun createRepository(repositoryName: String, configuration: RepositorySettings): Repository = - Repository( + fun createRepository(repositoryName: String, configuration: RepositorySettings): MavenRepository = + MavenRepository( name = repositoryName.ifEmpty { UUID.randomUUID().toString() }, visibility = configuration.visibility, redeployment = configuration.redeployment, @@ -76,9 +76,9 @@ internal class RepositoryFactory( val remoteClient = when { repositoriesNames.contains(host) -> - RepositoryLoopbackClient( + MavenRepositoryLoopbackClient( authenticationFacade = authenticationFacade, - repositoryService = repositoryService, + mavenRepositoryService = mavenRepositoryService, repositoryName = host ) else -> diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryLoopbackClient.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryLoopbackClient.kt similarity index 90% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryLoopbackClient.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryLoopbackClient.kt index affd04a0f..c163df6ab 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryLoopbackClient.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryLoopbackClient.kt @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.auth.AuthenticationFacade import com.reposilite.auth.api.Credentials -import com.reposilite.maven.api.LookupRequest +import com.reposilite.packages.maven.api.LookupRequest import com.reposilite.shared.ErrorResponse import com.reposilite.shared.http.AuthenticationMethod.LOOPBACK_LINK import com.reposilite.shared.http.RemoteClient @@ -33,14 +33,14 @@ import panda.std.Option import panda.std.Result import java.io.InputStream -internal class RepositoryLoopbackClient( +internal class MavenRepositoryLoopbackClient( private val authenticationFacade: AuthenticationFacade, - private val repositoryService: RepositoryService, + private val mavenRepositoryService: MavenRepositoryService, private val repositoryName: String ) : RemoteClient { override fun head(uri: String, credentials: RemoteCredentials?, connectTimeoutInSeconds: Int, readTimeoutInSeconds: Int): Result = - repositoryService.findDetails( + mavenRepositoryService.findDetails( LookupRequest( accessToken = credentials.toAccessToken(), repository = repositoryName, @@ -49,7 +49,7 @@ internal class RepositoryLoopbackClient( ) override fun get(uri: String, credentials: RemoteCredentials?, connectTimeoutInSeconds: Int, readTimeoutInSeconds: Int): Result = - repositoryService.findFile( + mavenRepositoryService.findFile( LookupRequest( accessToken = credentials.toAccessToken(), repository = repositoryName, diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryProvider.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryProvider.kt similarity index 77% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryProvider.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryProvider.kt index 3b8a4c98d..e905532a6 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryProvider.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryProvider.kt @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.auth.AuthenticationFacade import com.reposilite.journalist.Journalist -import com.reposilite.maven.application.RepositorySettings +import com.reposilite.packages.maven.application.RepositorySettings import com.reposilite.plugin.Extensions import com.reposilite.shared.ErrorResponse import com.reposilite.shared.http.RemoteClientProvider @@ -31,7 +31,7 @@ import panda.std.Result import panda.std.asSuccess import panda.std.reactive.Reference -internal class RepositoryProvider( +internal class MavenRepositoryProvider( private val journalist: Journalist, private val workingDirectory: Path, private val remoteClientProvider: RemoteClientProvider, @@ -41,20 +41,20 @@ internal class RepositoryProvider( statisticsFacade: StatisticsFacade, private val storageFacade: StorageFacade, mirrorService: MirrorService, - repositorySecurityProvider: RepositorySecurityProvider, + mavenRepositorySecurityProvider: MavenRepositorySecurityProvider, repositoriesSource: Reference>, ) { - val repositoryService = RepositoryService( + val mavenRepositoryService = MavenRepositoryService( journalist = journalist, - repositoryProvider = this, - securityProvider = repositorySecurityProvider, + mavenRepositoryProvider = this, + securityProvider = mavenRepositorySecurityProvider, mirrorService = mirrorService, statisticsFacade = statisticsFacade, extensions = extensions ) - private var repositories: Map = createRepositories(repositoriesSource.get()) + private var repositories: Map = createRepositories(repositoriesSource.get()) init { repositoriesSource.subscribe { @@ -63,15 +63,15 @@ internal class RepositoryProvider( } } - private fun createRepositories(repositoriesConfiguration: List): Map { - val factory = RepositoryFactory( + private fun createRepositories(repositoriesConfiguration: List): Map { + val factory = MavenRepositoryFactory( journalist = journalist, workingDirectory = workingDirectory, authenticationFacade = authenticationFacade, remoteClientProvider = remoteClientProvider, failureFacade = failureFacade, storageFacade = storageFacade, - repositoryService = repositoryService, + mavenRepositoryService = mavenRepositoryService, repositoriesNames = repositoriesConfiguration.map { it.id }, ) @@ -85,15 +85,15 @@ internal class RepositoryProvider( } - fun findRepository(name: String): Result = + fun findRepository(name: String): Result = getRepository(name) ?.asSuccess() ?: notFoundError("Repository $name not found") - fun getRepository(name: String): Repository? = + fun getRepository(name: String): MavenRepository? = repositories[name] - fun getRepositories(): Collection = + fun getRepositories(): Collection = repositories.values } diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositorySecurityProvider.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositorySecurityProvider.kt similarity index 54% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositorySecurityProvider.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositorySecurityProvider.kt index 5529ee100..34f7d597f 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositorySecurityProvider.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositorySecurityProvider.kt @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven -import com.reposilite.maven.RepositoryVisibility.HIDDEN -import com.reposilite.maven.RepositoryVisibility.PRIVATE -import com.reposilite.maven.RepositoryVisibility.PUBLIC +import com.reposilite.packages.maven.MavenRepositoryVisibility.HIDDEN +import com.reposilite.packages.maven.MavenRepositoryVisibility.PRIVATE +import com.reposilite.packages.maven.MavenRepositoryVisibility.PUBLIC import com.reposilite.shared.ErrorResponse import com.reposilite.shared.toErrorResponse import com.reposilite.shared.unauthorizedError @@ -31,35 +31,35 @@ import com.reposilite.token.RoutePermission.WRITE import io.javalin.http.HttpStatus.FORBIDDEN import panda.std.Result -internal class RepositorySecurityProvider(private val accessTokenFacade: AccessTokenFacade) { +internal class MavenRepositorySecurityProvider(private val accessTokenFacade: AccessTokenFacade) { - fun canAccessRepository(accessToken: AccessTokenIdentifier?, repository: Repository): Boolean = - when (repository.visibility) { + fun canAccessRepository(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository): Boolean = + when (mavenRepository.visibility) { PUBLIC -> true - HIDDEN, PRIVATE -> accessToken?.let { accessTokenFacade.canSee(it, "/${repository.name}") } ?: false + HIDDEN, PRIVATE -> accessToken?.let { accessTokenFacade.canSee(it, "/${mavenRepository.name}") } ?: false } - fun canAccessResource(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Result = - when (repository.visibility) { + fun canAccessResource(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Result = + when (mavenRepository.visibility) { PUBLIC -> Result.ok(Unit) HIDDEN -> Result.ok(Unit) - PRIVATE -> hasPermissionTo(accessToken, repository, gav, READ) + PRIVATE -> hasPermissionTo(accessToken, mavenRepository, gav, READ) } - fun canBrowseResource(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Result = - when (repository.visibility) { + fun canBrowseResource(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Result = + when (mavenRepository.visibility) { PUBLIC -> Result.ok(Unit) - HIDDEN -> hasPermissionTo(accessToken, repository, gav, READ) - PRIVATE -> hasPermissionTo(accessToken, repository, gav, READ) + HIDDEN -> hasPermissionTo(accessToken, mavenRepository, gav, READ) + PRIVATE -> hasPermissionTo(accessToken, mavenRepository, gav, READ) } - fun canModifyResource(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Boolean = - hasPermissionTo(accessToken, repository, gav, WRITE).isOk + fun canModifyResource(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Boolean = + hasPermissionTo(accessToken, mavenRepository, gav, WRITE).isOk - private fun hasPermissionTo(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location, permission: RoutePermission): Result = + private fun hasPermissionTo(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location, permission: RoutePermission): Result = accessToken ?.let { - Result.`when`(accessTokenFacade.hasPermissionTo(accessToken, "/${repository.name}/$gav", permission), + Result.`when`(accessTokenFacade.hasPermissionTo(accessToken, "/${mavenRepository.name}/$gav", permission), { }, { FORBIDDEN.toErrorResponse("You must be the token owner or a manager to access this.") } ) diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryService.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryService.kt similarity index 64% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryService.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryService.kt index 4293dba4b..6a888293c 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryService.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryService.kt @@ -13,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.journalist.Journalist import com.reposilite.journalist.Logger -import com.reposilite.maven.api.DeleteRequest -import com.reposilite.maven.api.DeployEvent -import com.reposilite.maven.api.DeployRequest -import com.reposilite.maven.api.Identifier -import com.reposilite.maven.api.LookupRequest -import com.reposilite.maven.api.PreResolveEvent -import com.reposilite.maven.api.ResolvedDocument -import com.reposilite.maven.api.ResolvedFileEvent +import com.reposilite.packages.maven.api.DeleteRequest +import com.reposilite.packages.maven.api.DeployEvent +import com.reposilite.packages.maven.api.DeployRequest +import com.reposilite.packages.maven.api.Identifier +import com.reposilite.packages.maven.api.LookupRequest +import com.reposilite.packages.maven.api.PreResolveEvent +import com.reposilite.packages.maven.api.ResolvedDocument +import com.reposilite.packages.maven.api.ResolvedFileEvent import com.reposilite.plugin.Extensions import com.reposilite.shared.ErrorResponse import com.reposilite.shared.errorResponse @@ -46,10 +46,10 @@ import panda.std.asSuccess import panda.std.ok import java.io.InputStream -internal class RepositoryService( +internal class MavenRepositoryService( private val journalist: Journalist, - val repositoryProvider: RepositoryProvider, - private val securityProvider: RepositorySecurityProvider, + val mavenRepositoryProvider: MavenRepositoryProvider, + private val securityProvider: MavenRepositorySecurityProvider, private val mirrorService: MirrorService, private val statisticsFacade: StatisticsFacade, private val extensions: Extensions, @@ -75,18 +75,18 @@ internal class RepositoryService( fun deployFile(deployRequest: DeployRequest): Result = with(deployRequest) { when { - repository.acceptsDeploymentOf(gav) -> - repository.storageProvider + mavenRepository.acceptsDeploymentOf(gav) -> + mavenRepository.storageProvider .putFile(gav, deployRequest.content) - .peek { logger.info("DEPLOY | Artifact $gav successfully deployed to ${repository.name} by ${deployRequest.by}") } - .peek { extensions.emitEvent(DeployEvent(repository, gav, deployRequest.by)) } + .peek { logger.info("DEPLOY | Artifact $gav successfully deployed to ${mavenRepository.name} by ${deployRequest.by}") } + .peek { extensions.emitEvent(DeployEvent(mavenRepository, gav, deployRequest.by)) } .flatMap { _ -> when { deployRequest.generateChecksums -> - repository.storageProvider + mavenRepository.storageProvider .getFile(gav) .peek { logger.info("DEPLOY | Generating checksums for $gav") } - .flatMap { repository.writeFileChecksums(gav, it) } + .flatMap { mavenRepository.writeFileChecksums(gav, it) } else -> { logger.debug("DEPLOY | Skipping checksums generation for $gav") ok() @@ -100,10 +100,10 @@ internal class RepositoryService( fun deleteFile(deleteRequest: DeleteRequest): Result = with(deleteRequest) { when { - securityProvider.canModifyResource(accessToken, repository, gav) -> - repository.storageProvider + securityProvider.canModifyResource(accessToken, mavenRepository, gav) -> + mavenRepository.storageProvider .removeFile(gav) - .peek { logger.info("DELETE | File $gav has been deleted from ${repository.name} by ${deleteRequest.by}") } + .peek { logger.info("DELETE | File $gav has been deleted from ${mavenRepository.name} by ${deleteRequest.by}") } else -> unauthorizedError("Unauthorized access request") } } @@ -122,9 +122,9 @@ internal class RepositoryService( } } - private fun resolve(lookupRequest: LookupRequest, block: (Repository, Location) -> Result): Result { + private fun resolve(lookupRequest: LookupRequest, block: (MavenRepository, Location) -> Result): Result { val (accessToken, repositoryName, gav) = lookupRequest - val repository = repositoryProvider.getRepository(lookupRequest.repository) ?: return notFoundError("Repository $repositoryName not found") + val repository = mavenRepositoryProvider.getRepository(lookupRequest.repository) ?: return notFoundError("Repository $repositoryName not found") return canAccessResource(lookupRequest.accessToken, repository.name, gav) .onError { logger.debug("ACCESS | Unauthorized attempt of access (token: $accessToken) to $gav from ${repository.name}") } @@ -133,61 +133,61 @@ internal class RepositoryService( } fun canAccessResource(accessToken: AccessTokenIdentifier?, repository: String, gav: Location): Result = - repositoryProvider.findRepository(repository) + mavenRepositoryProvider.findRepository(repository) .flatMap { securityProvider.canAccessResource(accessToken, it, gav) } - private fun findFile(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Result, ErrorResponse> = - findDetails(accessToken, repository, gav) + private fun findFile(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Result, ErrorResponse> = + findDetails(accessToken, mavenRepository, gav) .`is`(DocumentInfo::class.java) { notFound("Requested file is a directory") } - .flatMap { details -> findInputStream(repository, gav).map { details to it } } - .let { extensions.emitEvent(ResolvedFileEvent(accessToken, repository, gav, it)).result } + .flatMap { details -> findInputStream(mavenRepository, gav).map { details to it } } + .let { extensions.emitEvent(ResolvedFileEvent(accessToken, mavenRepository, gav, it)).result } fun findInputStream(lookupRequest: LookupRequest): Result = resolve(lookupRequest) { repository, gav -> findInputStream(repository, gav) } - private fun findInputStream(repository: Repository, gav: Location): Result = + private fun findInputStream(mavenRepository: MavenRepository, gav: Location): Result = when { - mirrorService.shouldPrioritizeMirrorRepository(repository, gav) -> { + mirrorService.shouldPrioritizeMirrorRepository(mavenRepository, gav) -> { logger.debug("Prioritizing mirror repository for '$gav'") mirrorService - .findRemoteFile(repository, gav) - .flatMapErr { repository.storageProvider.getFile(gav) } + .findRemoteFile(mavenRepository, gav) + .flatMapErr { mavenRepository.storageProvider.getFile(gav) } } - repository.storageProvider.exists(gav) -> { - logger.debug("Gav '$gav' found in '${repository.name}' repository") - repository.storageProvider.getFile(gav) + mavenRepository.storageProvider.exists(gav) -> { + logger.debug("Gav '$gav' found in '${mavenRepository.name}' repository") + mavenRepository.storageProvider.getFile(gav) } else -> { - logger.debug("Cannot find '$gav' in '${repository.name}' repository, requesting proxied repositories") - mirrorService.findRemoteFile(repository, gav) + logger.debug("Cannot find '$gav' in '${mavenRepository.name}' repository, requesting proxied repositories") + mirrorService.findRemoteFile(mavenRepository, gav) } } - private fun findDetails(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Result = + private fun findDetails(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Result = when { - mirrorService.shouldPrioritizeMirrorRepository(repository, gav) -> { + mirrorService.shouldPrioritizeMirrorRepository(mavenRepository, gav) -> { logger.debug("Prioritizing mirror repository for '$gav'") this - .findProxiedDetails(repository, gav) - .flatMapErr { findLocalDetails(accessToken, repository, gav) } + .findProxiedDetails(mavenRepository, gav) + .flatMapErr { findLocalDetails(accessToken, mavenRepository, gav) } } - repository.storageProvider.exists(gav) -> findLocalDetails(accessToken, repository, gav) // todo: add fallback to local for shouldPrioritizeMirrorRepository - else -> findProxiedDetails(repository, gav) + mavenRepository.storageProvider.exists(gav) -> findLocalDetails(accessToken, mavenRepository, gav) // todo: add fallback to local for shouldPrioritizeMirrorRepository + else -> findProxiedDetails(mavenRepository, gav) }.peek { - recordResolvedRequest(Identifier(repository.name, gav.toString()), it) + recordResolvedRequest(Identifier(mavenRepository.name, gav.toString()), it) } - private fun findLocalDetails(accessToken: AccessTokenIdentifier?, repository: Repository, gav: Location): Result = - repository.storageProvider.getFileDetails(gav) + private fun findLocalDetails(accessToken: AccessTokenIdentifier?, mavenRepository: MavenRepository, gav: Location): Result = + mavenRepository.storageProvider.getFileDetails(gav) .flatMap { it.takeIf { it.type == DIRECTORY } - ?.let { securityProvider.canBrowseResource(accessToken, repository, gav).map { _ -> it } } + ?.let { securityProvider.canBrowseResource(accessToken, mavenRepository, gav).map { _ -> it } } ?: it.asSuccess() } - private fun findProxiedDetails(repository: Repository, gav: Location): Result = + private fun findProxiedDetails(mavenRepository: MavenRepository, gav: Location): Result = mirrorService - .findRemoteDetails(repository, gav) + .findRemoteDetails(mavenRepository, gav) .mapErr { notFound("Cannot find '$gav' in local and remote repositories") } private fun recordResolvedRequest(identifier: Identifier, fileDetails: FileDetails) { @@ -197,7 +197,7 @@ internal class RepositoryService( } fun getRootDirectory(accessToken: AccessTokenIdentifier?): DirectoryInfo = - repositoryProvider.getRepositories() + mavenRepositoryProvider.getRepositories() .filter { securityProvider.canAccessRepository(accessToken, it) } .map { SimpleDirectoryInfo(it.name) } .let { DirectoryInfo("/", it) } diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryVisibility.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryVisibility.kt similarity index 89% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryVisibility.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryVisibility.kt index 2e62f5876..b15565a24 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/RepositoryVisibility.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MavenRepositoryVisibility.kt @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven -enum class RepositoryVisibility { +enum class MavenRepositoryVisibility { PUBLIC, HIDDEN, PRIVATE diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MetadataService.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MetadataService.kt similarity index 75% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/MetadataService.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MetadataService.kt index 9e9d40779..3c0d37222 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MetadataService.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MetadataService.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.MapperFeature @@ -24,18 +24,18 @@ import com.fasterxml.jackson.dataformat.xml.XmlMapper import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator import com.fasterxml.jackson.module.kotlin.kotlinModule import com.fasterxml.jackson.module.kotlin.readValue -import com.reposilite.maven.api.GeneratePomRequest -import com.reposilite.maven.api.LatestVersionResponse -import com.reposilite.maven.api.METADATA_FILE -import com.reposilite.maven.api.Metadata -import com.reposilite.maven.api.SaveMetadataRequest -import com.reposilite.maven.api.FilterType.HAS -import com.reposilite.maven.api.FilterType.NONE -import com.reposilite.maven.api.VersionSequence -import com.reposilite.maven.api.Versioning -import com.reposilite.maven.api.VersionsResponse -import com.reposilite.maven.api.extractReleaseVersions -import com.reposilite.maven.api.extractSnapshotVersions +import com.reposilite.packages.maven.api.GeneratePomRequest +import com.reposilite.packages.maven.api.LatestVersionResponse +import com.reposilite.packages.maven.api.METADATA_FILE +import com.reposilite.packages.maven.api.Metadata +import com.reposilite.packages.maven.api.SaveMetadataRequest +import com.reposilite.packages.maven.api.FilterType.HAS +import com.reposilite.packages.maven.api.FilterType.NONE +import com.reposilite.packages.maven.api.VersionSequence +import com.reposilite.packages.maven.api.Versioning +import com.reposilite.packages.maven.api.VersionsResponse +import com.reposilite.packages.maven.api.extractReleaseVersions +import com.reposilite.packages.maven.api.extractSnapshotVersions import com.reposilite.shared.ErrorResponse import com.reposilite.shared.internalServer import com.reposilite.shared.notFound @@ -48,7 +48,7 @@ import panda.std.mapToUnit import java.time.ZonedDateTime import java.time.format.DateTimeFormatter -internal class MetadataService(private val repositorySecurityProvider: RepositorySecurityProvider) { +internal class MetadataService(private val mavenRepositorySecurityProvider: MavenRepositorySecurityProvider) { private val xml by lazy { XmlMapper.xmlBuilder() @@ -67,8 +67,8 @@ internal class MetadataService(private val repositorySecurityProvider: Repositor with (saveMetadataRequest) { supplyThrowing { xml.writeValueAsBytes(metadata) } .mapErr { internalServer("Cannot parse metadata file") } - .flatMap { repository.storageProvider.putFile(gav.resolveMetadataFile(), it.inputStream()).map { _ -> it } } - .flatMap { repository.writeFileChecksums(gav.resolveMetadataFile(), it) } + .flatMap { mavenRepository.storageProvider.putFile(gav.resolveMetadataFile(), it.inputStream()).map { _ -> it } } + .flatMap { mavenRepository.writeFileChecksums(gav.resolveMetadataFile(), it) } .map { metadata } } @@ -81,11 +81,11 @@ internal class MetadataService(private val repositorySecurityProvider: Repositor val currentDirectory = gav.getParent() val parentDirectory = currentDirectory.getParent() - if (!repositorySecurityProvider.canModifyResource(accessToken, repository, parentDirectory)) { + if (!mavenRepositorySecurityProvider.canModifyResource(accessToken, mavenRepository, parentDirectory)) { return unauthorizedError("Unauthorized access request") } - repository.storageProvider + mavenRepository.storageProvider .putFile( location = gav, inputStream = """ @@ -101,7 +101,7 @@ internal class MetadataService(private val repositorySecurityProvider: Repositor """.trimIndent().trim().byteInputStream() ) - .map { findMetadata(repository, parentDirectory).orElseGet { Metadata() } } + .map { findMetadata(mavenRepository, parentDirectory).orElseGet { Metadata() } } .map { it.copy( groupId = groupId, @@ -117,7 +117,7 @@ internal class MetadataService(private val repositorySecurityProvider: Repositor .flatMap { saveMetadata( SaveMetadataRequest( - repository = repository, + mavenRepository = mavenRepository, gav = parentDirectory, metadata = it ) @@ -127,12 +127,12 @@ internal class MetadataService(private val repositorySecurityProvider: Repositor } } - fun findMetadata(repository: Repository, gav: Location): Result = - repository.storageProvider.getFile(gav.resolveMetadataFile()) + fun findMetadata(mavenRepository: MavenRepository, gav: Location): Result = + mavenRepository.storageProvider.getFile(gav.resolveMetadataFile()) .map { it.use { data -> xml.readValue(data) } } - fun findVersions(repository: Repository, gav: Location, filter: String?): Result = - repository.storageProvider.getFile(gav.resolveMetadataFile()) + fun findVersions(mavenRepository: MavenRepository, gav: Location, filter: String?): Result = + mavenRepository.storageProvider.getFile(gav.resolveMetadataFile()) .map { it.use { data -> xml.readValue(data) } } .map { extractVersions(it) } .map { (isSnapshot, versions) -> @@ -154,8 +154,8 @@ internal class MetadataService(private val repositorySecurityProvider: Repositor else -> ({ it.startsWith(filter) }) } - fun findLatestVersion(repository: Repository, gav: Location, filter: String?): Result = - findVersions(repository, gav, filter) + fun findLatestVersion(mavenRepository: MavenRepository, gav: Location, filter: String?): Result = + findVersions(mavenRepository, gav, filter) .filter({ it.versions.isNotEmpty() }, { notFound("Given artifact does not have any declared version") }) .map { (isSnapshot, versions) -> LatestVersionResponse(isSnapshot, versions.last()) } diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MirrorHost.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MirrorHost.kt similarity index 88% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/MirrorHost.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MirrorHost.kt index a0e3e3590..c0f2a9b9b 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MirrorHost.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MirrorHost.kt @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven -import com.reposilite.maven.application.MirroredRepositorySettings +import com.reposilite.packages.maven.application.MirroredRepositorySettings import com.reposilite.shared.http.RemoteClient data class MirrorHost( diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MirrorService.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MirrorService.kt similarity index 62% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/MirrorService.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MirrorService.kt index 947af0cc3..109c87839 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/MirrorService.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/MirrorService.kt @@ -14,13 +14,13 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.journalist.Journalist import com.reposilite.journalist.Logger -import com.reposilite.maven.StoragePolicy.PRIORITIZE_UPSTREAM_METADATA -import com.reposilite.maven.api.METADATA_FILE -import com.reposilite.maven.application.MirroredRepositorySettings +import com.reposilite.packages.maven.StoragePolicy.PRIORITIZE_UPSTREAM_METADATA +import com.reposilite.packages.maven.api.METADATA_FILE +import com.reposilite.packages.maven.application.MirroredRepositorySettings import com.reposilite.shared.ErrorResponse import com.reposilite.shared.notFoundError import com.reposilite.storage.api.FileDetails @@ -39,43 +39,43 @@ internal class MirrorService( private val clock: Clock ) : Journalist { - fun shouldPrioritizeMirrorRepository(repository: Repository, gav: Location): Boolean = + fun shouldPrioritizeMirrorRepository(mavenRepository: MavenRepository, gav: Location): Boolean = when { - repository.storagePolicy == PRIORITIZE_UPSTREAM_METADATA && gav.getSimpleName().contains(METADATA_FILE) -> - repository.metadataMaxAgeInSeconds <= 0 || !isMetadataFileValid(repository, gav) + mavenRepository.storagePolicy == PRIORITIZE_UPSTREAM_METADATA && gav.getSimpleName().contains(METADATA_FILE) -> + mavenRepository.metadataMaxAgeInSeconds <= 0 || !isMetadataFileValid(mavenRepository, gav) else -> false } - private fun isMetadataFileValid(repository: Repository, gav: Location): Boolean = - repository.storageProvider.getLastModifiedTime(gav) - .map { it.toInstant().plus(repository.metadataMaxAgeInSeconds, ChronoUnit.SECONDS) } + private fun isMetadataFileValid(mavenRepository: MavenRepository, gav: Location): Boolean = + mavenRepository.storageProvider.getLastModifiedTime(gav) + .map { it.toInstant().plus(mavenRepository.metadataMaxAgeInSeconds, ChronoUnit.SECONDS) } .matches { it.isAfter(Instant.now(clock)) } - fun findRemoteDetails(repository: Repository, gav: Location): Result = - searchInRemoteRepositories(repository, gav) { (host, config, client) -> + fun findRemoteDetails(mavenRepository: MavenRepository, gav: Location): Result = + searchInRemoteRepositories(mavenRepository, gav) { (host, config, client) -> client.head("${host.removeSuffix("/")}/$gav", config.authorization, config.connectTimeout, config.readTimeout) } - fun findRemoteFile(repository: Repository, gav: Location): Result = - searchInRemoteRepositories(repository, gav) { (host, config, client) -> + fun findRemoteFile(mavenRepository: MavenRepository, gav: Location): Result = + searchInRemoteRepositories(mavenRepository, gav) { (host, config, client) -> client.get("${host.removeSuffix("/")}/$gav", config.authorization, config.connectTimeout, config.readTimeout) - .flatMap { data -> if (config.store) storeFile(repository, gav, data) else ok(data) } + .flatMap { data -> if (config.store) storeFile(mavenRepository, gav, data) else ok(data) } .mapErr { error -> error.updateMessage { "$host: $it" } } } - private fun storeFile(repository: Repository, gav: Location, data: InputStream): Result = - repository.storageProvider + private fun storeFile(mavenRepository: MavenRepository, gav: Location, data: InputStream): Result = + mavenRepository.storageProvider .putFile(gav, data) - .flatMap { repository.storageProvider.getFile(gav) } + .flatMap { mavenRepository.storageProvider.getFile(gav) } - private fun searchInRemoteRepositories(repository: Repository, gav: Location, fetch: (MirrorHost) -> Result): Result = - repository.mirrorHosts.asSequence() + private fun searchInRemoteRepositories(mavenRepository: MavenRepository, gav: Location, fetch: (MirrorHost) -> Result): Result = + mavenRepository.mirrorHosts.asSequence() .filter { (_, config) -> isAllowed(config, gav).fold( { true }, { reason -> - logger.debug("MirrorService | Cannot request '$gav' from remote repository '${repository.name}' (reason: illegal $reason)") + logger.debug("MirrorService | Cannot request '$gav' from remote repository '${mavenRepository.name}' (reason: illegal $reason)") false } ) diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/PreservedBuildsListener.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/PreservedBuildsListener.kt similarity index 93% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/PreservedBuildsListener.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/PreservedBuildsListener.kt index 13fe08e96..d839780d0 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/PreservedBuildsListener.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/PreservedBuildsListener.kt @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven -import com.reposilite.maven.api.DeployEvent +import com.reposilite.packages.maven.api.DeployEvent import com.reposilite.plugin.api.EventListener internal class PreservedBuildsListener(private val mavenFacade: MavenFacade) : EventListener { override fun onCall(event: DeployEvent) { - val repository = event.repository + val repository = event.mavenRepository .takeUnless { it.preserveSnapshots } ?: return diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/Checksum.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/Checksum.kt similarity index 89% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/api/Checksum.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/Checksum.kt index 45535e542..9f3332217 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/Checksum.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/Checksum.kt @@ -1,4 +1,4 @@ -package com.reposilite.maven.api +package com.reposilite.packages.maven.api import java.io.InputStream import org.apache.commons.codec.digest.DigestUtils diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/DeleteApi.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/DeleteApi.kt similarity index 85% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/api/DeleteApi.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/DeleteApi.kt index 14d76128e..fb7a0b992 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/DeleteApi.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/DeleteApi.kt @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.reposilite.maven.api +package com.reposilite.packages.maven.api -import com.reposilite.maven.Repository +import com.reposilite.packages.maven.MavenRepository import com.reposilite.storage.api.Location import com.reposilite.token.AccessTokenIdentifier data class DeleteRequest( val accessToken: AccessTokenIdentifier, - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location, val by: String ) diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/DeploymentApi.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/DeploymentApi.kt similarity index 84% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/api/DeploymentApi.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/DeploymentApi.kt index c2bb1a78f..62922fa59 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/DeploymentApi.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/DeploymentApi.kt @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.reposilite.maven.api +package com.reposilite.packages.maven.api -import com.reposilite.maven.Repository +import com.reposilite.packages.maven.MavenRepository import com.reposilite.plugin.api.Event import com.reposilite.storage.api.Location import java.io.InputStream data class DeployRequest( - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location, val by: String, val content: InputStream, @@ -33,7 +33,7 @@ data class DeployRequest( * Called when deployed file has been successfully stored in repository */ class DeployEvent( - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location, val by: String ) : Event diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/Identifier.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/Identifier.kt similarity index 97% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/api/Identifier.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/Identifier.kt index b2f1cc7db..cc58a6d17 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/Identifier.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/Identifier.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.reposilite.maven.api +package com.reposilite.packages.maven.api import java.util.UUID diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/LatestApi.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/LatestApi.kt similarity index 86% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/api/LatestApi.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/LatestApi.kt index 6a14f1f5c..ab69c2434 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/LatestApi.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/LatestApi.kt @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.reposilite.maven.api +package com.reposilite.packages.maven.api -import com.reposilite.maven.Repository +import com.reposilite.packages.maven.MavenRepository import com.reposilite.storage.api.Location import com.reposilite.token.AccessTokenIdentifier @@ -27,14 +27,14 @@ data class LatestVersionResponse( data class LatestArtifactQueryRequest( val accessToken: AccessTokenIdentifier?, - val repository: Repository, + val mavenRepository: MavenRepository, val query: LatestArtifactQuery ) { fun toVersionLookupRequest(): VersionLookupRequest = VersionLookupRequest( accessToken = accessToken, - repository = repository, + mavenRepository = mavenRepository, gav = query.gav, filter = query.filter ) @@ -50,7 +50,7 @@ data class LatestArtifactQuery( data class LatestBadgeRequest( val accessToken: AccessTokenIdentifier?, - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location, val name: String? = null, val color: String? = null, @@ -61,7 +61,7 @@ data class LatestBadgeRequest( fun toVersionLookupRequest(): VersionLookupRequest = VersionLookupRequest( accessToken = accessToken, - repository = repository, + mavenRepository = mavenRepository, gav = gav, filter = filter ) diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/LookupApi.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/LookupApi.kt similarity index 88% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/api/LookupApi.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/LookupApi.kt index 885f3cc07..b6844ea66 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/LookupApi.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/LookupApi.kt @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.reposilite.maven.api +package com.reposilite.packages.maven.api -import com.reposilite.maven.Repository +import com.reposilite.packages.maven.MavenRepository import com.reposilite.plugin.api.Event import com.reposilite.shared.ErrorResponse import com.reposilite.storage.api.DocumentInfo @@ -33,7 +33,7 @@ data class LookupRequest( data class VersionLookupRequest( val accessToken: AccessTokenIdentifier?, - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location, val filter: String? = null ) @@ -45,13 +45,13 @@ data class VersionsResponse( data class PreResolveEvent( val accessToken: AccessTokenIdentifier?, - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location ) : Event data class ResolvedFileEvent( val accessToken: AccessTokenIdentifier?, - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location, var result: Result, ErrorResponse> ) : Event diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/Metadata.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/Metadata.kt similarity index 98% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/api/Metadata.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/Metadata.kt index fce269008..b26c20c8e 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/Metadata.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/Metadata.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.reposilite.maven.api +package com.reposilite.packages.maven.api import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/MetadataApi.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/MetadataApi.kt similarity index 84% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/api/MetadataApi.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/MetadataApi.kt index c84696e4a..0d8e2a280 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/api/MetadataApi.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/api/MetadataApi.kt @@ -14,21 +14,21 @@ * limitations under the License. */ -package com.reposilite.maven.api +package com.reposilite.packages.maven.api -import com.reposilite.maven.Repository +import com.reposilite.packages.maven.MavenRepository import com.reposilite.storage.api.Location import com.reposilite.token.AccessTokenIdentifier data class SaveMetadataRequest( - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location, val metadata: Metadata ) data class GeneratePomRequest( val accessToken: AccessTokenIdentifier, - val repository: Repository, + val mavenRepository: MavenRepository, val gav: Location, val pomDetails: PomDetails ) diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/application/MavenComponents.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/application/MavenComponents.kt similarity index 70% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/application/MavenComponents.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/application/MavenComponents.kt index ae4ab64bd..8d3cf5c1c 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/application/MavenComponents.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/application/MavenComponents.kt @@ -14,16 +14,15 @@ * limitations under the License. */ -package com.reposilite.maven.application +package com.reposilite.packages.maven.application import com.reposilite.auth.AuthenticationFacade import com.reposilite.journalist.Journalist -import com.reposilite.maven.LatestService -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.MetadataService -import com.reposilite.maven.MirrorService -import com.reposilite.maven.RepositoryProvider -import com.reposilite.maven.RepositorySecurityProvider +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.MetadataService +import com.reposilite.packages.maven.MirrorService +import com.reposilite.packages.maven.MavenRepositoryProvider +import com.reposilite.packages.maven.MavenRepositorySecurityProvider import com.reposilite.plugin.Extensions import com.reposilite.plugin.api.PluginComponents import com.reposilite.shared.http.RemoteClientProvider @@ -50,8 +49,8 @@ internal class MavenComponents( private val id: Reference, ) : PluginComponents { - private fun securityProvider(): RepositorySecurityProvider = - RepositorySecurityProvider(accessTokenFacade) + private fun securityProvider(): MavenRepositorySecurityProvider = + MavenRepositorySecurityProvider(accessTokenFacade) private fun metadataService(): MetadataService = MetadataService(securityProvider()) @@ -64,9 +63,9 @@ internal class MavenComponents( private fun repositoryProvider( mirrorService: MirrorService = mirrorService(), - securityProvider: RepositorySecurityProvider = securityProvider(), - ): RepositoryProvider = - RepositoryProvider( + securityProvider: MavenRepositorySecurityProvider = securityProvider(), + ): MavenRepositoryProvider = + MavenRepositoryProvider( journalist = journalist, workingDirectory = workingDirectory, remoteClientProvider = remoteClientProvider, @@ -76,23 +75,23 @@ internal class MavenComponents( mirrorService = mirrorService, statisticsFacade = statisticsFacade, extensions = extensions, - repositorySecurityProvider = securityProvider, + mavenRepositorySecurityProvider = securityProvider, repositoriesSource = mavenSettings.computed { it.repositories } ) - private fun latestService(): LatestService = - LatestService(id) + private fun latestService(): com.reposilite.packages.maven.LatestService = + com.reposilite.packages.maven.LatestService(id) fun mavenFacade( - securityProvider: RepositorySecurityProvider = securityProvider(), + securityProvider: MavenRepositorySecurityProvider = securityProvider(), metadataService: MetadataService = metadataService(), - latestService: LatestService = latestService(), - repositoryProvider: RepositoryProvider = repositoryProvider(), + latestService: com.reposilite.packages.maven.LatestService = latestService(), + mavenRepositoryProvider: MavenRepositoryProvider = repositoryProvider(), ): MavenFacade = MavenFacade( journalist = journalist, - repositorySecurityProvider = securityProvider, - repositoryProvider = repositoryProvider, + mavenRepositorySecurityProvider = securityProvider, + mavenRepositoryProvider = mavenRepositoryProvider, metadataService = metadataService, latestService = latestService ) diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/application/MavenPlugin.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/application/MavenPlugin.kt similarity index 89% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/application/MavenPlugin.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/application/MavenPlugin.kt index b21192def..d7e4f5e8a 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/application/MavenPlugin.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/application/MavenPlugin.kt @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.reposilite.maven.application +package com.reposilite.packages.maven.application import com.reposilite.configuration.local.LocalConfiguration import com.reposilite.configuration.shared.SharedConfigurationFacade -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.PreservedBuildsListener -import com.reposilite.maven.infrastructure.MavenApiEndpoints -import com.reposilite.maven.infrastructure.MavenEndpoints -import com.reposilite.maven.infrastructure.MavenLatestApiEndpoints +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.PreservedBuildsListener +import com.reposilite.packages.maven.infrastructure.MavenApiEndpoints +import com.reposilite.packages.maven.infrastructure.MavenEndpoints +import com.reposilite.packages.maven.infrastructure.MavenLatestApiEndpoints import com.reposilite.plugin.api.Plugin import com.reposilite.plugin.api.ReposiliteDisposeEvent import com.reposilite.plugin.api.ReposilitePlugin diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/application/MavenSettings.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/application/MavenSettings.kt similarity index 94% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/application/MavenSettings.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/application/MavenSettings.kt index 04df61050..4e938c4d0 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/application/MavenSettings.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/application/MavenSettings.kt @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.reposilite.maven.application +package com.reposilite.packages.maven.application import com.reposilite.configuration.shared.api.Doc import com.reposilite.configuration.shared.api.Min import com.reposilite.configuration.shared.api.SharedSettings -import com.reposilite.maven.StoragePolicy -import com.reposilite.maven.RepositoryVisibility -import com.reposilite.maven.RepositoryVisibility.PRIVATE -import com.reposilite.maven.RepositoryVisibility.PUBLIC +import com.reposilite.packages.maven.StoragePolicy +import com.reposilite.packages.maven.MavenRepositoryVisibility +import com.reposilite.packages.maven.MavenRepositoryVisibility.PRIVATE +import com.reposilite.packages.maven.MavenRepositoryVisibility.PUBLIC import com.reposilite.shared.http.AuthenticationMethod import com.reposilite.shared.http.RemoteCredentials import com.reposilite.storage.StorageProviderSettings @@ -48,7 +48,7 @@ data class RepositorySettings( @get:Doc(title = "Id", description = "The id of this repository.") val id: String = "", @get:Doc(title = "Visibility", description = "The visibility of this repository.") - val visibility: RepositoryVisibility = PUBLIC, + val visibility: MavenRepositoryVisibility = PUBLIC, @get:Doc(title = "Redeployment", description = "Does this repository accept redeployment of the same artifact version.") val redeployment: Boolean = false, @get:Doc(title = "Preserved snapshots", "By default, Reposilite deletes all deprecated build files. If you'd like to preserve them, set this property to true.") diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/DirectoryIndexPage.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/DirectoryIndexPage.kt similarity index 97% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/DirectoryIndexPage.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/DirectoryIndexPage.kt index fe2b0d292..656cf248b 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/DirectoryIndexPage.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/DirectoryIndexPage.kt @@ -1,4 +1,4 @@ -package com.reposilite.maven.infrastructure +package com.reposilite.packages.maven.infrastructure import com.reposilite.storage.api.FileDetails import com.reposilite.storage.api.FileType diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenApiEndpoints.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenApiEndpoints.kt similarity index 91% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenApiEndpoints.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenApiEndpoints.kt index d23b5461d..8a1c640a3 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenApiEndpoints.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenApiEndpoints.kt @@ -14,14 +14,14 @@ * limitations under the License. */ -package com.reposilite.maven.infrastructure +package com.reposilite.packages.maven.infrastructure -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.api.GeneratePomRequest -import com.reposilite.maven.api.LookupRequest -import com.reposilite.maven.api.VersionLookupRequest -import com.reposilite.maven.api.VersionsResponse -import com.reposilite.maven.api.PomDetails +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.api.GeneratePomRequest +import com.reposilite.packages.maven.api.LookupRequest +import com.reposilite.packages.maven.api.VersionLookupRequest +import com.reposilite.packages.maven.api.VersionsResponse +import com.reposilite.packages.maven.api.PomDetails import com.reposilite.shared.ContextDsl import com.reposilite.shared.ErrorResponse import com.reposilite.storage.api.FileDetails @@ -98,7 +98,7 @@ internal class MavenApiEndpoints(mavenFacade: MavenFacade) : MavenRoutes(mavenFa response = mavenFacade.findVersions( VersionLookupRequest( accessToken = this?.identifier, - repository = repository, + mavenRepository = repository, gav = gav, filter = ctx.queryParam("filter") ) @@ -130,7 +130,7 @@ internal class MavenApiEndpoints(mavenFacade: MavenFacade) : MavenRoutes(mavenFa .generatePom( GeneratePomRequest( accessToken = this.identifier, - repository = repository, + mavenRepository = repository, gav = gav, pomDetails = body(), ) diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenEndpoints.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenEndpoints.kt similarity index 96% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenEndpoints.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenEndpoints.kt index 2f28d4b5a..5ed7aa9a9 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenEndpoints.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenEndpoints.kt @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.reposilite.maven.infrastructure +package com.reposilite.packages.maven.infrastructure -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.api.DeleteRequest -import com.reposilite.maven.api.DeployRequest -import com.reposilite.maven.api.LookupRequest +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.api.DeleteRequest +import com.reposilite.packages.maven.api.DeployRequest +import com.reposilite.packages.maven.api.LookupRequest import com.reposilite.shared.ErrorResponse import com.reposilite.shared.extensions.resultAttachment import com.reposilite.shared.extensions.uri diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenLatestApiEndpoints.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenLatestApiEndpoints.kt similarity index 91% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenLatestApiEndpoints.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenLatestApiEndpoints.kt index 1237245ed..5ff83767f 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenLatestApiEndpoints.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenLatestApiEndpoints.kt @@ -14,16 +14,15 @@ * limitations under the License. */ -package com.reposilite.maven.infrastructure +package com.reposilite.packages.maven.infrastructure -import com.reposilite.maven.MatchedVersionHandler -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.Repository -import com.reposilite.maven.api.LatestArtifactQuery -import com.reposilite.maven.api.LatestArtifactQueryRequest -import com.reposilite.maven.api.LatestBadgeRequest -import com.reposilite.maven.api.LatestVersionResponse -import com.reposilite.maven.api.VersionLookupRequest +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.MavenRepository +import com.reposilite.packages.maven.api.LatestArtifactQuery +import com.reposilite.packages.maven.api.LatestArtifactQueryRequest +import com.reposilite.packages.maven.api.LatestBadgeRequest +import com.reposilite.packages.maven.api.LatestVersionResponse +import com.reposilite.packages.maven.api.VersionLookupRequest import com.reposilite.shared.ContextDsl import com.reposilite.shared.ErrorResponse import com.reposilite.shared.badRequestError @@ -106,7 +105,7 @@ internal class MavenLatestApiEndpoints( response = resolveLatestArtifact( context = this@ReposiliteRoute, accessToken = this, - repository = it, + mavenRepository = it, handler = { lookupRequest -> mavenFacade.findDetails(lookupRequest) } ) } @@ -133,7 +132,7 @@ internal class MavenLatestApiEndpoints( response = resolveLatestArtifact( context = this@ReposiliteRoute, accessToken = this, - repository = repository, + mavenRepository = repository, handler = { lookupRequest -> mavenFacade.findFile(lookupRequest).map { ctx.resultAttachment( @@ -152,11 +151,11 @@ internal class MavenLatestApiEndpoints( } } - private fun resolveLatestArtifact(context: ContextDsl<*>, accessToken: AccessTokenDto?, repository: Repository, handler: MatchedVersionHandler): Result = + private fun resolveLatestArtifact(context: ContextDsl<*>, accessToken: AccessTokenDto?, mavenRepository: MavenRepository, handler: com.reposilite.packages.maven.MatchedVersionHandler): Result = mavenFacade.findLatestVersionFile( LatestArtifactQueryRequest( accessToken = accessToken?.identifier, - repository = repository, + mavenRepository = mavenRepository, query = LatestArtifactQuery( gav = context.requireParameter("gav").toLocation(), extension = context.queryParameter("extension") ?: "jar", @@ -184,7 +183,7 @@ internal class MavenLatestApiEndpoints( mavenFacade.createLatestBadge( LatestBadgeRequest( accessToken = this?.identifier, - repository = repository, + mavenRepository = repository, gav = gav, name = queryParameter("name"), color = queryParameter("color"), diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenRoutes.kt b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenRoutes.kt similarity index 82% rename from reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenRoutes.kt rename to reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenRoutes.kt index b15c39df6..100ae9f41 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/maven/infrastructure/MavenRoutes.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/packages/maven/infrastructure/MavenRoutes.kt @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.reposilite.maven.infrastructure +package com.reposilite.packages.maven.infrastructure -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.Repository +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.MavenRepository import com.reposilite.shared.ContextDsl import com.reposilite.shared.notFoundError import com.reposilite.storage.api.Location @@ -26,7 +26,7 @@ import com.reposilite.web.api.ReposiliteRoutes abstract class MavenRoutes(val mavenFacade: MavenFacade) : ReposiliteRoutes() { - fun ContextDsl.repository(block: (Repository?) -> Unit) { + fun ContextDsl.repository(block: (MavenRepository?) -> Unit) { val repository = parameter("repository") ?: run { response = notFoundError("Missing repository parameter") return @@ -35,7 +35,7 @@ abstract class MavenRoutes(val mavenFacade: MavenFacade) : ReposiliteRoutes() { block(mavenFacade.getRepository(repository)) } - fun ContextDsl.requireRepository(block: (Repository) -> Unit) { + fun ContextDsl.requireRepository(block: (MavenRepository) -> Unit) { repository { when (it) { null -> response = notFoundError("Repository not found") diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/packages/npm/.gitkeep b/reposilite-backend/src/main/kotlin/com/reposilite/packages/npm/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/packages/oci/.gitkeep b/reposilite-backend/src/main/kotlin/com/reposilite/packages/oci/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/StatisticsFacade.kt b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/StatisticsFacade.kt index 6ec269372..50da2ee40 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/StatisticsFacade.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/StatisticsFacade.kt @@ -17,7 +17,7 @@ package com.reposilite.statistics import com.reposilite.journalist.Journalist import com.reposilite.journalist.Logger -import com.reposilite.maven.api.Identifier +import com.reposilite.packages.maven.api.Identifier import com.reposilite.plugin.api.Facade import com.reposilite.shared.ErrorResponse import com.reposilite.shared.badRequestError diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/StatisticsRepository.kt b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/StatisticsRepository.kt index b918ed511..4b545307b 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/StatisticsRepository.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/StatisticsRepository.kt @@ -16,7 +16,7 @@ package com.reposilite.statistics -import com.reposilite.maven.api.Identifier +import com.reposilite.packages.maven.api.Identifier import com.reposilite.statistics.api.ResolvedEntry import java.time.LocalDate import kotlin.Int.Companion.MAX_VALUE diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/api/ResolvedApi.kt b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/api/ResolvedApi.kt index 235e43ac6..5e884717f 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/api/ResolvedApi.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/api/ResolvedApi.kt @@ -16,7 +16,7 @@ package com.reposilite.statistics.api -import com.reposilite.maven.api.Identifier +import com.reposilite.packages.maven.api.Identifier /* Per repository */ diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/infrastructure/InMemoryStatisticsRepository.kt b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/infrastructure/InMemoryStatisticsRepository.kt index 8c15bb4a4..ab9962408 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/infrastructure/InMemoryStatisticsRepository.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/infrastructure/InMemoryStatisticsRepository.kt @@ -16,7 +16,7 @@ package com.reposilite.statistics.infrastructure -import com.reposilite.maven.api.Identifier +import com.reposilite.packages.maven.api.Identifier import com.reposilite.statistics.StatisticsRepository import com.reposilite.statistics.api.ResolvedEntry import java.time.LocalDate diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/infrastructure/SqlStatisticsRepository.kt b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/infrastructure/SqlStatisticsRepository.kt index 1f8f21b51..ff24c78a0 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/statistics/infrastructure/SqlStatisticsRepository.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/statistics/infrastructure/SqlStatisticsRepository.kt @@ -20,9 +20,9 @@ import com.reposilite.DatabaseMigrations.MIGRATION_001 import com.reposilite.DatabaseMigrations.MIGRATION_002 import com.reposilite.DatabaseMigrations.MIGRATION_003 import com.reposilite.journalist.Journalist -import com.reposilite.maven.api.GAV_MAX_LENGTH -import com.reposilite.maven.api.Identifier -import com.reposilite.maven.api.REPOSITORY_NAME_MAX_LENGTH +import com.reposilite.packages.maven.api.GAV_MAX_LENGTH +import com.reposilite.packages.maven.api.Identifier +import com.reposilite.packages.maven.api.REPOSITORY_NAME_MAX_LENGTH import com.reposilite.shared.extensions.executeQuery import com.reposilite.statistics.StatisticsRepository import com.reposilite.statistics.api.ResolvedEntry diff --git a/reposilite-backend/src/main/resources/META-INF/services/com.reposilite.plugin.api.ReposilitePlugin b/reposilite-backend/src/main/resources/META-INF/services/com.reposilite.plugin.api.ReposilitePlugin index 0a2501962..5b949c2af 100644 --- a/reposilite-backend/src/main/resources/META-INF/services/com.reposilite.plugin.api.ReposilitePlugin +++ b/reposilite-backend/src/main/resources/META-INF/services/com.reposilite.plugin.api.ReposilitePlugin @@ -1,6 +1,6 @@ com.reposilite.auth.application.AuthenticationPlugin com.reposilite.console.application.ConsolePlugin -com.reposilite.maven.application.MavenPlugin +com.reposilite.packages.maven.application.MavenPlugin com.reposilite.javadocs.application.JavadocPlugin com.reposilite.configuration.application.ConfigurationPlugin com.reposilite.configuration.local.LocalConfigurationPlugin diff --git a/reposilite-backend/src/test/kotlin/com/reposilite/packages/.gitkeep b/reposilite-backend/src/test/kotlin/com/reposilite/packages/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/reposilite-backend/src/test/kotlin/com/reposilite/maven/MavenFacadeTest.kt b/reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/MavenFacadeTest.kt similarity index 91% rename from reposilite-backend/src/test/kotlin/com/reposilite/maven/MavenFacadeTest.kt rename to reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/MavenFacadeTest.kt index e4309ef08..fee841584 100644 --- a/reposilite-backend/src/test/kotlin/com/reposilite/maven/MavenFacadeTest.kt +++ b/reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/MavenFacadeTest.kt @@ -14,22 +14,22 @@ * limitations under the License. */ -package com.reposilite.maven - -import com.reposilite.maven.RepositoryVisibility.HIDDEN -import com.reposilite.maven.RepositoryVisibility.PRIVATE -import com.reposilite.maven.RepositoryVisibility.PUBLIC -import com.reposilite.maven.api.Checksum -import com.reposilite.maven.api.DeleteRequest -import com.reposilite.maven.api.DeployRequest -import com.reposilite.maven.api.GeneratePomRequest -import com.reposilite.maven.api.LookupRequest -import com.reposilite.maven.api.METADATA_FILE -import com.reposilite.maven.api.PomDetails -import com.reposilite.maven.api.VersionLookupRequest -import com.reposilite.maven.application.MirroredRepositorySettings -import com.reposilite.maven.application.RepositorySettings -import com.reposilite.maven.specification.MavenSpecification +package com.reposilite.packages.maven + +import com.reposilite.packages.maven.MavenRepositoryVisibility.HIDDEN +import com.reposilite.packages.maven.MavenRepositoryVisibility.PRIVATE +import com.reposilite.packages.maven.MavenRepositoryVisibility.PUBLIC +import com.reposilite.packages.maven.api.Checksum +import com.reposilite.packages.maven.api.DeleteRequest +import com.reposilite.packages.maven.api.DeployRequest +import com.reposilite.packages.maven.api.GeneratePomRequest +import com.reposilite.packages.maven.api.LookupRequest +import com.reposilite.packages.maven.api.METADATA_FILE +import com.reposilite.packages.maven.api.PomDetails +import com.reposilite.packages.maven.api.VersionLookupRequest +import com.reposilite.packages.maven.application.MirroredRepositorySettings +import com.reposilite.packages.maven.application.RepositorySettings +import com.reposilite.packages.maven.specification.MavenSpecification import com.reposilite.storage.api.FileType.FILE import com.reposilite.storage.api.toLocation import com.reposilite.token.RoutePermission.READ @@ -85,8 +85,8 @@ internal class MavenFacadeTest : MavenSpecification() { } @ParameterizedTest - @EnumSource(value = RepositoryVisibility::class, names = [ "PUBLIC", "HIDDEN" ]) - fun `should find requested details without credentials in public and hidden repositories`(visibility: RepositoryVisibility) { + @EnumSource(value = MavenRepositoryVisibility::class, names = [ "PUBLIC", "HIDDEN" ]) + fun `should find requested details without credentials in public and hidden repositories`(visibility: MavenRepositoryVisibility) { // given: a repository with a file val fileSpec = addFileToRepository(FileSpec(visibility.name, "/gav/file.pom", "content")) @@ -123,8 +123,8 @@ internal class MavenFacadeTest : MavenSpecification() { } @ParameterizedTest - @EnumSource(value = RepositoryVisibility::class, names = [ "HIDDEN", "PRIVATE" ]) - fun `should restrict directory indexing in hidden and private repositories `(visibility: RepositoryVisibility) { + @EnumSource(value = MavenRepositoryVisibility::class, names = [ "HIDDEN", "PRIVATE" ]) + fun `should restrict directory indexing in hidden and private repositories `(visibility: MavenRepositoryVisibility) { // given: a repository with a file val fileSpec = addFileToRepository(FileSpec(visibility.name, "/gav/file.pom", "content")) @@ -141,8 +141,8 @@ internal class MavenFacadeTest : MavenSpecification() { inner class Modifications { @ParameterizedTest - @EnumSource(RepositoryVisibility::class) - fun `should deploy file under the given path`(visibility: RepositoryVisibility) { + @EnumSource(MavenRepositoryVisibility::class) + fun `should deploy file under the given path`(visibility: MavenRepositoryVisibility) { // given: an uri and file to store val fileSpec = FileSpec(visibility.name, "/com/reposilite/3.0.0/reposilite-3.0.0.jar", "content") val by = "dzikoysk@127.0.0.1" @@ -172,7 +172,7 @@ internal class MavenFacadeTest : MavenSpecification() { // when: the following file is deployed with requested checksums val deployResult = mavenFacade.deployFile( DeployRequest( - repository = fileSpec.repository(), + mavenRepository = fileSpec.repository(), gav = fileSpec.gav(), by = by, content = fileSpec.content.byteInputStream(), @@ -320,7 +320,7 @@ internal class MavenFacadeTest : MavenSpecification() { mavenFacade.generatePom( GeneratePomRequest( accessToken = token, - repository = repository, + mavenRepository = repository, gav = pom, pomDetails = PomDetails( groupId = "com.dzikoysk", diff --git a/reposilite-backend/src/test/kotlin/com/reposilite/maven/PreservedBuildsListenerTest.kt b/reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/PreservedBuildsListenerTest.kt similarity index 85% rename from reposilite-backend/src/test/kotlin/com/reposilite/maven/PreservedBuildsListenerTest.kt rename to reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/PreservedBuildsListenerTest.kt index 3577a0fef..ba89c1f86 100644 --- a/reposilite-backend/src/test/kotlin/com/reposilite/maven/PreservedBuildsListenerTest.kt +++ b/reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/PreservedBuildsListenerTest.kt @@ -14,17 +14,17 @@ * limitations under the License. */ -package com.reposilite.maven +package com.reposilite.packages.maven import com.reposilite.assertCollectionsEquals -import com.reposilite.maven.api.DeployEvent -import com.reposilite.maven.api.Metadata -import com.reposilite.maven.api.SaveMetadataRequest -import com.reposilite.maven.api.Snapshot -import com.reposilite.maven.api.SnapshotVersion -import com.reposilite.maven.api.Versioning -import com.reposilite.maven.application.RepositorySettings -import com.reposilite.maven.specification.MavenSpecification +import com.reposilite.packages.maven.api.DeployEvent +import com.reposilite.packages.maven.api.Metadata +import com.reposilite.packages.maven.api.SaveMetadataRequest +import com.reposilite.packages.maven.api.Snapshot +import com.reposilite.packages.maven.api.SnapshotVersion +import com.reposilite.packages.maven.api.Versioning +import com.reposilite.packages.maven.application.RepositorySettings +import com.reposilite.packages.maven.specification.MavenSpecification import com.reposilite.storage.api.toLocation import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -61,7 +61,7 @@ internal class PreservedBuildsListenerTest : MavenSpecification() { // this one is currently deployed mavenFacade.saveMetadata( SaveMetadataRequest( - repository = mavenFacade.getRepository(repositoryName)!!, + mavenRepository = mavenFacade.getRepository(repositoryName)!!, gav = versionId, metadata = Metadata( artifactId = artifactId, diff --git a/reposilite-backend/src/test/kotlin/com/reposilite/maven/ResolveEventTest.kt b/reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/ResolveEventTest.kt similarity index 85% rename from reposilite-backend/src/test/kotlin/com/reposilite/maven/ResolveEventTest.kt rename to reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/ResolveEventTest.kt index cbc75099f..033949077 100644 --- a/reposilite-backend/src/test/kotlin/com/reposilite/maven/ResolveEventTest.kt +++ b/reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/ResolveEventTest.kt @@ -1,9 +1,9 @@ -package com.reposilite.maven +package com.reposilite.packages.maven -import com.reposilite.maven.api.LookupRequest -import com.reposilite.maven.api.ResolvedFileEvent -import com.reposilite.maven.application.RepositorySettings -import com.reposilite.maven.specification.MavenSpecification +import com.reposilite.packages.maven.api.LookupRequest +import com.reposilite.packages.maven.api.ResolvedFileEvent +import com.reposilite.packages.maven.application.RepositorySettings +import com.reposilite.packages.maven.specification.MavenSpecification import com.reposilite.storage.api.Location import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/reposilite-backend/src/test/kotlin/com/reposilite/maven/specification/MavenSpecification.kt b/reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/specification/MavenSpecification.kt similarity index 89% rename from reposilite-backend/src/test/kotlin/com/reposilite/maven/specification/MavenSpecification.kt rename to reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/specification/MavenSpecification.kt index d9aa66c83..868b002d9 100644 --- a/reposilite-backend/src/test/kotlin/com/reposilite/maven/specification/MavenSpecification.kt +++ b/reposilite-backend/src/test/kotlin/com/reposilite/packages/maven/specification/MavenSpecification.kt @@ -14,21 +14,21 @@ * limitations under the License. */ -package com.reposilite.maven.specification +package com.reposilite.packages.maven.specification import com.reposilite.auth.application.AuthenticationComponents import com.reposilite.auth.application.AuthenticationSettings import com.reposilite.journalist.backend.InMemoryLogger -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.Repository -import com.reposilite.maven.api.LookupRequest -import com.reposilite.maven.api.Metadata -import com.reposilite.maven.api.SaveMetadataRequest -import com.reposilite.maven.api.Versioning -import com.reposilite.maven.application.MavenComponents -import com.reposilite.maven.application.MavenSettings -import com.reposilite.maven.application.MirrorCredentials -import com.reposilite.maven.application.RepositorySettings +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.MavenRepository +import com.reposilite.packages.maven.api.LookupRequest +import com.reposilite.packages.maven.api.Metadata +import com.reposilite.packages.maven.api.SaveMetadataRequest +import com.reposilite.packages.maven.api.Versioning +import com.reposilite.packages.maven.application.MavenComponents +import com.reposilite.packages.maven.application.MavenSettings +import com.reposilite.packages.maven.application.MirrorCredentials +import com.reposilite.packages.maven.application.RepositorySettings import com.reposilite.plugin.Extensions import com.reposilite.shared.http.AuthenticationMethod.BASIC import com.reposilite.shared.http.FakeRemoteClientProvider @@ -146,7 +146,7 @@ internal abstract class MavenSpecification { val content: String ) { - fun repository(): Repository = + fun repository(): MavenRepository = mavenFacade.getRepository(repository)!! fun toLookupRequest(authentication: AccessTokenIdentifier?): LookupRequest = @@ -183,13 +183,13 @@ internal abstract class MavenSpecification { private fun String.isAllowed(): Boolean = this.endsWith("/allow") - protected fun useMetadata(repository: String, gav: String, versioning: List, filter: String? = null): Quad = + protected fun useMetadata(repository: String, gav: String, versioning: List, filter: String? = null): Quad = Quad( mavenFacade.getRepository(repository), gav.toLocation(), mavenFacade.saveMetadata( SaveMetadataRequest( - repository = mavenFacade.getRepository(repository)!!, + mavenRepository = mavenFacade.getRepository(repository)!!, gav = gav.toLocation(), metadata = Metadata(versioning = Versioning(_versions = versioning)) ) diff --git a/reposilite-backend/src/test/kotlin/com/reposilite/statistics/specification/StatisticsSpecification.kt b/reposilite-backend/src/test/kotlin/com/reposilite/statistics/specification/StatisticsSpecification.kt index e4dc4f658..fe537baec 100644 --- a/reposilite-backend/src/test/kotlin/com/reposilite/statistics/specification/StatisticsSpecification.kt +++ b/reposilite-backend/src/test/kotlin/com/reposilite/statistics/specification/StatisticsSpecification.kt @@ -17,7 +17,7 @@ package com.reposilite.statistics.specification import com.reposilite.journalist.backend.InMemoryLogger -import com.reposilite.maven.api.Identifier +import com.reposilite.packages.maven.api.Identifier import com.reposilite.statistics.DailyDateIntervalProvider import com.reposilite.statistics.StatisticsFacade import com.reposilite.statistics.api.IncrementResolvedRequest diff --git a/reposilite-plugins/checksum-plugin/src/main/kotlin/com/reposilite/plugin/checksum/ChecksumPlugin.kt b/reposilite-plugins/checksum-plugin/src/main/kotlin/com/reposilite/plugin/checksum/ChecksumPlugin.kt index bf7fd2b65..ca38d7a37 100644 --- a/reposilite-plugins/checksum-plugin/src/main/kotlin/com/reposilite/plugin/checksum/ChecksumPlugin.kt +++ b/reposilite-plugins/checksum-plugin/src/main/kotlin/com/reposilite/plugin/checksum/ChecksumPlugin.kt @@ -1,8 +1,8 @@ package com.reposilite.plugin.checksum -import com.reposilite.maven.MavenFacade -import com.reposilite.maven.api.LookupRequest -import com.reposilite.maven.api.PreResolveEvent +import com.reposilite.packages.maven.MavenFacade +import com.reposilite.packages.maven.api.LookupRequest +import com.reposilite.packages.maven.api.PreResolveEvent import com.reposilite.plugin.api.Facade import com.reposilite.plugin.api.Plugin import com.reposilite.plugin.api.ReposilitePlugin diff --git a/reposilite-plugins/prometheus-plugin/src/main/kotlin/com/reposilite/plugin/prometheus/PrometheusPlugin.kt b/reposilite-plugins/prometheus-plugin/src/main/kotlin/com/reposilite/plugin/prometheus/PrometheusPlugin.kt index b167f9864..f81125173 100644 --- a/reposilite-plugins/prometheus-plugin/src/main/kotlin/com/reposilite/plugin/prometheus/PrometheusPlugin.kt +++ b/reposilite-plugins/prometheus-plugin/src/main/kotlin/com/reposilite/plugin/prometheus/PrometheusPlugin.kt @@ -1,7 +1,7 @@ package com.reposilite.plugin.prometheus -import com.reposilite.maven.api.DeployEvent -import com.reposilite.maven.api.ResolvedFileEvent +import com.reposilite.packages.maven.api.DeployEvent +import com.reposilite.packages.maven.api.ResolvedFileEvent import com.reposilite.plugin.api.Facade import com.reposilite.plugin.api.Plugin import com.reposilite.plugin.api.ReposilitePlugin