Uploaded image for project: '[Read Only] - Hippo Site Toolkit 2'
  1. [Read Only] - Hippo Site Toolkit 2
  2. HSTTWO-3434

Support cascading hst:configuration inheritance

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • 3.2.0
    • None

    Description

      Currently, the following HST setup results in a warning

      + hst:hst
         + hst:configurations
            + common
            + corporate
                - hst:inheritsfrom = ../common
                + hst:sitemenus
                + hst:workspace
                    + hst:sitemenus
            + subsite 
                - hst:inheritsfrom = ../corporate
      

      The warning is :

      log.warn("Skipping inheritfrom property for configuration node '{}' because this node is already inherit. Not allowed to inherit again", inheritConfig.getValueProvider().getPath());

      Supporting however the above setup should be fairly trivial (add some unit tests though that guarantee the order of inheritance)

      in org.hippoecm.hst.configuration.cache.CompositeConfigurationNodes#CompositeConfigurationNodes we now have:

      for (String inheritPath : inherits) {
                      if (!inheritPath.startsWith("../")) {
                          log.warn("hst:inheritsfrom property must start with ../ but this is not the case for '{}'. We skip this inherit", configurationRootNode.getValueProvider().getPath());
                          continue;
                      }
                      String hstConfigsInheritedRelPath = inheritPath.substring(3);
      
                      String absHstConfigsInheritedPath = configurationsNode.getValueProvider().getPath() + "/" + hstConfigsInheritedRelPath;
                      // regardless whether absHstConfigsInheritedPath exists or not, add it to the compositeConfigurationDependencyPaths : If it gets
                      // added later on, it does impact this CompositeConfigurationNodes
                      compositeConfigurationDependenyPaths.add(absHstConfigsInheritedPath);
                      compositeConfigurationDependenyPaths.addAll(createDependencyPaths(absHstConfigsInheritedPath, relPaths, false));
                      HstNode inheritConfig = configurationsNode.getNode(hstConfigsInheritedRelPath);
                      if (inheritConfig != null && isValidInheritedNode(inheritConfig)) {
                          orderedRootConfigurationNodeInheritanceList.add(inheritConfig);
                          if (inheritConfig.getValueProvider().hasProperty(HstNodeTypes.GENERAL_PROPERTY_INHERITS_FROM)) {
                              log.warn("Skipping inheritfrom property for configuration node '{}' because this node is already inherit. Not allowed to inherit again", inheritConfig.getValueProvider().getPath());
                          }
                      } else {
                          log.error("Relative inherit path '{}' for node '{}' does not point to a node of type '{}' or does not exist. Fix this path.",
                                  new String[]{inheritPath, configurationRootNode.getValueProvider().getPath(), NODETYPE_HST_CONFIGURATION});
                      }
                  }
      

      in the part with

      if (inheritConfig.getValueProvider().hasProperty(HstNodeTypes.GENERAL_PROPERTY_INHERITS_FROM)) {
      

      we should just use the inherited config inherits from property again as an extra 'inheritPath'

      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: