-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JCRVLT-767: vlt: potential incorrect identifier comparison #348
Draft
reschke
wants to merge
5
commits into
master
Choose a base branch
from
JCRVLT-767
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
931ceef
Documentation: Fix typo
kwin 100024c
JCRVLT-767: vlt: potential incorrect identifier comparison (work in p…
reschke 864914e
JCRVLT-767: vlt: potential incorrect identifier comparison (improve d…
reschke 073c891
JCRVLT-767: vlt: potential incorrect identifier comparison (avoid tes…
reschke 223bb00
JCRVLT-767: vlt: potential incorrect identifier comparison (rewrite c…
reschke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -989,8 +989,19 @@ private void removeReferences(@NotNull Node node) throws ReferentialIntegrityExc | |
VersioningState vs = new VersioningState(stack, node); | ||
Node updatedNode = null; | ||
Optional<String> identifier = ni.getIdentifier(); | ||
|
||
boolean isUuidProtected = false; | ||
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 | ||
if (identifier.isPresent() && !node.getIdentifier().equals(identifier.get()) && !"rep:root".equals(ni.getPrimaryType().orElse(""))) { | ||
if (identifier.isPresent() && isUuidProtected && !node.getIdentifier().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 +1058,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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't the uuid already set through the sysview import? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we get here in case we skipped that...? |
||
} 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; | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original idea was to encapsulate impl specific differences in https://github.com/apache/jackrabbit-filevault/blob/master/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/spi/ServiceProvider.java.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer; let's do more research on the "setting of jcr:uuid" first, and the outcome of that would inform what information we would want to add there.