[MAGNOLIA-8961] JCR import command fails when replacing existing nodes Created: 20/Jun/23  Updated: 18/Sep/23  Resolved: 29/Aug/23

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 6.2.35
Fix Version/s: 6.3.0, 6.2.39

Type: Bug Priority: Neutral
Reporter: Jonathan Ayala Assignee: Antonín Juran
Resolution: Fixed Votes: 0
Labels: VN-Testing, quickwin
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: 3d 7h Time Spent: 3d 7h
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
Relates
causality
duplicate
is duplicated by JCRTOOLS-63 Jcr importer is failing for XML files Closed
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MAGNOLIA-9040 Implementation Sub-task Completed Antonín Juran  
MAGNOLIA-9041 Code review Sub-task Completed Adam Siska  
MAGNOLIA-9042 Pre-integration QA Sub-task Completed Adam Siska  
MAGNOLIA-9043 Final QA Sub-task Completed Quach Hao Thien  
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
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Release notes required:
Yes
Documentation update required:
Yes
Date of First Response:
Sprint: Nucleus 42, Nucleus 43
Story Points: 5
Team: Nucleus
Work Started:
Approved:
Yes

 Description   

Steps to reproduce

In demo author:

  1. Export an asset from dam app
  2. Open importer subapp of Jcr-Tools app
  3. Select dam repository, root path and behaviour: replace existing nodes with the same ID
  4. Press execute

Expected results

Node is imported correctly and replaced

Actual results

There is an error message: 

javax.jcr.query.InvalidQueryException: Query:
SELECT * FROM [nt:resource] WHERE(*); expected: NOT, (

Development notes

The query is not correctly generated in method info.magnolia.importexport.command.JcrImportCommand.validate(Node, Context, NodeIterator). The value of statement is: 

SELECT * FROM [nt:resource] WHERE 

It's assumed that there's always a where clause while there are some cases in which it's not the case. Adding an empty string check in line 118 will fix this issue.



 Comments   
Comment by Quach Hao Thien [ 13/Jul/23 ]

Discovery

The problem comes from this line. It's supposed to process the stream of children nodes right before importing process, but the importing process has already actually affected that stream. So the stream doesn't contain the children nodes before importing process as we expected but it contains the children node after importing.

The unexpected result of the children nodes stream leads to the wrong filter predicate at this line, so the whereClause variable will be empty, and the statement will end up with an empty WHERE

String statement = "SELECT * FROM [nt:resource] WHERE " + whereClause; 

Proposed solution:

This code https://git.magnolia-cms.com/projects/PLATFORM/repos/main/browse/magnolia-core/src/main/java/info/magnolia/importexport/command/JcrImportCommand.java?at=refs%2Fheads%2Frelease%2F6.2#108 should take place before the importing

 

Set<String> childNodeNamesBeforeImport = asStream(childNodesBeforeImport)
                .map(NodeUtil::getNodePathIfPossible)
                .collect(Collectors.toSet()); 
Comment by Loris Croci [ 30/Aug/23 ]

hello @quach
We have a customer with this problem in production waiting for this fix to be released. When will be released? In which version?

thanks
Loris

Comment by Quach Hao Thien [ 30/Aug/23 ]

Hi loris.croci ,

This ticket is integrated into 6.3.0 and 6.2.39. I don't have the information about releasing atm.

Comment by Quach Hao Thien [ 12/Sep/23 ]

Hi loris.croci ,

FYI, Magnolia 6.2.39 will be released by Monday 18th September at the latest.

Generated at Mon Feb 12 04:37:22 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.