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

Get item by url fragment does not return proper item when rootPath is configured in JcrContentConnector

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Neutral
    • None
    • 5.5.6
    • None
    • None

    Description

      There is a problem in line String fullFragment = ("/".equals(getRootPath()) ? "" : getRootPath()) + urlFragment;
      If the rootPath is configured, the fragment will be appended more rootPath, although the fragment is full path here.
      eg: rootPath: /data/products
      In linkedField: /data/products/cars/car1
      Value when debugging: fullFragment: /data/products/data/products/cars/car1

      So It causes a problem in choose dialog: item is not re-selected when open choose dialog in linkField

      @Override
          public JcrItemId getItemIdByUrlFragment(String urlFragment) {
              try {
                  String fullFragment = ("/".equals(getRootPath()) ? "" : getRootPath()) + urlFragment;
                  String nodePath = JcrItemUtil.parseNodeIdentifier(fullFragment);
                  nodePath = !StringUtils.isBlank(nodePath) ? nodePath : getRootPath();
                  JcrItemId nodeItemId = JcrItemUtil.getItemId(getWorkspace(), nodePath);
                  if (nodeItemId == null || !JcrItemUtil.isPropertyItemId(fullFragment)) {
                      return nodeItemId;
                  } else {
                      return new JcrPropertyItemId(nodeItemId, parsePropertyName(fullFragment));
                  }
              } catch (RepositoryException e) {
                  log.error("Failed to obtain JCR id for fragment: " + e.getMessage(), e);
                  return null;
              }
          }
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              sang.ngo Sang Ngo Huu
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD