Skip to content

Commit 61e920f

Browse files
committed
JCRVLT-551 improve documentation
check references in tests
1 parent eca4d58 commit 61e920f

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/site/markdown/referenceablenodes.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
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].
2525
The import behavior depends on the used FileVault version.
2626

27-
## Behaviour prior FileVault 3.5.2
27+
## Import behavior prior FileVault 3.5.2
2828

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].
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] but all its references are kept (i.e. they point to a different path after the import).
3030

31-
## Behavior since FileVault 3.5.2
31+
## Import behavior since FileVault 3.5.2
3232

3333
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.
3434

vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ReferenceableIdentifiersImportIT.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -183,25 +183,32 @@ public void testIdentifierCollisionInsideFilterWithReferencesOutsideFilter() thr
183183
admin.save();
184184
assertProperty("/tmp/reference/" + PROPERTY_NAME, UUID_REFERENCEABLE_CHILD);
185185

186-
PropertyIterator propIter = referenceableNode.getReferences();
187-
assertTrue(propIter.hasNext());
188-
189186
// install package again (with default policy IdConflictPolicy.FAIL)
190187
Exception e = assertThrows(Exception.class, () -> { extractVaultPackageStrict("/test-packages/referenceable.zip"); } );
191188
assertEquals(ReferentialIntegrityException.class, e.getClass());
192189
admin.refresh(false);
193-
190+
assertProperty("/tmp/reference/" + PROPERTY_NAME, UUID_REFERENCEABLE_CHILD);
191+
referenceableNode = admin.getNode("/tmp/reference").getProperty(PROPERTY_NAME).getNode();
192+
assertEquals("/tmp/referenceable/collision", referenceableNode.getPath());
193+
194194
// now try to remove the referenced node (with policy IdConflictPolicy.CREATE_NEW_ID)
195195
ImportOptions options = getDefaultOptions();
196196
options.setStrict(true);
197197
options.setIdConflictPolicy(IdConflictPolicy.CREATE_NEW_ID);
198198
e = assertThrows(Exception.class, () -> { extractVaultPackage("/test-packages/referenceable.zip", options);});
199199
assertEquals(ReferentialIntegrityException.class, e.getClass());
200200
admin.refresh(false);
201-
201+
assertProperty("/tmp/reference/" + PROPERTY_NAME, UUID_REFERENCEABLE_CHILD);
202+
referenceableNode = admin.getNode("/tmp/reference").getProperty(PROPERTY_NAME).getNode();
203+
assertEquals("/tmp/referenceable/collision", referenceableNode.getPath());
204+
202205
// now try to remove the referenced node (with default policy IdConflictPolicy.FORCE_REMOVE_CONFLICTING_ID)
203206
options.setIdConflictPolicy(IdConflictPolicy.FORCE_REMOVE_CONFLICTING_ID);
204207
extractVaultPackage("/test-packages/referenceable.zip", options);
208+
// make sure that reference does still exist but now again points to the original path
209+
assertProperty("/tmp/reference/" + PROPERTY_NAME, UUID_REFERENCEABLE_CHILD);
210+
referenceableNode = admin.getNode("/tmp/reference").getProperty(PROPERTY_NAME).getNode();
211+
assertEquals("/tmp/referenceable/child", referenceableNode.getPath());
205212
}
206213

207214
@Test

0 commit comments

Comments
 (0)