Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-3439

SaveFormAction and SaveDialogAction contains error in setNodeName()

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Obsolete
    • Icon: Neutral Neutral
    • None
    • 5.3.8
    • dialogs
    • xUbuntu 14.04
    • Yes

      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

        Acceptance criteria

              Unassigned Unassigned
              drfits Evgeniy Fitsner
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD