sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [sling-org-apache-sling-feature-cpconverter] branch master updated: SLING-10481: remove computeFilter from VaultPackageAssembler as it is not used anymore. (#105)
Date Wed, 01 Sep 2021 16:02:04 GMT
This is an automated email from the ASF dual-hosted git repository.

pauls pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git


The following commit(s) were added to refs/heads/master by this push:
     new 0847d91  SLING-10481: remove computeFilter from VaultPackageAssembler as it is not
used anymore. (#105)
0847d91 is described below

commit 0847d913519a3d41bfb722647a2dedf724e923a5
Author: Karl Pauls <pauls@apache.org>
AuthorDate: Wed Sep 1 18:01:57 2021 +0200

    SLING-10481: remove computeFilter from VaultPackageAssembler as it is not used anymore.
(#105)
---
 .../cpconverter/handlers/BundleEntryHandler.java   |  2 +-
 .../handlers/SlingInitialContentBundleHandler.java |  2 +-
 .../cpconverter/vltpkg/VaultPackageAssembler.java  | 74 ----------------------
 3 files changed, 2 insertions(+), 76 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
b/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
index 44a3da1..827d8dd 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
@@ -421,7 +421,7 @@ public class BundleEntryHandler extends AbstractRegexEntryHandler {
 
     void finalizePackageAssembly(@NotNull String path, @NotNull Map<PackageType, VaultPackageAssembler>
packageAssemblers, @NotNull ContentPackage2FeatureModelConverter converter, @Nullable String
runMode) throws IOException, ConverterException {
         for (java.util.Map.Entry<PackageType, VaultPackageAssembler> entry : packageAssemblers.entrySet())
{
-            File packageFile = entry.getValue().createPackage(false);
+            File packageFile = entry.getValue().createPackage();
             converter.processSubPackage(path + "-" + entry.getKey(), runMode, converter.open(packageFile),
true);
         }
     }
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/handlers/SlingInitialContentBundleHandler.java
b/src/main/java/org/apache/sling/feature/cpconverter/handlers/SlingInitialContentBundleHandler.java
index 967f561..829b89d 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/handlers/SlingInitialContentBundleHandler.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/handlers/SlingInitialContentBundleHandler.java
@@ -52,7 +52,7 @@ public class SlingInitialContentBundleHandler extends BundleEntryHandler
{
     @Override
     void finalizePackageAssembly(@NotNull String path, @NotNull Map<PackageType, VaultPackageAssembler>
packageAssemblers, @NotNull ContentPackage2FeatureModelConverter converter, @Nullable String
runMode) throws IOException, ConverterException {
         for (java.util.Map.Entry<PackageType, VaultPackageAssembler> entry : packageAssemblers.entrySet())
{
-            File packageFile = entry.getValue().createPackage(false);
+            File packageFile = entry.getValue().createPackage();
             handler.processSubPackage(path + "-" + entry.getKey(), runMode, converter.open(packageFile),
converter, true);
         }
     }
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/vltpkg/VaultPackageAssembler.java
b/src/main/java/org/apache/sling/feature/cpconverter/vltpkg/VaultPackageAssembler.java
index 7f04523..e3692e2 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/vltpkg/VaultPackageAssembler.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/vltpkg/VaultPackageAssembler.java
@@ -18,7 +18,6 @@ package org.apache.sling.feature.cpconverter.vltpkg;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.filefilter.DirectoryFileFilter;
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
 import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
 import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
@@ -29,16 +28,13 @@ import org.apache.jackrabbit.vault.packaging.PackageId;
 import org.apache.jackrabbit.vault.packaging.PackageProperties;
 import org.apache.jackrabbit.vault.packaging.PackageType;
 import org.apache.jackrabbit.vault.packaging.VaultPackage;
-import org.apache.jackrabbit.vault.util.PlatformNameFormat;
 import org.apache.sling.feature.cpconverter.ContentPackage2FeatureModelConverter;
 import org.apache.sling.feature.cpconverter.handlers.DefaultEntryParser;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
-import java.io.FileFilter;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -277,10 +273,6 @@ public class VaultPackageAssembler {
     }
 
     public @NotNull File createPackage() throws IOException {
-        return createPackage(false);
-    }
-
-    public @NotNull File createPackage(boolean generateFilters) throws IOException {
         // generate the Vault properties XML file
 
         File metaDir = new File(storingDirectory, META_DIR);
@@ -307,11 +299,6 @@ public class VaultPackageAssembler {
         try (FileOutputStream fos = new FileOutputStream(xmlProperties)) {
             properties.storeToXML(fos, null);
         }
-
-        if (generateFilters) {
-            // generate the Vault filter XML file based on new contents of the package
-            computeFilters(storingDirectory);
-        }
         
         Set<String> allRepoPaths = VaultPackageUtils.toRepositoryPaths(allPaths);
         Set<String> convertedCpRepoPaths = VaultPackageUtils.toRepositoryPaths(convertedCpPaths);
@@ -372,67 +359,6 @@ public class VaultPackageAssembler {
         }
     }
 
-    private void computeFilters(@NotNull File outputDirectory) {
-        VaultPackageUtils.forEachDirectoryBelowJcrRoot(outputDirectory, (child, base) ->
{
-            TreeNode node = lowestCommonAncestor(new TreeNode(child));
-            File lowestCommonAncestor = node != null ? node.val : null;
-            if (lowestCommonAncestor != null) {
-                String root = "/" + PlatformNameFormat.getRepositoryPath(base.toURI().relativize(lowestCommonAncestor.toURI()).getPath(),
true);
-                filter.add(new PathFilterSet(root));
-            }
-        });
-    }
-
-    private static @Nullable TreeNode lowestCommonAncestor(@NotNull TreeNode root) {
-        int currMaxDepth = 0;//curr tree's deepest leaf depth
-        int countMaxDepth = 0;//num of deepest leaves
-        TreeNode node = null;
-
-        for (File child : root.val.listFiles((FileFilter) DirectoryFileFilter.INSTANCE))
{
-            TreeNode temp = lowestCommonAncestor(new TreeNode(child));
-
-            if (temp == null) {
-                continue;
-            } else if (temp.maxDepth > currMaxDepth) {//if deeper leaf found,update everything
to that deeper leaf
-                currMaxDepth = temp.maxDepth;
-                node = temp;//update the maxDepth leaf/LCA
-                countMaxDepth = 1;//reset count of maxDepth leaves
-            } else if (temp.maxDepth == currMaxDepth) {
-                countMaxDepth++;//more deepest leaves of curr (sub)tree found
-            }
-        }
-
-        if (countMaxDepth > 1) {
-            //if there're several leaves at the deepest level of curr tree,curr root is the
LCA of them
-            //OR if there're several LCA of several deepest leaves in curr tree,curr root
is also the LCA of them
-            root.maxDepth = node.maxDepth + 1;//update root's maxDepth and return it
-            return root;
-        } else if (countMaxDepth == 1) {
-            //if there's only 1 deepest leaf or only 1 LCA of curr tree,return that leaf/LCA
-            node.maxDepth++;//update node's maxDepth and return it
-            return node;
-        } else if (countMaxDepth == 0) {
-            //if curr root's children have no children(all leaves,so all return null to temp),set
root's maxDepth to 2,return
-            root.maxDepth = 2;//update node's maxDepth to 2 cuz its children are leaves
-            return root;
-        }
-
-        return null;
-    }
-
-    private static final class TreeNode {
-
-        File val;
-
-        int maxDepth;//this means the maxDepth of curr treenode-rooted (sub)tree
-
-        TreeNode(@NotNull File x) {
-            val = x;
-            maxDepth = 0;
-        }
-
-    }
-
     private static final class RemoveInstallHooksPredicate implements Predicate<Map.Entry<Object,
Object>> {
         @Override
         public boolean test(java.util.Map.Entry<Object, Object> entry) {

Mime
View raw message