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

SaveFormAction and SaveDialogAction contains error in setNodeName()

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Neutral
    • Resolution: Unresolved
    • Affects Version/s: 5.3.8
    • Fix Version/s: 5.3.x, 5.4.x
    • Component/s: dialogs
    • Labels:
    • Environment:
      xUbuntu 14.04
    • Patch included:
      Yes

      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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated: