[LIVECOPY-256] Exception in relink if content is not matching definition Created: 15/Mar/21  Updated: 21/Jun/21  Resolved: 14/Apr/21

Status: Closed
Project: Live Copy
Component/s: None
Affects Version/s: 3.2.2
Fix Version/s: 3.2.4

Type: Bug Priority: Neutral
Reporter: Mercedes Iruela Assignee: Evzen Fochr
Resolution: Fixed Votes: 0
Labels: maintenance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[X]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Date of First Response:
Epic Link: Live Copy maintenance
Sprint: Maintenance 52, Maintenance 53
Story Points: 2

 Description   

Steps to reproduce

  1.  Define a new component
    form:
      properties:
        link:
          label: Link
          $type: linkField
          chooser:
            workbenchChooser:
              appName: pages
        image:
          $type: compositeField
          label: Image composite
          itemProvider:
            $type: jcrChildNodeProvider
          properties:
            title:
              label: Image Title
              $type: textField
    
  2. Create a master, create a page and add the component above.
  3. Create a livecopy from master
  4. Modify previous component adding a new composite field:
    form:
      properties:
        link:
          label: Link
          $type: linkField
          chooser:
            workbenchChooser:
              appName: pages
        image:
          $type: compositeField
          label: Image composite
          itemProvider:
            $type: jcrChildNodeProvider
          properties:
            title:
              label: Image Title
              $type: textField
        secondaryImage:
          $type: compositeField
          label: Secondary Image composite
          itemProvider:
            $type: jcrChildNodeProvider
          properties:
            title:
              label: Secondary Image Title
              $type: textField
    
  5. Try to relink the livecopy

Expected results

Links are relinked and no exceptions are thrown

Actual results

Exception:

Caused by: java.lang.RuntimeException: javax.jcr.PathNotFoundException: secondaryImage
	at info.magnolia.livecopy.actions.RewirePageLinksAction.onSuccess(RewirePageLinksAction.java:118) ~[magnolia-livecopy-3.2.2.jar:?]
	at info.magnolia.livecopy.actions.RewirePageLinksAction.lambda$process$0(RewirePageLinksAction.java:92) ~[magnolia-livecopy-3.2.2.jar:?]
	at java.util.Optional.ifPresent(Unknown Source) ~[?:?]
	at info.magnolia.ui.AlertBuilder.lambda$build$ccff1191$1(AlertBuilder.java:182) ~[magnolia-ui-framework-6.2.6.jar:?]
	at jdk.internal.reflect.GeneratedMethodAccessor511.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:499) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:273) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:237) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1014) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.ui.Button.fireClick(Button.java:384) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.ui.Button$1.click(Button.java:57) ~[vaadin-server-8.9.4.jar:8.9.4]
	at jdk.internal.reflect.GeneratedMethodAccessor510.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:155) ~[vaadin-server-8.9.4.jar:8.9.4]
	... 109 more
Caused by: javax.jcr.PathNotFoundException: secondaryImage
	at org.apache.jackrabbit.core.NodeImpl$8.perform(NodeImpl.java:2167) ~[jackrabbit-core-2.20.0.jar:2.20.0]
	at org.apache.jackrabbit.core.NodeImpl$8.perform(NodeImpl.java:2161) ~[jackrabbit-core-2.20.0.jar:2.20.0]
	at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216) ~[jackrabbit-core-2.20.0.jar:2.20.0]
	at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91) ~[jackrabbit-core-2.20.0.jar:2.20.0]
	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2161) ~[jackrabbit-core-2.20.0.jar:2.20.0]
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.getNode(DelegateNodeWrapper.java:204) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.getNode(ContentDecoratorNodeWrapper.java:151) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.getNode(DelegateNodeWrapper.java:204) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.getNode(ContentDecoratorNodeWrapper.java:151) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.getNode(DelegateNodeWrapper.java:204) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.getNode(ContentDecoratorNodeWrapper.java:151) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.getNode(DelegateNodeWrapper.java:204) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.getNode(ContentDecoratorNodeWrapper.java:151) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.getNode(DelegateNodeWrapper.java:204) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.getNode(ContentDecoratorNodeWrapper.java:151) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.getNode(DelegateNodeWrapper.java:204) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.getNode(ContentDecoratorNodeWrapper.java:151) ~[magnolia-core-6.2.6.jar:?]
	at info.magnolia.livecopy.actions.rewire.StandardRewirePageLinksHelper.handleCompositeField(StandardRewirePageLinksHelper.java:119) ~[magnolia-livecopy-3.2.2.jar:?]
	at info.magnolia.livecopy.actions.rewire.StandardRewirePageLinksHelper.rewriteLinksForField(StandardRewirePageLinksHelper.java:94) ~[magnolia-livecopy-3.2.2.jar:?]
	at info.magnolia.livecopy.actions.rewire.StandardRewirePageLinksHelper.rewriteLinksForNode(StandardRewirePageLinksHelper.java:81) ~[magnolia-livecopy-3.2.2.jar:?]
	at info.magnolia.livecopy.actions.rewire.RewirePageLinksHelper.rewritePageLinks(RewirePageLinksHelper.java:63) ~[magnolia-livecopy-3.2.2.jar:?]
	at info.magnolia.livecopy.actions.RewirePageLinksAction.onSuccess(RewirePageLinksAction.java:105) ~[magnolia-livecopy-3.2.2.jar:?]
	at info.magnolia.livecopy.actions.RewirePageLinksAction.lambda$process$0(RewirePageLinksAction.java:92) ~[magnolia-livecopy-3.2.2.jar:?]
	at java.util.Optional.ifPresent(Unknown Source) ~[?:?]
	at info.magnolia.ui.AlertBuilder.lambda$build$ccff1191$1(AlertBuilder.java:182) ~[magnolia-ui-framework-6.2.6.jar:?]
	at jdk.internal.reflect.GeneratedMethodAccessor511.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:499) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:273) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:237) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1014) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.ui.Button.fireClick(Button.java:384) ~[vaadin-server-8.9.4.jar:8.9.4]
	at com.vaadin.ui.Button$1.click(Button.java:57) ~[vaadin-server-8.9.4.jar:8.9.4]
	at jdk.internal.reflect.GeneratedMethodAccessor510.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:155) ~[vaadin-server-8.9.4.jar:8.9.4]
	... 109 more

Workaround

Open the original component and save it and push changes, so that the new empty node is added.

Development notes

When relinking composite fields, the definition of the field is taken into account:

private void handleCompositeField(Node slaveContentNode, CompositeFieldDefinition compositeFieldDef, Locale locale, boolean protectFieldAfterRewire) throws Exception {
        List<EditorPropertyDefinition> fields = compositeFieldDef.getProperties();
        Node compositeNode = slaveContentNode.getNode(compositeFieldDef.getName());
        for (EditorPropertyDefinition configuredFieldDefinition : fields) {
            rewriteLinksForField(compositeNode, configuredFieldDefinition, locale, protectFieldAfterRewire);
        }
    }

In case of missing node instead of failing, the exception should be ignored instead of failing.
We should check behaviour for Multifields also.


Generated at Mon Feb 12 02:26:58 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.