Skip to content

Commit eca4d58

Browse files
authored
JCRVLT-551 try to set UUID from package (#159)
add additional import options to tweak UUID collision behavior add documentation update asf parent to v24 always build site with Travis
1 parent ac74458 commit eca4d58

29 files changed

+843
-260
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ addons:
7070
script:
7171
- |
7272
if [ "$SONARQUBE_EXECUTION" == "true" ]; then
73-
mvn clean verify sonar:sonar -B -Pjacoco-report -Dsonar.projectKey=apache_jackrabbit-filevault -Dlogback.configurationFile=vault-core/src/test/resources/logback-only-errors.xml
73+
mvn clean verify site sonar:sonar -B -Pjacoco-report -Dsonar.projectKey=apache_jackrabbit-filevault -Dlogback.configurationFile=vault-core/src/test/resources/logback-only-errors.xml
7474
else
75-
mvn clean verify -B
75+
mvn clean verify site -B
7676
fi
7777
# If you use Gradle, cleanup the build cache from lock/temporary files
7878
before_cache:

parent/pom.xml

+10-47
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.apache</groupId>
2424
<artifactId>apache</artifactId>
25-
<version>23</version>
25+
<version>24</version>
2626
<relativePath />
2727
</parent>
2828

@@ -52,12 +52,14 @@ Apache Jackrabbit FileVault is a project of the Apache Software Foundation.
5252
<oak.version>1.40.0</oak.version>
5353
<slf4j.version>1.7.25</slf4j.version>
5454
<test.oak>true</test.oak> <!-- passed to integration test as property "oak", set to true to test with Oak, false means test with Jackrabbit 2 -->
55-
<java.target.version>1.8</java.target.version>
5655
<bnd.version>5.3.0</bnd.version>
57-
<maven.version>3.6.1</maven.version><!-- due to https://issues.apache.org/jira/browse/MNG-6059 -->
56+
<minimalMavenBuildVersion>3.6.1</minimalMavenBuildVersion><!-- due to https://issues.apache.org/jira/browse/MNG-6059 -->
57+
<minimalJavaBuildVersion>1.8</minimalJavaBuildVersion>
58+
<maven.compiler.target>1.8</maven.compiler.target>
5859
<surefire.version>3.0.0-M4</surefire.version>
5960
<sling.url>http://localhost:4502</sling.url>
6061
<jacoco.command /><!-- is overwritten by https://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html -->
62+
<project.build.outputTimestamp>2021-05-20T11:29:22Z</project.build.outputTimestamp>
6163
</properties>
6264

6365
<!-- ====================================================================== -->
@@ -203,15 +205,13 @@ Bundle-Category: jackrabbit
203205
<plugin>
204206
<groupId>org.apache.maven.plugins</groupId>
205207
<artifactId>maven-surefire-plugin</artifactId>
206-
<version>3.0.0-M5</version>
207208
<configuration>
208209
<trimStackTrace>false</trimStackTrace>
209210
</configuration>
210211
</plugin>
211212
<plugin>
212213
<groupId>org.apache.maven.plugins</groupId>
213214
<artifactId>maven-failsafe-plugin</artifactId>
214-
<version>3.0.0-M5</version>
215215
<configuration>
216216
<systemPropertyVariables>
217217
<!-- put derby.log (created for Jackrabbit based ITs below target instead of the current directory) -->
@@ -266,56 +266,21 @@ Bundle-Category: jackrabbit
266266
<plugin>
267267
<groupId>org.apache.maven.plugins</groupId>
268268
<artifactId>maven-site-plugin</artifactId>
269-
<version>3.9.1</version>
270269
<configuration>
271270
<skip>true</skip><!-- skip for all modules where not explicitly enabled -->
272271
<skipDeploy>true</skipDeploy><!-- always deploy via maven-scm-publish-plugin -->
273272
</configuration>
274-
<dependencies>
275-
<dependency>
276-
<groupId>org.apache.maven.doxia</groupId>
277-
<artifactId>doxia-module-markdown</artifactId>
278-
<version>1.10</version>
279-
</dependency>
280-
</dependencies>
281-
</plugin>
282-
<plugin>
283-
<groupId>org.apache.maven.plugins</groupId>
284-
<artifactId>maven-project-info-reports-plugin</artifactId>
285-
<version>3.1.2</version>
286273
</plugin>
287274
<plugin>
288-
<groupId>org.apache.maven.plugins</groupId>
289-
<artifactId>maven-javadoc-plugin</artifactId>
290-
<version>3.3.0</version>
275+
<groupId>org.jacoco</groupId>
276+
<artifactId>jacoco-maven-plugin</artifactId>
277+
<version>0.8.7</version>
291278
</plugin>
279+
<!-- update from 1.4.1 in ASF parent -->
292280
<plugin>
293281
<groupId>org.apache.maven.plugins</groupId>
294282
<artifactId>maven-enforcer-plugin</artifactId>
295-
<version>3.0.0-M3</version>
296-
<executions>
297-
<execution>
298-
<id>enforce-java-and-maven</id>
299-
<goals>
300-
<goal>enforce</goal>
301-
</goals>
302-
<configuration>
303-
<rules>
304-
<requireJavaVersion>
305-
<version>${java.target.version}</version>
306-
</requireJavaVersion>
307-
<requireMavenVersion>
308-
<version>${maven.version}</version>
309-
</requireMavenVersion>
310-
</rules>
311-
</configuration>
312-
</execution>
313-
</executions>
314-
</plugin>
315-
<plugin>
316-
<groupId>org.jacoco</groupId>
317-
<artifactId>jacoco-maven-plugin</artifactId>
318-
<version>0.8.7</version>
283+
<version>3.0.0</version>
319284
</plugin>
320285
</plugins>
321286
</pluginManagement>
@@ -340,8 +305,6 @@ Bundle-Category: jackrabbit
340305
<groupId>org.apache.maven.plugins</groupId>
341306
<artifactId>maven-compiler-plugin</artifactId>
342307
<configuration>
343-
<source>${java.target.version}</source>
344-
<target>${java.target.version}</target>
345308
<debug>true</debug>
346309
<showDeprecation>false</showDeprecation>
347310
<showWarnings>true</showWarnings>

src/site/markdown/importmode.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
Import Mode
1919
===========
20-
The import mode defines how imported content affects existing content in the repository. It is controlled by the [ImportMode][api.ImportMode] set in the [Workspace Filter](filter.html) and defaults to `REPLACE`.
20+
The import mode defines how imported content affects existing content in the repository. It is controlled by the [ImportMode][api.ImportMode] set in the [Workspace Filter](filter.html) and defaults to `REPLACE`.
21+
22+
Details on how node ids are treated during import are outlined at [Referenceable Nodes](referenceablenodes.html)
2123

2224
<!-- MACRO{toc} -->
2325

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
# Referenceable Nodes
19+
20+
<!-- MACRO{toc} -->
21+
22+
## Overview
23+
24+
The JCR 2.0 specification defines [referenceable nodes][1]. Those carry a `jcr:uuid` property which uniquely identifies a node within a repository workspace. Each FileVault export contains this (protected) property `jcr:uuid` as well which is important to keep [referential integrity][2].
25+
The import behavior depends on the used FileVault version.
26+
27+
## Behaviour prior FileVault 3.5.2
28+
29+
The ids of referenceable nodes are only kept during import when a node with the same name (independent of its `jcr:uuid` value) does not yet exist in the repository. For existing nodes the ids are never updated with the value from the package. They either get a new id or keep their old one (in case the old node was already a referenceable node). In case of conflicts with nodes at a different path, the existing conflicting node is [removed][5].
30+
31+
## Behavior since FileVault 3.5.2
32+
33+
Since version 3.5.2 ([JCRVLT-551](https://issues.apache.org/jira/browse/JCRVLT-551)) FileVault tries to use the `jcr:uuid` of the node in the package even if a same named node does already exist. In case this cannot be achieved while keeping referential integrity of old and new nodes an exception is thrown. Existing nodes with conflicting identifiers or reference properties towards conflicting identifiers are removed in advance if they are contained in the [filter rules][4] to reduce the conflict potential.
34+
35+
### Id Conflict Policies
36+
37+
The import behavior of packages with conflicting ids can be tweaked with `ImportOptions.setIdConflictPolicies(...)`. For further details refer to its [javadoc][3]. The old behavior can be achieved with `IdConflictPolicy.FORCE_REMOVE_CONFLICTING_ID`.
38+
39+
[1]: https://docs.adobe.com/content/docs/en/spec/jcr/2.0/3_Repository_Model.html#3.8%20Referenceable%20Nodes
40+
[2]: https://docs.adobe.com/content/docs/en/spec/jcr/2.0/3_Repository_Model.html#3.8.2%20Referential%20Integrity
41+
[3]: apidocs/org/apache/jackrabbit/vault/fs/api/IdConflictPolicies.html
42+
[4]: filter.html
43+
[5]: https://docs.adobe.com/content/docs/en/spec/jcr/2.0/11_Import.html#11.8.2%20Remove%20Existing%20Node

src/site/site.xml

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<item href="privileges.html" name="Privileges"/>
4545
<item href="installhooks.html" name="Install Hooks"/>
4646
</item>
47+
<item href="referenceablenodes.html" name="Referenceable Nodes"/>
4748
<item href="rcp.html" name="Vault Remote Copy" />
4849
</menu>
4950
<menu name="Developing">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.jackrabbit.vault.fs.api;
18+
19+
import javax.jcr.ImportUUIDBehavior;
20+
21+
public enum IdConflictPolicy {
22+
/** Default handling, fail in case of unresolvable conflicts. Conflicts are automatically resolved in case the conflicting UUID and all its references are inside the package filter. */
23+
FAIL,
24+
/** Create a new ID for the imported node (for all referenceable nodes), this may break existing references in the package. This fails if a referenced node is overwritten by a node with a different id */
25+
CREATE_NEW_ID,
26+
/** Remove the node with the conflicting id along with its references (even if outside the filters). This goes beyond {@link ImportUUIDBehavior#IMPORT_UUID_COLLISION_REMOVE_EXISTING}, as it also does not only resolve UUID collisions but also replacements of referenceable nodes with different ids.
27+
* Use with care, as this may remove references outside the filter. */
28+
FORCE_REMOVE_CONFLICTING_ID
29+
}

vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
@Version("2.9.0")
18+
@Version("2.10.0")
1919
package org.apache.jackrabbit.vault.fs.api;
2020

2121
import org.osgi.annotation.versioning.Version;

vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/AbstractArtifactHandler.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
3737
import org.apache.jackrabbit.vault.fs.impl.ArtifactSetImpl;
3838
import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
39+
import org.apache.jackrabbit.vault.fs.io.ImportOptions;
3940
import org.apache.jackrabbit.vault.fs.spi.ACLManagement;
4041
import org.apache.jackrabbit.vault.fs.spi.ServiceProviderFactory;
42+
import org.jetbrains.annotations.NotNull;
4143
import org.xml.sax.InputSource;
4244
import org.xml.sax.SAXException;
4345
import org.xml.sax.helpers.DefaultHandler;
@@ -119,7 +121,7 @@ public ImportInfo accept(Session session, Aggregate file,
119121
throws RepositoryException, IOException {
120122
Node node = file.getNode();
121123
String name = node.getName();
122-
return accept(file.getManager().getWorkspaceFilter(),
124+
return accept(new ImportOptions(), file.getManager().getWorkspaceFilter(),
123125
name.length() == 0 ? node : node.getParent(),
124126
name, (ArtifactSetImpl) artifacts);
125127
}
@@ -131,13 +133,14 @@ public ImportInfo accept(Session session, Aggregate parent, String name,
131133
ArtifactSet artifacts)
132134
throws RepositoryException, IOException {
133135
Node node = parent.getNode();
134-
return accept(parent.getManager().getWorkspaceFilter(),
136+
return accept(new ImportOptions(), parent.getManager().getWorkspaceFilter(),
135137
node, name, (ArtifactSetImpl) artifacts);
136138
}
137139

138140
/**
139141
* Imports an artifact set below the node.
140142
*
143+
* @param option the import options
141144
* @param wspFilter the workspace filter
142145
* @param parent the parent node
143146
* @param name the name of the (new) import
@@ -146,7 +149,7 @@ public ImportInfo accept(Session session, Aggregate parent, String name,
146149
* @throws RepositoryException if an error occurs.
147150
* @throws IOException if an I/O error occurs.
148151
*/
149-
protected abstract ImportInfoImpl accept(WorkspaceFilter wspFilter, Node parent,
152+
protected abstract ImportInfoImpl accept(@NotNull ImportOptions options, WorkspaceFilter wspFilter, Node parent,
150153
String name, ArtifactSetImpl artifacts)
151154
throws RepositoryException, IOException;
152155

0 commit comments

Comments
 (0)