Andreas Schaefer created SLING-6462:
---------------------------------------

             Summary: Filter Isolated jcr:content nodes (by includes) are not 
deployed
                 Key: SLING-6462
                 URL: https://issues.apache.org/jira/browse/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="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;
            }
        }
    }
}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to