This is an automated email from the ASF dual-hosted git repository. ottlinger pushed a commit to branch feature/TENTACLES-26 in repository https://gitbox.apache.org/repos/asf/creadur-tentacles.git
commit 4a8f82e096774af1ba9305605c53eb80908fdd4f Author: P. Ottlinger <[email protected]> AuthorDate: Fri Jul 17 12:50:00 2026 +0200 TENTACLES-26: Reformat code and inline as record --- .../apache/creadur/tentacles/Configuration.java | 2 +- .../org/apache/creadur/tentacles/IOSystem.java | 2 +- .../java/org/apache/creadur/tentacles/Layout.java | 5 ++-- .../org/apache/creadur/tentacles/LicenseType.java | 2 +- .../org/apache/creadur/tentacles/Licenses.java | 2 +- .../java/org/apache/creadur/tentacles/Main.java | 15 +++++------ .../org/apache/creadur/tentacles/NexusClient.java | 4 +-- .../org/apache/creadur/tentacles/Platform.java | 30 +++------------------- .../org/apache/creadur/tentacles/Templates.java | 4 +-- 9 files changed, 21 insertions(+), 45 deletions(-) diff --git a/src/main/java/org/apache/creadur/tentacles/Configuration.java b/src/main/java/org/apache/creadur/tentacles/Configuration.java index e2d7f4c..09be985 100644 --- a/src/main/java/org/apache/creadur/tentacles/Configuration.java +++ b/src/main/java/org/apache/creadur/tentacles/Configuration.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information diff --git a/src/main/java/org/apache/creadur/tentacles/IOSystem.java b/src/main/java/org/apache/creadur/tentacles/IOSystem.java index 4d3d7fd..198e790 100644 --- a/src/main/java/org/apache/creadur/tentacles/IOSystem.java +++ b/src/main/java/org/apache/creadur/tentacles/IOSystem.java @@ -106,7 +106,7 @@ public class IOSystem { } } - public OutputStream write(final File destination) throws IOException { + private OutputStream write(final File destination) throws IOException { final OutputStream out = Files.newOutputStream(destination.toPath()); return new BufferedOutputStream(out, 32768); } diff --git a/src/main/java/org/apache/creadur/tentacles/Layout.java b/src/main/java/org/apache/creadur/tentacles/Layout.java index 9b37a03..c166b5b 100644 --- a/src/main/java/org/apache/creadur/tentacles/Layout.java +++ b/src/main/java/org/apache/creadur/tentacles/Layout.java @@ -32,13 +32,14 @@ public class Layout { this.localRootDirectory = new File(configuration.getRootDirectoryForLocalOutput()); - final FileSystem fileSystem = platform.getFileSystem(); + final FileSystem fileSystem = platform.fileSystem(); fileSystem.mkdirs(this.localRootDirectory); + this.output = this.localRootDirectory; + this.repository = new File(this.localRootDirectory, "repo"); this.contentRootDirectory = new File(this.localRootDirectory, "content"); - this.output = this.localRootDirectory; fileSystem.mkdirs(this.repository); fileSystem.mkdirs(this.contentRootDirectory); diff --git a/src/main/java/org/apache/creadur/tentacles/LicenseType.java b/src/main/java/org/apache/creadur/tentacles/LicenseType.java index 59ad0ce..fab89f2 100644 --- a/src/main/java/org/apache/creadur/tentacles/LicenseType.java +++ b/src/main/java/org/apache/creadur/tentacles/LicenseType.java @@ -31,7 +31,7 @@ public enum LicenseType { final Map<String, String> licenses = new ConcurrentHashMap<>(); for (final LicenseType type : values()) { - type.putTextInto(licenses, platform.getTentaclesResources()); + type.putTextInto(licenses, platform.tentaclesResources()); } return new Licenses(licenses, platform); } diff --git a/src/main/java/org/apache/creadur/tentacles/Licenses.java b/src/main/java/org/apache/creadur/tentacles/Licenses.java index 261cade..ad4b6a0 100644 --- a/src/main/java/org/apache/creadur/tentacles/Licenses.java +++ b/src/main/java/org/apache/creadur/tentacles/Licenses.java @@ -30,7 +30,7 @@ public class Licenses { public Licenses(final Map<String, String> licenses, final Platform platform) { super(); - this.ioSystem = platform.getIoSystem(); + this.ioSystem = platform.ioSystem(); this.licenses = Collections.unmodifiableMap(licenses); } diff --git a/src/main/java/org/apache/creadur/tentacles/Main.java b/src/main/java/org/apache/creadur/tentacles/Main.java index 5a3eceb..6a27615 100644 --- a/src/main/java/org/apache/creadur/tentacles/Main.java +++ b/src/main/java/org/apache/creadur/tentacles/Main.java @@ -77,9 +77,9 @@ public class Main { this.platform = platform; this.configuration = configuration; this.layout = layout; - this.fileSystem = platform.getFileSystem(); - this.ioSystem = platform.getIoSystem(); - this.tentaclesResources = platform.getTentaclesResources(); + this.fileSystem = platform.fileSystem(); + this.ioSystem = platform.ioSystem(); + this.tentaclesResources = platform.tentaclesResources(); this.templates = templates; this.reports = new Reports(); @@ -320,7 +320,7 @@ public class Main { } else if (LOCAL_FILE_SYSTEM.isRepositoryFor(configuration)) { final File file = new File(configuration.getStagingRepositoryURI()); final List<File> collect = - this.platform.getFileSystem().archivesInPath(file, + this.platform.fileSystem().archivesInPath(file, configuration.getFileRepositoryPathNameFilter()); for (final File f : collect) { @@ -349,11 +349,10 @@ public class Main { continue; } - final String path = entry.getName(); - // check if entry has suspicious path traversal elements - Path target = contents.toPath().toAbsolutePath().normalize(); - Path resolved = target.resolve(path).normalize(); + final String path = entry.getName(); + final Path target = contents.toPath().toAbsolutePath().normalize(); + final Path resolved = target.resolve(path).normalize(); if(!resolved.startsWith(target)) { throw new IOException("Invalid archive entry: " + path); diff --git a/src/main/java/org/apache/creadur/tentacles/NexusClient.java b/src/main/java/org/apache/creadur/tentacles/NexusClient.java index 465d6b9..dfecde8 100644 --- a/src/main/java/org/apache/creadur/tentacles/NexusClient.java +++ b/src/main/java/org/apache/creadur/tentacles/NexusClient.java @@ -57,8 +57,8 @@ public class NexusClient { this.client = HttpClientBuilder.create().disableContentCompression() .build(); - this.fileSystem = platform.getFileSystem(); - this.ioSystem = platform.getIoSystem(); + this.fileSystem = platform.fileSystem(); + this.ioSystem = platform.ioSystem(); } public File download(final URI uri, final File file) throws IOException { diff --git a/src/main/java/org/apache/creadur/tentacles/Platform.java b/src/main/java/org/apache/creadur/tentacles/Platform.java index f87fffc..2810ca6 100644 --- a/src/main/java/org/apache/creadur/tentacles/Platform.java +++ b/src/main/java/org/apache/creadur/tentacles/Platform.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -18,7 +18,7 @@ */ package org.apache.creadur.tentacles; -public class Platform { +public record Platform(TentaclesResources tentaclesResources, FileSystem fileSystem, IOSystem ioSystem) { public static Platform aPlatform() { final FileSystem fileSystem = new FileSystem(); @@ -28,28 +28,4 @@ public class Platform { return new Platform(tentaclesResources, fileSystem, ioSystem); } - private final TentaclesResources tentaclesResources; - private final FileSystem fileSystem; - private final IOSystem ioSystem; - - public Platform(final TentaclesResources tentaclesResources, - final FileSystem fileSystem, final IOSystem ioSystem) { - super(); - this.tentaclesResources = tentaclesResources; - this.fileSystem = fileSystem; - this.ioSystem = ioSystem; - } - - public TentaclesResources getTentaclesResources() { - return this.tentaclesResources; - } - - public FileSystem getFileSystem() { - return this.fileSystem; - } - - public IOSystem getIoSystem() { - return this.ioSystem; - } - } diff --git a/src/main/java/org/apache/creadur/tentacles/Templates.java b/src/main/java/org/apache/creadur/tentacles/Templates.java index d41eaa8..cfe3fd3 100644 --- a/src/main/java/org/apache/creadur/tentacles/Templates.java +++ b/src/main/java/org/apache/creadur/tentacles/Templates.java @@ -26,8 +26,8 @@ public final class Templates { private final TentaclesResources tentaclesResources; public Templates(final Platform platform) { - this.ioSystem = platform.getIoSystem(); - this.tentaclesResources = platform.getTentaclesResources(); + this.ioSystem = platform.ioSystem(); + this.tentaclesResources = platform.tentaclesResources(); final Properties properties = new Properties(); properties.setProperty("resource.loader.class.cache", "true"); properties.setProperty("resource.loaders", "class");
