Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-6462

Filter Isolated jcr:content nodes (by includes) are not deployed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • Sling Eclipse IDE 2.0.0
    • Tooling
    • None
    • MacOS Sierra, JDK 1.8, latest Sling

    Description

      If a jcr:content node is included by a filter.xml but not its parent then the deployment of the corresponding .content.xml fails and with it its parent node becomes a Sling Folder and the jcr:content node is missing.

      Assuming we have the following on our file system:

      • A folder /etc/designs/base
      • A file .content.xml in that folder:
      <?xml version="1.0" encoding="UTF-8"?>
      <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
          jcr:primaryType="cq:Page">
          <jcr:content
              cq:doctype="html_5"
              cq:template="/libs/wcm/core/templates/designpage"
              jcr:primaryType="cq:PageContent"
              jcr:title="AEM Base Components"
              sling:resourceType="wcm/core/components/designer"/>
      </jcr:root>
      

      A filter.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <workspaceFilter version="1.0">
          <filter root="/apps/base"/>
      
          <filter root="/etc/clientlibs/base"/>
      
          <filter root="/etc/designs/base">
              <include pattern="/etc/designs/base/jcr:content"/>
          </filter>
      <!--
          <filter root="/etc/designs/base"/>
      -->
      
      </workspaceFilter>
      

      Taking out the include filter and replace it with the comment out one below makes the deployment work.

      Some preliminary investigations revealed that the ResourceChangeCommandFactory.getFilterResult() returns
      PREREQUISITE instead of ALLOW as the path that is tested is /etc/designs/base instead of /etc/designs/base/jcr:content.

      Locally I added that code after the filter.filter() call and before the return:

      //AS NOTE: If we have a jcr:content and it is limited by an include then it might fail
      //AS NOTE: (DENY) or worse coming back as PREREQUISITE making an undefined node. Here it
      //AS NOTE: checks if the resource proxy has a child of jcr:content and if so check with
      //AS NOTE: that path.
      if(filterResult != FilterResult.ALLOW && resourceProxy != null) {
          List<ResourceProxy> resourceProxyChildren = resourceProxy.getChildren();
          if(resourceProxyChildren.size() == 1) {
              ResourceProxy child = resourceProxyChildren.get(0);
              if(child.getPath().endsWith("/jcr:content")) {
                  FilterResult temp = filter.filter(child.getPath());
                  if(temp == FilterResult.ALLOW) {
                      return FilterResult.ALLOW;
                  }
              }
          }
      }
      

      Attachments

        1. SLING-6462.zip
          7 kB
          Robert Munteanu

        Issue Links

          Activity

            People

              Unassigned Unassigned
              andysch Andreas Schaefer
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: