Uploaded image for project: 'Magnolia REST Framework'
  1. Magnolia REST Framework
  2. MGNLREST-786

I18nDeliveryNodeWrapper is missing localized property

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 2.2.24
    • delivery
    • None

      Steps to reproduce

      1. Define a normal fallback site mapping with 3 locales:
        • en (default)
        • de
        • de_CH
      2. Create a page with content, e.g. a simple Title component. Maintain the "title" property in "de" only (e.g. "Deutscher Titel"). Now, in JCR is the following property structure
        • title (does not exist)
        • title_de = "Deutscher Titel" (exist)
        • title_de_CH (does not exist) 
      3. Call the page via REST with the "de_CH" (/.rest/delivery/pages.... ?lang=de-CH)

      Expected results

      It is expected that a "title" field exists in the response, which contains the content for "de", in the above example "Deutscher Titel"

      Actual results

      The "title" field is not present!!!

      Workaround

      2 Possible workarounds, but these are not usable with several languages (approx. 30 in the project):

      1. You also have to maintain "de_CH" with "Deutscher Titel"
      2. You also maintain "en"

      We actually have the case in the project that we always request with the full locales, e.g. de_CH, as these are maintained from time to time. In general, however, the content that is maintained under "de" should be used. This is currently not working!!!
      Maintenance in English is not feasible, especially at the beginning, as we are starting with German. But in the future "en" should be the default language.

      Development notes

      Die "Bug" or Problem is in the Class

      "info.magnolia.rest.delivery.jcr.i18n.I18nDeliveryNodeWrapper"

      private boolean validRequestedItem(Item item) {
          try {
              return this.doesNotContainLocaleInName(item) || this.isRequestedLocale(item);
          } catch (RepositoryException var3) {
              log.debug("Unable to determine if item is localized.", var3);
              return false;
          }
      }
      
      private boolean isRequestedLocale(Item item) throws RepositoryException {
          return this.i18nSupport.getLocale().equals(LocaleUtils.parseFromFilename(item.getName(), (Locale)null));
      }

      This method is called internally to get all properties from a node and return them to the node writer. However, the method checks whether either "title" or "title_en_CH" (because the requested locale is "de-CH") is the name of the property. However, the name of the property is "title_en", which is why the property is filtered out. However, since "title_en" is the only property, "title" is never listed as a property. If you now maintain "title" or "title_de_CH", the check works, "title" is listed as a property and the fallback from "de_CH" to "de" works!

      In my view, the solution would be something like check not the locale (include the Country) but check the language.

       

        Acceptance criteria

              Unassigned Unassigned
              mtaubeneck Martin Taubeneck
              AuthorX
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:

                  Bug DoR
                  Task DoD