You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2017/12/01 14:36:11 UTC
svn commit: r1816871 - in
/jackrabbit/commons/filevault-package-maven-plugin/trunk/src:
main/java/org/apache/jackrabbit/filevault/maven/packaging/
main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/
test/java/org/apache/jackrabbit/filevault...
Author: tripod
Date: Fri Dec 1 14:36:11 2017
New Revision: 1816871
URL: http://svn.apache.org/viewvc?rev=1816871&view=rev
Log:
JCRVLT-239 Package Maven Plugin: Add "accessControlcHandling" property
Added:
jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/AccessControlHandling.java
jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-map/
jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-map/pom.xml
jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-plugin-config/
jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-plugin-config/pom.xml
Modified:
jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/VaultMojo.java
jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/PropertyConfigurationIT.java
Modified: jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/VaultMojo.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/VaultMojo.java?rev=1816871&r1=1816870&r2=1816871&view=diff
==============================================================================
--- jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/VaultMojo.java (original)
+++ jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/VaultMojo.java Fri Dec 1 14:36:11 2017
@@ -40,6 +40,7 @@ import java.util.zip.ZipFile;
import javax.annotation.Nonnull;
import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.filevault.maven.packaging.impl.AccessControlHandling;
import org.apache.jackrabbit.filevault.maven.packaging.impl.DefaultWorkspaceFilter;
import org.apache.jackrabbit.filevault.maven.packaging.impl.PackageType;
import org.apache.jackrabbit.filevault.maven.packaging.impl.PathFilterSet;
@@ -240,6 +241,43 @@ public class VaultMojo extends AbstractM
private boolean allowIndexDefinitions;
/**
+ * Defines the Access control handling. This will become the
+ * {@code acHandling} property of the properties.xml file.<br/>
+ * Possible values:
+ * <ul>
+ * <li>{@code ignore}: Ignores the packaged access control and leaves the target unchanged.</li>
+ * <li>{@code overwrite}: Applies the access control provided with the package to the target. this also removes
+ * existing access control.</li>
+ * <li>{@code merge}: Merge access control provided with the package with the one in the content by replacing the
+ * access control entries of corresponding principals (i.e. package first). It never alters access control entries of
+ * principals not present in the package.</li>
+ * <li>{@code merge_preserve}: Merge access control in the content with the one provided with the package by
+ * adding the access control entries of principals not present in the content (i.e. content first). It never alters
+ * access control entries already existing in the content.</li>
+ * <li>{@code clear}: Clears all access control on the target system.</li>
+ * </ul>
+ */
+ @Parameter(
+ property = "vault.acHandling",
+ required = false)
+ private AccessControlHandling accessControlHandling;
+
+ /**
+ * Sets the access control handling.
+ * @param type the string representation of the ac handling
+ * @throws MojoFailureException if an error occurs
+ */
+ public void setAccessControlHandling(String type) throws MojoFailureException {
+ try {
+ accessControlHandling = AccessControlHandling.valueOf(type.toUpperCase());
+ } catch (IllegalArgumentException e) {
+ throw new MojoFailureException("Invalid accessControlHandling specified: " + type +".\n" +
+ "Must be empty or one of '" + StringUtils.join(AccessControlHandling.values(), "','") + "'.");
+ }
+
+ }
+
+ /**
* Controls if errors during dependency validation should fail the build.
*/
@Parameter(
@@ -442,6 +480,7 @@ public class VaultMojo extends AbstractM
* <tr><td>allowIndexDefinitions</td><td>Use <i>allowIndexDefinitions</i> parameter to set</td></tr>
* <tr><td>packagePath</td><td>Automatically generated from the group and package name</td></tr>
* <tr><td>packageType</td><td>Set via the package type parameter</td></tr>
+ * <tr><td>acHandling</td><td>Use <i>accessControlHandling</i> parameter to set</td></tr>
* </table>
*/
@Parameter
@@ -895,6 +934,9 @@ public class VaultMojo extends AbstractM
props.put("requiresRoot", String.valueOf(requiresRoot));
props.put("allowIndexDefinitions", String.valueOf(allowIndexDefinitions));
props.put("packageType", packageType.name().toLowerCase());
+ if (accessControlHandling != null) {
+ props.put("acHandling", accessControlHandling.name().toLowerCase());
+ }
return props;
}
Added: jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/AccessControlHandling.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/AccessControlHandling.java?rev=1816871&view=auto
==============================================================================
--- jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/AccessControlHandling.java (added)
+++ jackrabbit/commons/filevault-package-maven-plugin/trunk/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/AccessControlHandling.java Fri Dec 1 14:36:11 2017
@@ -0,0 +1,103 @@
+/*
+ * 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.filevault.maven.packaging.impl;
+
+/**
+ * <code>AccessControlHandling</code> defines the behavior when importing
+ * access control nodes.
+ */
+public enum AccessControlHandling {
+
+ /**
+ * Ignores the packaged access control and leaves the target unchanged.
+ */
+ IGNORE,
+
+ /**
+ * Applies the access control provided with the package to the target. this
+ * also removes existing access control.
+ */
+ OVERWRITE,
+
+ /**
+ * Merge access control provided with the package with the one in the
+ * content by replacing the access control entries of corresponding
+ * principals (i.e. package first). It never alters access control entries
+ * of principals not present in the package.
+ * <p/>
+ * Example:<br/>
+ *
+ * Content ACL:
+ * <pre>
+ * everyone, deny, jcr:all
+ * bob, allow, jcr:read
+ * bob, allow, jcr:write
+ * </pre>
+ *
+ * Package ACL:
+ * <pre>
+ * bob, deny, jcr:all
+ * alice, allow, jcr:read
+ * </pre>
+ *
+ * Result ACL:
+ * <pre>
+ * everyone, deny, jcr:all
+ * bob, deny, jcr:all
+ * alice, allow, jcr:read
+ * </pre>
+ */
+ MERGE,
+
+ /**
+ * Merge access control in the content with the one provided with the
+ * package by adding the access control entries of principals not present in the
+ * content (i.e. content first). It never alters access control entries already
+ * existing in the content.
+ *
+ * <p/>
+ * Example:<br/>
+ *
+ * Content ACL:
+ * <pre>
+ * everyone, deny, jcr:all
+ * bob, allow, jcr:read
+ * bob, allow, jcr:write
+ * </pre>
+ *
+ * Package ACL:
+ * <pre>
+ * bob, deny, jcr:all
+ * alice, allow, jcr:read
+ * </pre>
+ *
+ * Result ACL:
+ * <pre>
+ * everyone, deny, jcr:all
+ * bob, allow, jcr:read
+ * bob, allow, jcr:write
+ * alice, allow, jcr:read
+ * </pre>
+ */
+ MERGE_PRESERVE,
+
+ /**
+ * Clears all access control on the target system.
+ */
+ CLEAR,
+
+}
Modified: jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/PropertyConfigurationIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/PropertyConfigurationIT.java?rev=1816871&r1=1816870&r2=1816871&view=diff
==============================================================================
--- jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/PropertyConfigurationIT.java (original)
+++ jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/java/org/apache/jackrabbit/filevault/maven/packaging/it/PropertyConfigurationIT.java Fri Dec 1 14:36:11 2017
@@ -31,4 +31,33 @@ public class PropertyConfigurationIT {
.verifyPackageProperty("description", "Description from plugin");
}
+
+ /**
+ * Tests that properties like acHandling can be set via the "properties" map.
+ */
+ @Test
+ public void test_that_properties_can_be_set_via_map() throws Exception {
+ new ProjectBuilder()
+ .setTestProjectDir("properties-from-map")
+ .build()
+ .verifyPackageProperty("requiresRoot", "true")
+ .verifyPackageProperty("allowIndexDefinitions", "true")
+ .verifyPackageProperty("acHandling", "overwrite");
+
+ }
+
+ /**
+ * Tests set properties set explicitly as plugin config param have higher precedence than those in the properties map.
+ */
+ @Test
+ public void test_that_properties_set_in_plugin_config_have_higher_precedence() throws Exception {
+ new ProjectBuilder()
+ .setTestProjectDir("properties-from-plugin-config")
+ .build()
+ .verifyPackageProperty("requiresRoot", "true")
+ .verifyPackageProperty("allowIndexDefinitions", "true")
+ .verifyPackageProperty("acHandling", "merge");
+
+ }
+
}
Added: jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-map/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-map/pom.xml?rev=1816871&view=auto
==============================================================================
--- jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-map/pom.xml (added)
+++ jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-map/pom.xml Fri Dec 1 14:36:11 2017
@@ -0,0 +1,52 @@
+<!--
+ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ====================================================================== -->
+ <!-- P R O J E C T D E S C R I P T I O N -->
+ <!-- ====================================================================== -->
+ <groupId>org.apache.jackrabbit.filevault</groupId>
+ <artifactId>package-plugin-test-pkg</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>content-package</packaging>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>filevault-package-maven-plugin</artifactId>
+ <version>${plugin.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <failOnEmptyFilter>false</failOnEmptyFilter>
+
+ <!-- these property can only bet set via plugin properties -->
+ <requiresRoot>true</requiresRoot>
+ <allowIndexDefinitions>true</allowIndexDefinitions>
+
+ <properties>
+ <!-- property set here should be accepted because not set in plugin config -->
+ <acHandling>overwrite</acHandling>
+ </properties>
+
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-plugin-config/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-plugin-config/pom.xml?rev=1816871&view=auto
==============================================================================
--- jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-plugin-config/pom.xml (added)
+++ jackrabbit/commons/filevault-package-maven-plugin/trunk/src/test/resources/test-projects/properties-from-plugin-config/pom.xml Fri Dec 1 14:36:11 2017
@@ -0,0 +1,54 @@
+<!--
+ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ====================================================================== -->
+ <!-- P R O J E C T D E S C R I P T I O N -->
+ <!-- ====================================================================== -->
+ <groupId>org.apache.jackrabbit.filevault</groupId>
+ <artifactId>package-plugin-test-pkg</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>content-package</packaging>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>filevault-package-maven-plugin</artifactId>
+ <version>${plugin.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <failOnEmptyFilter>false</failOnEmptyFilter>
+
+ <!-- properties set here should have higher precedence than in the properties map -->
+ <requiresRoot>true</requiresRoot>
+ <allowIndexDefinitions>true</allowIndexDefinitions>
+ <accessControlHandling>merge</accessControlHandling>
+
+ <properties>
+ <requiresRoot>false</requiresRoot>
+ <allowIndexDefinitions>false</allowIndexDefinitions>
+ <acHandling>overwrite</acHandling>
+ </properties>
+
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>