From 371bd9f2ac1ad20aec0fee59cdb810f694d70b98 Mon Sep 17 00:00:00 2001 From: eschleb Date: Wed, 4 Dec 2024 17:31:02 +0100 Subject: [PATCH] Simplify bundles parsing (path is not needed in pattern, since we are already "walking" only child-files) --- .../FlexibleImageGeneratorModule.java | 10 +++++--- .../flexible/model/bundle/BundlesParser.java | 25 +++++++++++++------ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/merkle/oss/magnolia/imaging/flexible/FlexibleImageGeneratorModule.java b/src/main/java/com/merkle/oss/magnolia/imaging/flexible/FlexibleImageGeneratorModule.java index 8089b49..ac9a4b6 100644 --- a/src/main/java/com/merkle/oss/magnolia/imaging/flexible/FlexibleImageGeneratorModule.java +++ b/src/main/java/com/merkle/oss/magnolia/imaging/flexible/FlexibleImageGeneratorModule.java @@ -1,19 +1,23 @@ package com.merkle.oss.magnolia.imaging.flexible; -import com.google.inject.Provider; -import com.merkle.oss.magnolia.imaging.flexible.model.bundle.ProcessedBundlesProvider; import info.magnolia.module.ModuleLifecycle; import info.magnolia.module.ModuleLifecycleContext; + +import java.lang.invoke.MethodHandles; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; +import com.google.inject.Inject; +import com.google.inject.Provider; +import com.merkle.oss.magnolia.imaging.flexible.model.bundle.ProcessedBundlesProvider; public class FlexibleImageGeneratorModule implements ModuleLifecycle { private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final Provider bundlesProviderProvider; private String bundlesConfigPath; + @Inject public FlexibleImageGeneratorModule(final Provider bundlesProviderProvider){ this.bundlesProviderProvider = bundlesProviderProvider; } diff --git a/src/main/java/com/merkle/oss/magnolia/imaging/flexible/model/bundle/BundlesParser.java b/src/main/java/com/merkle/oss/magnolia/imaging/flexible/model/bundle/BundlesParser.java index 48f73fe..eae557c 100644 --- a/src/main/java/com/merkle/oss/magnolia/imaging/flexible/model/bundle/BundlesParser.java +++ b/src/main/java/com/merkle/oss/magnolia/imaging/flexible/model/bundle/BundlesParser.java @@ -1,18 +1,20 @@ package com.merkle.oss.magnolia.imaging.flexible.model.bundle; -import com.google.gson.Gson; -import com.google.gson.JsonIOException; -import com.google.gson.JsonSyntaxException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.invoke.MethodHandles; import java.net.URI; import java.net.URISyntaxException; -import java.nio.file.*; +import java.nio.file.FileSystem; +import java.nio.file.FileSystemNotFoundException; +import java.nio.file.FileSystems; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.PathMatcher; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.Collections; @@ -20,6 +22,13 @@ import java.util.function.Function; import java.util.stream.Stream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; +import com.google.gson.JsonIOException; +import com.google.gson.JsonSyntaxException; + public class BundlesParser { private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -50,7 +59,7 @@ private Stream create(final BundlesConfig bundlesConfig) { private Stream create(final String bundlesDirName, final String path) { try { - final String filePattern = "**" + path + "/**/" + bundlesDirName + "/*.json"; + final String filePattern = "**" + bundlesDirName + "/*.json"; LOG.info("Load image bundle definitions which match pattern '{}'", filePattern); final Stream.Builder> bundles = Stream.builder();