Andreas Schaefer created SLING-6462:

             Summary: Filter Isolated jcr:content nodes (by includes) are not 
                 Key: SLING-6462
             Project: Sling
          Issue Type: Bug
          Components: Tooling
         Environment: MacOS Sierra, JDK 1.8, latest Sling
            Reporter: Andreas Schaefer

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=""; 
xmlns:cq=""; xmlns:jcr="";
        jcr:title="AEM Base Components"

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 root="/etc/designs/base"/>


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;

This message was sent by Atlassian JIRA

Reply via email to