[MGNLUI-3860] MultiValueChilNodeTransformer does not work with a linkfield Created: 25/Apr/16  Updated: 17/Oct/16  Resolved: 30/May/16

Status: Closed
Project: Magnolia UI
Component/s: dialogs
Affects Version/s: 5.4.5, 5.4.6
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Teresa Miyar Assignee: Federico Grilli
Resolution: Not an issue Votes: 0
Labels: support, timebox
Remaining Estimate: 0d
Time Spent: 1d
Original Estimate: Not Specified

Attachments: XML File config.modules.security-app.dialogs.user.form.tabs.user.fields.companies-3.xml    
Issue Links:
dependency
relation
is related to MGNLUI-3892 Updating sortable node children may t... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Sprint: Basel 46
Story Points: 2

 Description   

When using a info.magnolia.ui.form.field.definition.LinkFieldDefinition and a MultivalueChildNodetransformer, it works if the item is already created, but fails if you create a new item. This was tested on the security app creating a new user.

Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.elementData(ArrayList.java:400)
	at java.util.ArrayList.remove(ArrayList.java:477)
	at info.magnolia.ui.vaadin.integration.jcr.AbstractJcrNodeAdapter.sortChildren(AbstractJcrNodeAdapter.java:249)
	at info.magnolia.ui.vaadin.integration.jcr.AbstractJcrNodeAdapter.updateChildren(AbstractJcrNodeAdapter.java:215)
	at info.magnolia.security.app.dialog.action.SaveUserDialogAction.createOrUpdateUser(SaveUserDialogAction.java:183)
	at info.magnolia.security.app.dialog.action.SaveUserDialogAction.execute(SaveUserDialogAction.java:97)
	at info.magnolia.ui.api.action.AbstractActionExecutor.execute(AbstractActionExecutor.java:62)
	... 123 more

OUTCOME
---------------
The transformer seems to work fine. The ArrayIndexOutOfBoundsException is caused by a wrong if condition at AbstractJcrNodeAdapter.sortChildren(Node, List<String>) line #244. However, when getting rid of that, another issue arises with a user creation. The sub-node companies cannot be created under a not yet existing user node and so it ends up under e.g. the /admin node. I got it working by fixing the cause for the AIOOBE at MGNLUI-3892 plus this patch https://git.magnolia-cms.com/users/fgrilli/repos/ui/commits/a5548e44bbc8de4ec05693cf1217848e73c9e543#security-app/src/main/java/info/magnolia/security/app/dialog/action/SaveUserDialogAction.java

However, the dev team is not keen on including the fix to SaveUserDialogAction.java in the code base as having a user sub-node with custom properties seems more like a customer-specific need for a given project and not something we want to support out of the box. So we would suggest the customer to create/extend a custom SaveUserDialogAction and apply the above patch. Case is different for the inability of User to support multivalued properties (again not a transformer problem MAGNOLIA-6679). That needs to be fixed but since it requires an API breaking change it can be done only in a major release. The current issue would be closed with Workaround exists or Not an issue



 Comments   
Comment by Teresa Miyar [ 25/Apr/16 ]

Field configuration attached

Generated at Mon Feb 12 09:10:49 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.