Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

ResourceFilterStream.class for Content Fragment trying to .setChildSelector("[jcr:content/metadata/cq:tags]

Avatar

Level 2

 

Hi,

 

I am trying to filter out Content Fragment using ResourceFilterStream, but cannot do so using .setChildSelector("[jcr:content/metadata/cq:tags]

 

Doing something like below.

 

Resource resource = resourceResolver.getResource("/content/dam/test-site");
ResourceFilterStream rfs = resource.adaptTo(ResourceFilterStream.class);

rfs.setBranchSelector("[jcr:primaryType] == 'dam:Asset'")
.setChildSelector("[jcr:content/metadata/cq:tags] like 'test-site:test'")
.stream()
.forEach(r-> logger.info("found resource {}",r.getPath()));

 

what should be the  .setChildSelector

 
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Aakarsh 

 ResourceFilterStream rfs = resource.adaptTo(ResourceFilterStream.class);
        rfs
                .setBranchSelector("[jcr:primaryType] != 'dam:Asset'")
                .setChildSelector("[jcr:content/metadata/cq:tags] contains $tag").addParam("tag", "properties:orientation/landscape")
                .stream()
                .forEach(r -> {
                    try {
                        resp.getWriter().println("Path: " + r.getPath());
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                });

Please try with following code:

 


Aanchal Sikka

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

@Aakarsh 

 ResourceFilterStream rfs = resource.adaptTo(ResourceFilterStream.class);
        rfs
                .setBranchSelector("[jcr:primaryType] != 'dam:Asset'")
                .setChildSelector("[jcr:content/metadata/cq:tags] contains $tag").addParam("tag", "properties:orientation/landscape")
                .stream()
                .forEach(r -> {
                    try {
                        resp.getWriter().println("Path: " + r.getPath());
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                });

Please try with following code:

 


Aanchal Sikka