From d876f1c8352a43b8febf3ddbb32fc260d9d0a831 Mon Sep 17 00:00:00 2001 From: dzikoysk Date: Sat, 6 Feb 2021 16:16:02 +0100 Subject: [PATCH] GH-341 Bump CDN to 1.6.0 (Resolve #341) --- reposilite-backend/pom.xml | 19 ++++++++++++++++++- .../config/ConfigurationLoader.java | 4 ++-- .../reposilite/console/HelpCommand.java | 6 +++--- .../reposilite/frontend/FrontendService.java | 4 ++-- .../reposilite/metadata/MetadataUtils.java | 5 ++--- .../reposilite/repository/Repository.java | 4 ++-- ...osiliteIntegrationTestSpecification.groovy | 4 ++-- .../config/ConfigurationLoaderTest.groovy | 8 ++++---- .../console/ConsoleThreadTest.groovy | 6 +++--- .../reposilite/repository/ArtifactTest.groovy | 4 ++-- .../repository/DeployEndpointTest.groovy | 2 +- .../repository/LookupApiEndpointTest.groovy | 18 +++++++++--------- .../repository/ProxyServiceTest.groovy | 2 +- 13 files changed, 51 insertions(+), 35 deletions(-) diff --git a/reposilite-backend/pom.xml b/reposilite-backend/pom.xml index 8b3c546bf..d2fd9b022 100644 --- a/reposilite-backend/pom.xml +++ b/reposilite-backend/pom.xml @@ -91,7 +91,7 @@ net.dzikoysk cdn - 1.5.3 + 1.6.0 org.springframework.security @@ -134,6 +134,23 @@ 2.11.0 + + + org.tinylog + slf4j-tinylog + 2.2.1 + + + org.tinylog + tinylog-api + 2.2.1 + + + org.tinylog + tinylog-impl + 2.2.1 + + com.google.http-client diff --git a/reposilite-backend/src/main/java/org/panda_lang/reposilite/config/ConfigurationLoader.java b/reposilite-backend/src/main/java/org/panda_lang/reposilite/config/ConfigurationLoader.java index d5e0481d4..6824a7eca 100644 --- a/reposilite-backend/src/main/java/org/panda_lang/reposilite/config/ConfigurationLoader.java +++ b/reposilite-backend/src/main/java/org/panda_lang/reposilite/config/ConfigurationLoader.java @@ -56,7 +56,7 @@ public static Configuration load(String customConfigurationFile, String workingD verifyBasePath(configuration); verifyProxied(configuration); - FileUtils.overrideFile(configurationFile, cdn.compose(configuration)); + FileUtils.overrideFile(configurationFile, cdn.render(configuration)); loadProperties(configuration); return configuration; @@ -73,7 +73,7 @@ private static Configuration createConfiguration(File configurationFile) throws Reposilite.getLogger().info("Legacy configuration file has been found"); Configuration configuration = CDN.configure() - .enableIndentationFormatting() + .enableYamlLikeFormatting() .build() .parse(Configuration.class, FileUtils.getContentOfFile(legacyConfiguration)); diff --git a/reposilite-backend/src/main/java/org/panda_lang/reposilite/console/HelpCommand.java b/reposilite-backend/src/main/java/org/panda_lang/reposilite/console/HelpCommand.java index 641e57ef1..8dc904e1e 100644 --- a/reposilite-backend/src/main/java/org/panda_lang/reposilite/console/HelpCommand.java +++ b/reposilite-backend/src/main/java/org/panda_lang/reposilite/console/HelpCommand.java @@ -17,7 +17,7 @@ package org.panda_lang.reposilite.console; import org.panda_lang.reposilite.ReposiliteConstants; -import org.panda_lang.utilities.commons.text.ContentJoiner; +import org.panda_lang.utilities.commons.text.Joiner; import picocli.CommandLine; import picocli.CommandLine.Command; import picocli.CommandLine.Model.ArgSpec; @@ -67,8 +67,8 @@ public boolean execute(List response) { CommandSpec specification = command.getCommandSpec(); response.add(" " + command.getCommandName() - + " " + ContentJoiner.on(" ").join(specification.args(), ArgSpec::paramLabel) - + " - " + ContentJoiner.on(". ").join(specification.usageMessage().description())); + + " " + Joiner.on(" ").join(specification.args(), ArgSpec::paramLabel) + + " - " + Joiner.on(". ").join(specification.usageMessage().description())); } return true; diff --git a/reposilite-backend/src/main/java/org/panda_lang/reposilite/frontend/FrontendService.java b/reposilite-backend/src/main/java/org/panda_lang/reposilite/frontend/FrontendService.java index fe1faa0ff..33d31793f 100644 --- a/reposilite-backend/src/main/java/org/panda_lang/reposilite/frontend/FrontendService.java +++ b/reposilite-backend/src/main/java/org/panda_lang/reposilite/frontend/FrontendService.java @@ -20,7 +20,7 @@ import org.panda_lang.reposilite.utils.FilesUtils; import org.panda_lang.utilities.commons.StringUtils; import org.panda_lang.utilities.commons.function.Lazy; -import org.panda_lang.utilities.commons.text.MessageFormatter; +import org.panda_lang.utilities.commons.text.Formatter; import java.util.function.Supplier; @@ -43,7 +43,7 @@ public String getApp() { } public static FrontendService load(Configuration configuration) { - MessageFormatter formatter = new MessageFormatter() + Formatter formatter = new Formatter() .register("{{REPOSILITE.BASE_PATH}}", configuration.basePath) .register("{{REPOSILITE.VUE_BASE_PATH}}", configuration.basePath.equals("/") ? "" : configuration.basePath) .register("{{REPOSILITE.TITLE}}", configuration.title.replace("'", "\\'")) diff --git a/reposilite-backend/src/main/java/org/panda_lang/reposilite/metadata/MetadataUtils.java b/reposilite-backend/src/main/java/org/panda_lang/reposilite/metadata/MetadataUtils.java index 5e549e126..395ff7eec 100644 --- a/reposilite-backend/src/main/java/org/panda_lang/reposilite/metadata/MetadataUtils.java +++ b/reposilite-backend/src/main/java/org/panda_lang/reposilite/metadata/MetadataUtils.java @@ -16,12 +16,11 @@ package org.panda_lang.reposilite.metadata; -import org.panda_lang.panda.Panda; import org.panda_lang.reposilite.utils.FilesUtils; import org.panda_lang.utilities.commons.StringUtils; import org.panda_lang.utilities.commons.collection.Pair; import org.panda_lang.utilities.commons.function.PandaStream; -import org.panda_lang.utilities.commons.text.ContentJoiner; +import org.panda_lang.utilities.commons.text.Joiner; import java.io.File; import java.time.Instant; @@ -122,7 +121,7 @@ protected static String toUpdateTime(File file) { } public static String toGroup(String[] elements) { - return ContentJoiner.on(".") + return Joiner.on(".") .join(Arrays.copyOfRange(elements, 0, elements.length)) .toString(); } diff --git a/reposilite-backend/src/main/java/org/panda_lang/reposilite/repository/Repository.java b/reposilite-backend/src/main/java/org/panda_lang/reposilite/repository/Repository.java index 27d5986c5..05941d3ea 100644 --- a/reposilite-backend/src/main/java/org/panda_lang/reposilite/repository/Repository.java +++ b/reposilite-backend/src/main/java/org/panda_lang/reposilite/repository/Repository.java @@ -17,7 +17,7 @@ package org.panda_lang.reposilite.repository; import org.panda_lang.reposilite.metadata.MetadataUtils; -import org.panda_lang.utilities.commons.text.ContentJoiner; +import org.panda_lang.utilities.commons.text.Joiner; import java.io.File; import java.util.Arrays; @@ -58,7 +58,7 @@ public boolean isHidden() { } public File getFile(String... path) { - return new File(directory, ContentJoiner.on(File.separator).join(path).toString()); + return new File(directory, Joiner.on(File.separator).join(path).toString()); } public String getUri() { diff --git a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/ReposiliteIntegrationTestSpecification.groovy b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/ReposiliteIntegrationTestSpecification.groovy index 9675db5d2..05602290f 100644 --- a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/ReposiliteIntegrationTestSpecification.groovy +++ b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/ReposiliteIntegrationTestSpecification.groovy @@ -57,13 +57,13 @@ abstract class ReposiliteIntegrationTestSpecification extends ReposiliteTestSpec properties.forEach({ property, value -> System.setProperty(property, value) }) try { - return ReposiliteLauncher.create(ArrayUtils.mergeArrays(args, ArrayUtils.of( + return ReposiliteLauncher.create(ArrayUtils.merge(args, ArrayUtils.of( "--working-directory=" + workingDirectory.getAbsolutePath(), "--test-env" ))).orElseThrow({ new RuntimeException("Invalid test parameters") }) } finally { - System.clearProperty("reposilite.port"); + System.clearProperty("reposilite.port") properties.forEach({ key, value -> System.clearProperty(key) }) } } diff --git a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/config/ConfigurationLoaderTest.groovy b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/config/ConfigurationLoaderTest.groovy index 28373ddcf..e24ca6bbf 100644 --- a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/config/ConfigurationLoaderTest.groovy +++ b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/config/ConfigurationLoaderTest.groovy @@ -21,7 +21,7 @@ import net.dzikoysk.cdn.CDN import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir import org.panda_lang.utilities.commons.FileUtils -import org.panda_lang.utilities.commons.text.ContentJoiner +import org.panda_lang.utilities.commons.text.Joiner import static org.junit.jupiter.api.Assertions.* @@ -63,7 +63,7 @@ class ConfigurationLoaderTest { @Test void 'should load custom config' () { def customConfig = new File(workingDirectory, "random.cdn") - FileUtils.overrideFile(customConfig, CDN.defaultInstance().compose(new Configuration())) + FileUtils.overrideFile(customConfig, CDN.defaultInstance().render(new Configuration())) FileUtils.overrideFile(customConfig, FileUtils.getContentOfFile(customConfig).replace("port: 80", "port: 7")) def configuration = ConfigurationLoader.tryLoad(customConfig.getAbsolutePath(), workingDirectory.getAbsolutePath()) @@ -73,7 +73,7 @@ class ConfigurationLoaderTest { @Test void 'should not load other file types' () { def customConfig = new File(workingDirectory, "random.properties") - FileUtils.overrideFile(customConfig, CDN.defaultInstance().compose(new Configuration())) + FileUtils.overrideFile(customConfig, CDN.defaultInstance().render(new Configuration())) assertThrows RuntimeException.class, { ConfigurationLoader.load(customConfig.getAbsolutePath(), workingDirectory.getAbsolutePath()) } } @@ -92,7 +92,7 @@ class ConfigurationLoaderTest { @Test void 'should verify proxied' () { def config = new File(workingDirectory, "config.cdn") - FileUtils.overrideFile(config, ContentJoiner.on("\n").join( + FileUtils.overrideFile(config, Joiner.on("\n").join( "proxied {", " https://without.slash", " https://with.slash/", diff --git a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/console/ConsoleThreadTest.groovy b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/console/ConsoleThreadTest.groovy index 58ee56e97..68ecb34b7 100644 --- a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/console/ConsoleThreadTest.groovy +++ b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/console/ConsoleThreadTest.groovy @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test import org.panda_lang.reposilite.ReposiliteConstants import org.panda_lang.reposilite.ReposiliteWriter import org.panda_lang.reposilite.error.FailureService -import org.panda_lang.utilities.commons.text.ContentJoiner +import org.panda_lang.utilities.commons.text.Joiner import static org.junit.jupiter.api.Assertions.assertTrue @@ -32,7 +32,7 @@ class ConsoleThreadTest { void 'should print version message' () { executeInput("version") - assertTrue ContentJoiner.on('') + assertTrue Joiner.on('') .join(ReposiliteWriter.getCache()) .toString() .contains(ReposiliteConstants.VERSION) @@ -42,7 +42,7 @@ class ConsoleThreadTest { void 'should print docker info' () { executeInput('') - assertTrue ContentJoiner.on('') + assertTrue Joiner.on('') .join(ReposiliteWriter.getCache()) .toString() .contains("Docker") diff --git a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/ArtifactTest.groovy b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/ArtifactTest.groovy index 5b9e1f5c2..ceaf8ae8b 100644 --- a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/ArtifactTest.groovy +++ b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/ArtifactTest.groovy @@ -20,7 +20,7 @@ import groovy.transform.CompileStatic import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir -import org.panda_lang.utilities.commons.text.ContentJoiner +import org.panda_lang.utilities.commons.text.Joiner import static org.junit.jupiter.api.Assertions.assertEquals @@ -50,7 +50,7 @@ class ArtifactTest { @Test void 'should return artifact file' () { - def fileName = ContentJoiner.on(File.separator) + def fileName = Joiner.on(File.separator) .join(ARTIFACT.getRepository().getName(), ARTIFACT.getGroup(), ARTIFACT.getArtifact(), ARTIFACT.getVersion()) .toString() diff --git a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/DeployEndpointTest.groovy b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/DeployEndpointTest.groovy index f6050e202..1ba0f6259 100644 --- a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/DeployEndpointTest.groovy +++ b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/DeployEndpointTest.groovy @@ -92,7 +92,7 @@ class DeployEndpointTest extends ReposiliteIntegrationTestSpecification { def response = put(uri, username, password, content) assertEquals status, response.getStatusLine().getStatusCode() - def result = IOUtils.convertStreamToString(response.getEntity().getContent()).getValue() + def result = IOUtils.convertStreamToString(response.getEntity().getContent()).get() assertNotNull result assertTrue result.contains(message) } diff --git a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/LookupApiEndpointTest.groovy b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/LookupApiEndpointTest.groovy index be24b3b6e..bdeb2546f 100644 --- a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/LookupApiEndpointTest.groovy +++ b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/LookupApiEndpointTest.groovy @@ -38,10 +38,10 @@ class LookupApiEndpointTest extends ReposiliteIntegrationTestSpecification { def repositories = shouldReturn200AndJsonResponse('/api') assertNotNull repositories.get('files') - def files = repositories.getSection('files') + def files = repositories.getSection('files').get() assertEquals 2, files.size() - assertEquals 'releases', files.getSection(0).getString('name').get() - assertEquals 'snapshots', files.getSection(1).getString('name').get() + assertEquals 'releases', files.getSection(0).get().getString('name', null) + assertEquals 'snapshots', files.getSection(1).get().getString('name', null) } @Test @@ -52,11 +52,11 @@ class LookupApiEndpointTest extends ReposiliteIntegrationTestSpecification { assertEquals HttpStatus.SC_OK, response.getStatusCode() def repositories = CDN.defaultInstance().parseJson(response.parseAsString()) - def files = repositories.getSection('files') + def files = repositories.getSection('files').get() assertEquals 3, files.size() - assertEquals 'releases', files.getSection(0).getString('name').get() - assertEquals 'snapshots', files.getSection(1).getString('name').get() - assertEquals 'private', files.getSection(2).getString('name').get() + assertEquals 'releases', files.getSection(0).get().getString('name').get() + assertEquals 'snapshots', files.getSection(1).get().getString('name').get() + assertEquals 'private', files.getSection(2).get().getString('name').get() } @Test @@ -83,8 +83,8 @@ class LookupApiEndpointTest extends ReposiliteIntegrationTestSpecification { @Test void 'should return 200 and directory dto' () { def result = shouldReturn200AndJsonResponse('/api/org/panda-lang/reposilite-test') - def files = result.getSection('files') - assertEquals '1.0.1-SNAPSHOT', files.getSection(0).getString('name').get() + def files = result.getSection('files').get() + assertEquals '1.0.1-SNAPSHOT', files.getSection(0).get().getString('name').get() } private static Configuration shouldReturn200AndJsonResponse(String uri) { diff --git a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/ProxyServiceTest.groovy b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/ProxyServiceTest.groovy index ef5d628f5..c7b95c208 100644 --- a/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/ProxyServiceTest.groovy +++ b/reposilite-backend/src/test/groovy/org/panda_lang/reposilite/repository/ProxyServiceTest.groovy @@ -95,7 +95,7 @@ final class ProxyServiceTest extends ReposiliteIntegrationTestSpecification { def proxiedConfigurationFile = new File(PROXIED_WORKING_DIRECTORY.getAbsolutePath() + '/' + ReposiliteConstants.CONFIGURATION_FILE_NAME) proxiedConfigurationFile.getParentFile().mkdirs() - FileUtils.overrideFile(proxiedConfigurationFile, CDN.defaultInstance().compose(proxiedConfiguration)) + FileUtils.overrideFile(proxiedConfigurationFile, CDN.defaultInstance().render(proxiedConfiguration)) def proxiedReposilite = ReposiliteLauncher.create(null, PROXIED_WORKING_DIRECTORY.getAbsolutePath(), false, true)