Skip to content

Commit

Permalink
Simplify bundles parsing (path is not needed in pattern, since we are…
Browse files Browse the repository at this point in the history
… already "walking" only child-files)
  • Loading branch information
eschleb committed Dec 4, 2024
1 parent 2df1b40 commit 371bd9f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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<ProcessedBundlesProvider> bundlesProviderProvider;
private String bundlesConfigPath;

@Inject
public FlexibleImageGeneratorModule(final Provider<ProcessedBundlesProvider> bundlesProviderProvider){
this.bundlesProviderProvider = bundlesProviderProvider;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
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;
import java.util.Optional;
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());

Expand Down Expand Up @@ -50,7 +59,7 @@ private Stream<Bundle> create(final BundlesConfig bundlesConfig) {

private Stream<Bundle> 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<Stream<Bundle>> bundles = Stream.builder();

Expand Down

0 comments on commit 371bd9f

Please sign in to comment.