Index: main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/AccessControlHandling.java
===================================================================
--- main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/AccessControlHandling.java (nonexistent)
+++ main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/AccessControlHandling.java (working copy)
@@ -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;
+
+/**
+ * AccessControlHandling 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.
+ *
+ * Example:
+ *
+ * Content ACL:
+ *
+ * everyone, deny, jcr:all
+ * bob, allow, jcr:read
+ * bob, allow, jcr:write
+ *
+ *
+ * Package ACL:
+ *
+ * bob, deny, jcr:all
+ * alice, allow, jcr:read
+ *
+ *
+ * Result ACL:
+ *
+ * everyone, deny, jcr:all
+ * bob, deny, jcr:all
+ * alice, allow, jcr:read
+ *
+ */
+ 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.
+ *
+ *
+ * Example:
+ *
+ * Content ACL:
+ *
+ * everyone, deny, jcr:all
+ * bob, allow, jcr:read
+ * bob, allow, jcr:write
+ *
+ *
+ * Package ACL:
+ *
+ * bob, deny, jcr:all
+ * alice, allow, jcr:read
+ *
+ *
+ * Result ACL:
+ *
+ * everyone, deny, jcr:all
+ * bob, allow, jcr:read
+ * bob, allow, jcr:write
+ * alice, allow, jcr:read
+ *
+ */
+ MERGE_PRESERVE,
+
+ /**
+ * Clears all access control on the target system.
+ */
+ CLEAR,
+
+}
Property changes on: main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/AccessControlHandling.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: main/java/org/apache/jackrabbit/filevault/maven/packaging/VaultMojo.java
===================================================================
--- main/java/org/apache/jackrabbit/filevault/maven/packaging/VaultMojo.java (revision 1816621)
+++ main/java/org/apache/jackrabbit/filevault/maven/packaging/VaultMojo.java (working copy)
@@ -40,6 +40,7 @@
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;
@@ -248,6 +249,43 @@
private boolean allowIndexDefinitions;
/**
+ * Defines the AC handling. This will become the
+ * {@code acHandling} property of the properties.xml file.
+ * Possible values:
+ *
+ * ignore: Ignores the packaged access control and leaves the target unchanged.
+ * overwrite: Applies the access control provided with the package to the target. this also removes
+ * existing access control.
+ * 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.
+ * 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.
+ * clear: Clears all access control on the target system.
+ *
+ */
+ @Parameter(
+ property = "vault.acHandling",
+ required = false)
+ private AccessControlHandling acHandling;
+
+ /**
+ * Sets the AC handling.
+ * @param type the string representation of the ac handling
+ * @throws MojoFailureException if an error occurrs
+ */
+ public void setAcHandling(String type) throws MojoFailureException {
+ try {
+ acHandling = AccessControlHandling.valueOf(type.toUpperCase());
+ } catch (IllegalArgumentException e) {
+ throw new MojoFailureException("Invalid acHandling specified: " + type +".\n" +
+ "Must be empty or one of '" + StringUtils.join(AccessControlHandling.values(), "','") + "'.");
+ }
+
+ }
+
+ /**
* Controls if errors during dependency validation should fail the build.
*/
@Parameter(
@@ -383,6 +421,7 @@
* | allowIndexDefinitions | Use allowIndexDefinitions parameter to set |
* | packagePath | Automatically generated from the group and package name |
* | packageType | Set via the package type parameter |
+ * | acHandling | Use acHandling parameter to set |
*
*/
@Parameter
@@ -836,6 +875,9 @@
props.put("requiresRoot", String.valueOf(requiresRoot));
props.put("allowIndexDefinitions", String.valueOf(allowIndexDefinitions));
props.put("packageType", packageType.name().toLowerCase());
+ if (acHandling != null) {
+ props.put("acHandling", acHandling.name().toLowerCase());
+ }
return props;
}
Index: test/java/org/apache/jackrabbit/filevault/maven/packaging/it/PropertyConfigurationIT.java
===================================================================
--- test/java/org/apache/jackrabbit/filevault/maven/packaging/it/PropertyConfigurationIT.java (revision 1816621)
+++ test/java/org/apache/jackrabbit/filevault/maven/packaging/it/PropertyConfigurationIT.java (working copy)
@@ -31,4 +31,33 @@
.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");
+
+ }
+
}
Index: test/resources/test-projects/properties-from-map/pom.xml
===================================================================
--- test/resources/test-projects/properties-from-map/pom.xml (nonexistent)
+++ test/resources/test-projects/properties-from-map/pom.xml (working copy)
@@ -0,0 +1,52 @@
+
+
+ 4.0.0
+
+
+
+
+ org.apache.jackrabbit.filevault
+ package-plugin-test-pkg
+ 1.0.0-SNAPSHOT
+ content-package
+
+
+
+
+
+ org.apache.jackrabbit
+ filevault-package-maven-plugin
+ ${plugin.version}
+ true
+
+ false
+
+
+ true
+ true
+
+
+
+ overwrite
+
+
+
+
+
+
+
Property changes on: test/resources/test-projects/properties-from-map/pom.xml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: test/resources/test-projects/properties-from-map/pom.xml
===================================================================
--- test/resources/test-projects/properties-from-map/pom.xml (nonexistent)
+++ test/resources/test-projects/properties-from-map/pom.xml (working copy)
@@ -0,0 +1,52 @@
+
+
+ 4.0.0
+
+
+
+
+ org.apache.jackrabbit.filevault
+ package-plugin-test-pkg
+ 1.0.0-SNAPSHOT
+ content-package
+
+
+
+
+
+ org.apache.jackrabbit
+ filevault-package-maven-plugin
+ ${plugin.version}
+ true
+
+ false
+
+
+ true
+ true
+
+
+
+ overwrite
+
+
+
+
+
+
+
Property changes on: test/resources/test-projects/properties-from-map/pom.xml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: test/resources/test-projects/properties-from-plugin-config/pom.xml
===================================================================
--- test/resources/test-projects/properties-from-plugin-config/pom.xml (nonexistent)
+++ test/resources/test-projects/properties-from-plugin-config/pom.xml (working copy)
@@ -0,0 +1,54 @@
+
+
+ 4.0.0
+
+
+
+
+ org.apache.jackrabbit.filevault
+ package-plugin-test-pkg
+ 1.0.0-SNAPSHOT
+ content-package
+
+
+
+
+
+ org.apache.jackrabbit
+ filevault-package-maven-plugin
+ ${plugin.version}
+ true
+
+ false
+
+
+ true
+ true
+ merge
+
+
+ false
+ false
+ overwrite
+
+
+
+
+
+
+
Property changes on: test/resources/test-projects/properties-from-plugin-config/pom.xml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: test/resources/test-projects/properties-from-plugin-config/pom.xml
===================================================================
--- test/resources/test-projects/properties-from-plugin-config/pom.xml (nonexistent)
+++ test/resources/test-projects/properties-from-plugin-config/pom.xml (working copy)
@@ -0,0 +1,54 @@
+
+
+ 4.0.0
+
+
+
+
+ org.apache.jackrabbit.filevault
+ package-plugin-test-pkg
+ 1.0.0-SNAPSHOT
+ content-package
+
+
+
+
+
+ org.apache.jackrabbit
+ filevault-package-maven-plugin
+ ${plugin.version}
+ true
+
+ false
+
+
+ true
+ true
+ merge
+
+
+ false
+ false
+ overwrite
+
+
+
+
+
+
+
Property changes on: test/resources/test-projects/properties-from-plugin-config/pom.xml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id Author
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property