jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r1868686 - in /jackrabbit/commons/filevault/trunk: vault-core/ vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/ vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ vault-core/src/test/java/org/apache/jackrabb...
Date Mon, 21 Oct 2019 09:57:32 GMT
Author: kwin
Date: Mon Oct 21 09:57:32 2019
New Revision: 1868686

URL: http://svn.apache.org/viewvc?rev=1868686&view=rev
Log:
JCRVLT-371 allow optional dependencies locations property

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImplTest.java
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/pom.xml
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
    jackrabbit/commons/filevault/trunk/vault-doc/src/site/markdown/properties.md

Modified: jackrabbit/commons/filevault/trunk/vault-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/pom.xml?rev=1868686&r1=1868685&r2=1868686&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/pom.xml (original)
+++ jackrabbit/commons/filevault/trunk/vault-core/pom.xml Mon Oct 21 09:57:32 2019
@@ -211,6 +211,12 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest</artifactId>
+            <version>2.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
             <version>${slf4j.version}</version>

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java?rev=1868686&r1=1868685&r2=1868686&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
Mon Oct 21 09:57:32 2019
@@ -17,9 +17,11 @@
 
 package org.apache.jackrabbit.vault.packaging;
 
+import java.net.URI;
 import java.util.Calendar;
 import java.util.Map;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import org.apache.jackrabbit.vault.fs.api.VaultFsConfig;
@@ -74,6 +76,12 @@ public interface PackageProperties {
     String NAME_DEPENDENCIES = "dependencies";
 
     /**
+     * Name of the meta-inf property for locations of package dependencies. Each location
has the format {@code <packageId>=<uri>}.
+     * Multiple locations are separated by ",".
+     */
+    String NAME_DEPENDENCIES_LOCATIONS = "dependencies-locations";
+
+    /**
      * Name of the created meta-inf property
      */
     String NAME_CREATED = "created";
@@ -176,6 +184,13 @@ public interface PackageProperties {
      * @see #NAME_DEPENDENCIES
      */
     String MF_KEY_PACKAGE_DEPENDENCIES = "Content-Package-Dependencies";
+    
+    /**
+     * The manifest header key for locations of package dependencies. Each location has the
format {@code <packageId>=<uri>}.
+     * Multiple locations are separated by ",".
+     * @see #NAME_DEPENDENCIES_LOCATIONS
+     */
+    String MF_KEY_PACKAGE_DEPENDENCIES_LOCATIONS = "Content-Package-Dependencies-Locations";
 
     /**
      * The manifest header key for all filter roots separated by ','.
@@ -297,4 +312,10 @@ public interface PackageProperties {
      */
     @Nullable
     PackageType getPackageType();
+
+    /**
+     * Returns a map of dependency locations where key = package id and value = uri of package
dependency with that id.
+     * @return dependencies locations as map
+     */
+    @Nonnull Map<PackageId, URI> getDependenciesLocations();
 }
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java?rev=1868686&r1=1868685&r2=1868686&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
Mon Oct 21 09:57:32 2019
@@ -17,7 +17,10 @@
 
 package org.apache.jackrabbit.vault.packaging.impl;
 
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Calendar;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -171,6 +174,40 @@ public abstract class PackagePropertiesI
     /**
      * {@inheritDoc}
      */
+    @Override
+    public Map<PackageId, URI> getDependenciesLocations() {
+        String deps = getProperty(NAME_DEPENDENCIES_LOCATIONS);
+        if (deps == null || deps.length() == 0) {
+            return Collections.emptyMap();
+        } else {
+            // parse item in the format <pid>=<uri>, items are comma separated
+            Map<PackageId, URI> dependenciesLocations = new HashMap<>();
+            for (String item : deps.split(",")) {
+                String[] parts = item.split("=", 2);
+                if (parts.length < 2) {
+                    log.error("Invalid dependencies locations string, item " +item + " does
not contain a '='");
+                } else {
+                    PackageId packageId = PackageId.fromString(parts[0]);
+                    if (packageId == null) {
+                        log.error("Invalid package id given in item " + item);
+                        continue;
+                    }
+                    try {
+                        URI uri = new URI(parts[1]);
+                        dependenciesLocations.put(packageId, uri);
+                    } catch (URISyntaxException e) {
+                        log.error("Invalid uri given in item " + item);
+                    }
+                    
+                }
+            }
+            return dependenciesLocations;
+        }
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public Calendar getDateProperty(String name) {
         try {

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImplTest.java?rev=1868686&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImplTest.java
(added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImplTest.java
Mon Oct 21 09:57:32 2019
@@ -0,0 +1,79 @@
+/*
+ * 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.jackrabbit.vault.packaging.impl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.jackrabbit.vault.packaging.PackageId;
+import org.apache.jackrabbit.vault.packaging.PackageProperties;
+import org.hamcrest.Matchers;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PackagePropertiesImplTest {
+
+    class SimplePackageProperties extends PackagePropertiesImpl {
+        final Properties properties;
+
+        public SimplePackageProperties(Map<String, String> properties) {
+            this.properties = new Properties();
+            this.properties.putAll(properties);
+        }
+        
+        @Override
+        protected Properties getPropertiesMap() {
+            return properties;
+        }
+    }
+
+    @Test
+    public void testGetDependenciesLocations() throws URISyntaxException {
+        PackageProperties packageProperties = new SimplePackageProperties(Collections.singletonMap(PackageProperties.NAME_DEPENDENCIES_LOCATIONS,
"group1:name1:1.0=maven:com.example.mygroupid:myartifactId:1.0.0:zip"));
+        Assert.assertThat(packageProperties.getDependenciesLocations(), Matchers.equalTo(Collections.singletonMap(PackageId.fromString("group1:name1:1.0"),
new URI("maven:com.example.mygroupid:myartifactId:1.0.0:zip"))));
+        
+        packageProperties = new SimplePackageProperties(Collections.singletonMap(PackageProperties.NAME_DEPENDENCIES_LOCATIONS,
"group1:name1:1.0=maven:com.example.mygroupid:myartifactId:1.0.0:zip,group2:name2:2.0=maven:com.example.mygroupid2:myartifactId2:2.0.0:zip,"));
+        Map<PackageId, URI> expectedDependenciesLocations = new HashMap<>();
+        expectedDependenciesLocations.put(PackageId.fromString("group1:name1:1.0"), new URI("maven:com.example.mygroupid:myartifactId:1.0.0:zip"));
+        expectedDependenciesLocations.put(PackageId.fromString("group2:name2:2.0"), new URI("maven:com.example.mygroupid2:myartifactId2:2.0.0:zip"));
+        
+        Assert.assertThat(packageProperties.getDependenciesLocations(), Matchers.equalTo(expectedDependenciesLocations));
+    }
+
+    @Test
+    public void testGetInvalidDependenciesLocations() throws URISyntaxException {
+        PackageProperties packageProperties = new SimplePackageProperties(Collections.singletonMap(PackageProperties.NAME_DEPENDENCIES_LOCATIONS,
"group1:name1:1.0maven:com.example.mygroupid:myartifactId:1.0.0:zip"));
+        // no key=value format
+        Assert.assertThat(packageProperties.getDependenciesLocations(), Matchers.equalTo(Collections.emptyMap()));
+        // invalid key (pid)
+        packageProperties = new SimplePackageProperties(Collections.singletonMap(PackageProperties.NAME_DEPENDENCIES_LOCATIONS,
"=maven:com.example.mygroupid:myartifactId:1.0.0:zip"));
+        Assert.assertThat(packageProperties.getDependenciesLocations(), Matchers.equalTo(Collections.emptyMap()));
+        // invalid value (uri)
+        packageProperties = new SimplePackageProperties(Collections.singletonMap(PackageProperties.NAME_DEPENDENCIES_LOCATIONS,
"group1:name1:1.0=maven:invalid uri"));
+        Assert.assertThat(packageProperties.getDependenciesLocations(), Matchers.equalTo(Collections.emptyMap()));
+    }
+
+    @Test
+    public void testGetNotSetDependenciesLocations() throws URISyntaxException {
+        PackageProperties packageProperties = new SimplePackageProperties(Collections.emptyMap());
+        Assert.assertThat(packageProperties.getDependenciesLocations(), Matchers.equalTo(Collections.emptyMap()));
+    }
+}

Modified: jackrabbit/commons/filevault/trunk/vault-doc/src/site/markdown/properties.md
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-doc/src/site/markdown/properties.md?rev=1868686&r1=1868685&r2=1868686&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-doc/src/site/markdown/properties.md (original)
+++ jackrabbit/commons/filevault/trunk/vault-doc/src/site/markdown/properties.md Mon Oct 21
09:57:32 2019
@@ -62,11 +62,13 @@ Example:
 | lastModifiedBy | A user name indicating who last modified this package | no | empty
 | buildCount | An integer indicating how often this package has been built | no | empty
 | dependencies | Comma-separated list of dependencies. Each dependency has the format `<group>:<name>:<version
or versionrange>`. See [Dependencies][api.Dependency]. | no | empty
+| dependencies-locations | Optional comma-separated list of dependencies' locations. Each
item has the format `<package-id>=<uri>`. Currently [FileVault Package Maven Plugin](https://jackrabbit.apache.org/filevault-package-maven-plugin/index.html)
is using a URI scheme for Maven coordinates like 
+`maven:<groupId>:<artifactId>:<version>[[:<classifier>]:packaging]`.
| no | empty
 | created | A date string in the format `±YYYY-MM-DDThh:mm:ss.SSSTZD` specifying when
the package has been created initially (see also [ISO8601][api.ISO8601]) | no | empty
 | createdBy | A user name indicating who initially created this package | no | empty
 | lastWrapped | A date string in the format `±YYYY-MM-DDThh:mm:ss.SSSTZD` specifying when
the package has been last wrapped (i.e. rebuilt) (see also [ISO8601][api.ISO8601]) | no |
empty
 | lastWrappedBy | A user name indicating who last modified this package | no | empty
-| acHandling | See [AccessControlHandling][api. AccessControlHandling]. | no | ignore
+| acHandling | See [AccessControlHandling][api.AccessControlHandling]. | no | ignore
 | cndPattern | A [Java regular expression pattern](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)
which specifies where to look for CND files within the given package | no | `^/(apps|libs)/([^/]+/){1,2}nodetypes/.+\\.cnd$`
 | requiresRoot | If set to `true` indicates that only admin sessions can install this package
| no | `false`
 | requiresRestart | If set to `true` indicates that the system should be restarted after
this package has been installed | no | `false`
@@ -88,6 +90,7 @@ Since version 3.1.40 ([JCRVLT-32](https:
 | Attribute | Description |
 | -------- | ------- |
 | Content-Package-Dependencies | Same as `dependencies` within the `properties.xml` |
+| Content-Package-Dependencies-Locations | Same as `dependencies-locations` within the `properties.xml`
|
 | Content-Package-Description | Same as `description` within the `properties.xml` |
 | Content-Package-Type | Same as `packageType` within the `properties.xml`
 | Content-Package-Id | The string format of the [PackageId][api.PackageId] |



Mime
View raw message