Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-13889

Serialize referenced documents in component properties always in the PageModelAPI v1.0

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • None
    • 14.3.0
    • None
    • None
    • Pulsar
    • Pulsar 242 - Site Dev APIs 2

    Description

      Hst configuration, and most specifically XPage Documents their hst config can have components which have properties that reference a document. Typically this is stored in a ParametersInfo, for example:

      public interface BannerComponentInfo {
      
          @Parameter(name = "path", defaultValue = "some/default")
          @JcrPath(isRelative = true)
          String getPath();
      
      }
      

      the above results in that the hst component in the CM gets to pick a document for property 'path'.

      Instead of via ParametersInfo, it can also be achieved with DynamicComponentParameters in JCR nodes that a component can reference other documents.

      Any component extending from BaseHstDynamicComponent do get any referenced document already set as model and thus also present in the PMA v1.0 as a primary citizen field of the hst component. However, the paramsInfo will still serialize the string value of the referenced document, which can be a absolute or relative path, for example

      "meta" : {
              "paramsInfo" : {
                "path" : "common/contact"
              },
              "params" : { }
            }
      

      This can be done better since 'common/contact' doesn't mean anything for an SPA developer.

      It becomes even more important if we have old style components which do not get a referenced document set as model: then the content is simply missing in the PMA completely.

      Hence, we opt for the following:

      Desired output

      instead of

      "meta" : {
              "paramsInfo" : {
                "path" : "common/contact"
              },
              "params" : { }
            }
      

      we want something like

      "meta" : {
              "paramsInfo" : {
                "path" : "/page/u30092f4e2ef74c7286a58ce895908937"
              },
              "params" : { }
            },
      ...
      ...
      ...
      "u30092f4e2ef74c7286a58ce895908937" : {
            "type" : "document",
            "links" : {
              "site" : {
                "href" : "/about-us",
                "type" : "internal"
              }
            },
           ....
      

      note that ideally instead of

       "path" : "/page/u30092f4e2ef74c7286a58ce895908937"
      

      we would have

       "path" : { 
                "$ref" :  "/page/u30092f4e2ef74c7286a58ce895908937" 
              }
      

      but this is very hard since jackson is serializing a getter with a String return value, not a Map

      Implementation Details

      ParametersInfoUtils#createParametersInfo already has the notion of HstParameterValueConverter, which happens to always use the DefaultHstParameterValueConverter. If we extend that a bit to allow to inject a custom PageModelAPI aware HstParameterValueConverter, we can serialize parameters which are backed by JcrPath differently and make sue the referenced document gets serialized as well

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              aschrijvers Ard Schrijvers
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: