sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject [sling-org-apache-sling-distribution-core] branch master updated: SLING-7343 - Replace the custom RegexpPathMapping with the one contributed in Jackrabbit Vault
Date Thu, 04 Jan 2018 10:13:18 GMT
This is an automated email from the ASF dual-hosted git repository.

simonetripodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 350ca7e  SLING-7343 - Replace the custom RegexpPathMapping with the one contributed
in Jackrabbit Vault
350ca7e is described below

commit 350ca7ee5ed61e4bfc80b6d1974d928c9b4af0d8
Author: Simo Tripodi <stripodi@adobe.com>
AuthorDate: Wed Jan 3 11:44:33 2018 +0100

    SLING-7343 - Replace the custom RegexpPathMapping with the one
    contributed in Jackrabbit Vault
---
 .../impl/vlt/FileVaultContentSerializer.java       |  1 +
 .../serialization/impl/vlt/RegexpPathMapping.java  | 60 ----------------------
 .../impl/vlt/RegexpPathMappingTest.java            | 57 --------------------
 3 files changed, 1 insertion(+), 117 deletions(-)

diff --git a/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultContentSerializer.java
b/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultContentSerializer.java
index 27e0df1..5547185 100644
--- a/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultContentSerializer.java
+++ b/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultContentSerializer.java
@@ -31,6 +31,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.apache.jackrabbit.vault.fs.api.ImportMode;
+import org.apache.jackrabbit.vault.fs.api.RegexpPathMapping;
 import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
 import org.apache.jackrabbit.vault.fs.config.MetaInf;
 import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
diff --git a/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/RegexpPathMapping.java
b/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/RegexpPathMapping.java
deleted file mode 100644
index 42eb206..0000000
--- a/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/RegexpPathMapping.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "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
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sling.distribution.serialization.impl.vlt;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.jackrabbit.vault.fs.api.PathMapping;
-
-final class RegexpPathMapping implements PathMapping {
-
-    private final Map<Pattern, String> pathsMapping = new HashMap<Pattern, String>();
-
-    public <K, V> void addAllMappings(Map<K, V> pathsMappingMap) {
-        for (Entry<K, V> entry : pathsMappingMap.entrySet()) {
-            addMapping(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
-        }
-    }
-
-    public void addMapping(String fromPattern, String toPattern) {
-        pathsMapping.put(Pattern.compile(fromPattern), toPattern);
-    }
-
-    @Override
-    public String map(String path) {
-        for (Entry<Pattern, String> pathMapping : pathsMapping.entrySet()) {
-            Matcher matcher = pathMapping.getKey().matcher(path);
-            if (matcher.matches()) {
-                return matcher.replaceAll(pathMapping.getValue());
-            }
-        }
-        return path;
-    }
-
-    // `reverse` is not taken in consideration at all in this version
-    @Override
-    public String map(String path, boolean reverse) {
-        return map(path);
-    }
-
-}
diff --git a/src/test/java/org/apache/sling/distribution/serialization/impl/vlt/RegexpPathMappingTest.java
b/src/test/java/org/apache/sling/distribution/serialization/impl/vlt/RegexpPathMappingTest.java
deleted file mode 100644
index e021742..0000000
--- a/src/test/java/org/apache/sling/distribution/serialization/impl/vlt/RegexpPathMappingTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "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
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sling.distribution.serialization.impl.vlt;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.sling.distribution.serialization.impl.vlt.RegexpPathMapping;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Testcase for {@link RegexpPathMappingTest}
- */
-public class RegexpPathMappingTest {
-
-    private RegexpPathMapping pathMapping;
-
-    @Before
-    public void setUp() {
-        pathMapping = new RegexpPathMapping();
-    }
-
-    @After
-    public void tearDown() {
-        pathMapping = null;
-    }
-
-    @Test
-    public void testIdentityMapping() {
-        assertEquals("/etc/my/fake/data", pathMapping.map("/etc/my/fake/data"));
-    }
-
-    @Test
-    public void testCorrectMapping() {
-        pathMapping.addMapping("/etc/(.*)", "/dummy/$1/custom");
-
-        assertEquals("/dummy/my/fake/data/custom", pathMapping.map("/etc/my/fake/data"));
-    }
-
-}

-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <commits@sling.apache.org>'].

Mime
View raw message