[MGNLUI-3439] SaveFormAction and SaveDialogAction contains error in setNodeName() Created: 21/May/15  Updated: 09/Mar/21  Resolved: 09/Mar/21

Status: Closed
Project: Magnolia UI
Component/s: dialogs
Affects Version/s: 5.3.8
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Evgeniy Fitsner Assignee: Unassigned
Resolution: Obsolete Votes: 0
Labels: maintenance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

xUbuntu 14.04


Issue Links:
supersession
is superseded by MGNLUI-6334 Behaviour of node name in new framework Closed
Template:
Patch included:
Yes
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)

 Description   

SaveDialogAction and SaveDialogAction has protected method setNodeName which workin incorrectly
Actual: when dialog has field with name 'name' method save node as number instead of name in case if 'name' doesn't contains special characters.
Expected: method should save node with name as 'name' property in both cases - w/ and w/o special characters in it
1) Method should be changed from

protected void setNodeName(Node node, JcrNodeAdapter item) throws RepositoryException {
        String propertyName = "name";
        if (node.hasProperty(propertyName) && !node.hasProperty(ModelConstants.JCR_NAME)) {
            Property property = node.getProperty(propertyName);
            String newNodeName = property.getString();
            if (!node.getName().equals(Path.getValidatedLabel(newNodeName))) {
                newNodeName = Path.getUniqueLabel(node.getSession(), node.getParent().getPath(), Path.getValidatedLabel(newNodeName));
                item.setNodeName(newNodeName);
                NodeUtil.renameNode(node, newNodeName);
            }
        }
    }

to this

private final static String PROPERTY_NAME = "name";
protected void setNodeName(Node node, JcrNodeAdapter item) throws RepositoryException {
        if (node.hasProperty(PROPERTY_NAME) && !node.hasProperty(ModelConstants.JCR_NAME)) {
            item.setNodeName( Path.getUniqueLabel(node.getSession(), node.getParent().getPath(), Path.getValidatedLabel(newNodeName)));
            NodeUtil.renameNode(node, newNodeName);
        }
    }

2) could you please using DRY principle to avoid code duplicated


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