From 931ceef98513167af3218b773d9213e123a2f52d Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Tue, 6 Aug 2024 15:52:15 +0200 Subject: [PATCH 1/5] Documentation: Fix typo --- src/site/markdown/packagetypes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/markdown/packagetypes.md b/src/site/markdown/packagetypes.md index d11577d6..19a50364 100644 --- a/src/site/markdown/packagetypes.md +++ b/src/site/markdown/packagetypes.md @@ -54,7 +54,7 @@ Container Package Container packages act as deployment vehicle and don't contain regular nodes. Only OSGi bundles, configuration and sub packages (for use with the [OSGi Installer](https://sling.apache.org/documentation/bundles/jcr-installer-provider.html)) are allowed. In addition also sub packages below `/etc/packages/...` are supported. -Containers may be nested which means they may contain itself packages of type `container`. +Containers may be nested which means they may contain themselves packages of type `container`. Mixed Package From 100024ccede3084564ebdbf89cdf8894168ed91a Mon Sep 17 00:00:00 2001 From: Julian Reschke Date: Thu, 8 Aug 2024 15:33:34 +0100 Subject: [PATCH 2/5] JCRVLT-767: vlt: potential incorrect identifier comparison (work in progress) --- .../vault/fs/impl/io/DocViewImporter.java | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java index 3572276b..814c5a58 100644 --- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java +++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java @@ -989,8 +989,17 @@ private void removeReferences(@NotNull Node node) throws ReferentialIntegrityExc VersioningState vs = new VersioningState(stack, node); Node updatedNode = null; Optional identifier = ni.getIdentifier(); + + String nodeUUID = null; + try { + nodeUUID = node.getUUID(); + } catch (RepositoryException ex) { + // node not referenceable + } + // try to set uuid via sysview import if it differs from existing one - if (identifier.isPresent() && !node.getIdentifier().equals(identifier.get()) && !"rep:root".equals(ni.getPrimaryType().orElse(""))) { + if (identifier.isPresent() && nodeUUID != null && !nodeUUID.equals(identifier.get()) + && !"rep:root".equals(ni.getPrimaryType().orElse(""))) { long startTime = System.currentTimeMillis(); String previousIdentifier = node.getIdentifier(); log.debug("Node stashing for {} starting, existing identifier: {}, new identifier: {}, import mode: {}", @@ -1047,8 +1056,38 @@ private void removeReferences(@NotNull Node node) throws ReferentialIntegrityExc } // add remaining mixins (for all import modes) for (String mixin : newMixins) { + Property uuidProp = null; vs.ensureCheckedOut(); - node.addMixin(mixin); + + if (mixin.equals("mix:referenceable") && identifier.isPresent()) { + // if this is mix:ref and ni specifies an identifier, + // try to set it + try { + uuidProp = node.setProperty(Property.JCR_UUID, identifier.get()); + } catch (RepositoryException ex) { + log.debug("tried to set jcr:uuid to {} before adding mix:referenceable failed, continuing", ex); + } + + try { + node.addMixin(mixin); + } catch (RepositoryException ex) { + // try to add the mixin; this fails with classic + // jackrabbit, so undo the change for jcr:uuid and retry + if (uuidProp != null) { + log.debug( + "failed to add mix:referenceable after setting jcr:uuid, retrying without (uuid will be lost)", + ex); + // retry once after removing jcr:uuid + uuidProp.remove(); + node.addMixin(mixin); + } else { + throw ex; + } + } + } else { + node.addMixin(mixin); + } + updatedNode = node; } } From 864914efe5f63d4e190620b489cf624eb6e2d872 Mon Sep 17 00:00:00 2001 From: Julian Reschke Date: Fri, 9 Aug 2024 07:35:17 +0100 Subject: [PATCH 3/5] JCRVLT-767: vlt: potential incorrect identifier comparison (improve detection of referenceable node) --- .../jackrabbit/vault/fs/impl/io/DocViewImporter.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java index 814c5a58..e7fd4bfd 100644 --- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java +++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java @@ -990,15 +990,13 @@ private void removeReferences(@NotNull Node node) throws ReferentialIntegrityExc Node updatedNode = null; Optional identifier = ni.getIdentifier(); - String nodeUUID = null; - try { - nodeUUID = node.getUUID(); - } catch (RepositoryException ex) { - // node not referenceable + boolean isUuidProtected = false; + if (node.hasProperty(Property.JCR_UUID)) { + isUuidProtected = node.getProperty(Property.JCR_UUID).getDefinition().isProtected(); } // try to set uuid via sysview import if it differs from existing one - if (identifier.isPresent() && nodeUUID != null && !nodeUUID.equals(identifier.get()) + if (identifier.isPresent() && isUuidProtected && !node.getIdentifier().equals(identifier.get()) && !"rep:root".equals(ni.getPrimaryType().orElse(""))) { long startTime = System.currentTimeMillis(); String previousIdentifier = node.getIdentifier(); From 073c89186b37ba2f2e74b955879b6de327a29b8a Mon Sep 17 00:00:00 2001 From: Julian Reschke Date: Fri, 9 Aug 2024 09:34:30 +0100 Subject: [PATCH 4/5] JCRVLT-767: vlt: potential incorrect identifier comparison (avoid test fail on classic Jackrabbit by checking reh repo name desc as well) --- .../apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java index e7fd4bfd..644a0c62 100644 --- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java +++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java @@ -993,6 +993,10 @@ private void removeReferences(@NotNull Node node) throws ReferentialIntegrityExc boolean isUuidProtected = false; if (node.hasProperty(Property.JCR_UUID)) { isUuidProtected = node.getProperty(Property.JCR_UUID).getDefinition().isProtected(); + } else if (! session.getRepository().getDescriptor(Repository.REP_NAME_DESC).contains("Oak")) { + // workaround for non-Oak repos that may not be able to add + // mixin:referencable *after* setting jcr:uuid + isUuidProtected = true; } // try to set uuid via sysview import if it differs from existing one From 223bb00051fb67b41e2a01dd2d5f70a7f5ca7a2b Mon Sep 17 00:00:00 2001 From: Julian Reschke Date: Fri, 9 Aug 2024 12:10:59 +0100 Subject: [PATCH 5/5] JCRVLT-767: vlt: potential incorrect identifier comparison (rewrite code that detects non-Oak repos) --- .../apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java index 644a0c62..e45b2c3f 100644 --- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java +++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java @@ -991,12 +991,12 @@ private void removeReferences(@NotNull Node node) throws ReferentialIntegrityExc Optional identifier = ni.getIdentifier(); boolean isUuidProtected = false; - if (node.hasProperty(Property.JCR_UUID)) { - isUuidProtected = node.getProperty(Property.JCR_UUID).getDefinition().isProtected(); - } else if (! session.getRepository().getDescriptor(Repository.REP_NAME_DESC).contains("Oak")) { + if (! session.getRepository().getDescriptor(Repository.REP_NAME_DESC).contains("Oak")) { // workaround for non-Oak repos that may not be able to add // mixin:referencable *after* setting jcr:uuid isUuidProtected = true; + } else if (node.hasProperty(Property.JCR_UUID)) { + isUuidProtected = node.getProperty(Property.JCR_UUID).getDefinition().isProtected(); } // try to set uuid via sysview import if it differs from existing one