Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Ignore deactivated nodes in Author

Avatar

Level 3

Hello Everyone,

We have a usecase where I have to create a report(json) from content folder in author instance. This report should contain only those nodes which are activated and ignore the deactivated nodes.

Currently the code which I have written is creating the JSON file correctly (using TidyJSONWriter) but having both (activated and deactivated content).

Iterator<Resource> itearator = this.resourceResolver.findResources(String.format(MY_QUERY), XPATH);

Is there any api available that gives only the list of deactivated content and I can ignore that list in my Java function while creating json file?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

It's easy to determine the replication status of a resource:

com.day.cq.replication.ReplicationStatus status = resource.adaptTo(ReplicationStatus.class);

Jörg

View solution in original post

7 Replies

Avatar

Level 5

Hello,

Can you share your query? We can try tweaking the query to satisfy your use-case.

Thanks,

Aneet

Avatar

Community Advisor

Hi

You can use QueryBuilder Debugger to get list of Activated node(cq:Page and dam:Asset) under /cotent/

http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&facets=on&query=path%3D...

path=/content/

type=nt:base

group.1_property=jcr:content/cq:lastReplicationAction

group.1_property.value=Activate

group.2_property=jcr:primaryType

group.2_property.1_value=cq:Page

group.2_property.2_value=dam:Asset

group.p.and=true

p.limit=-1

p.hits=selective

p.properties=jcr:path

1. Open http://localhost:4502/libs/cq/search/content/querydebug.html

2. Type above query and click on Search

3. Once query executed you get the result, click on  JSON QueryBuilder Link to get JSON output

Note Above query will only return Activate Page and assets jCR path, JSON response can be changed from query based on what we need. If you need to check only cq:Page above query can be simplified and optimised too.

Thanks

Arun



Arun Patidar

Avatar

Correct answer by
Employee Advisor

It's easy to determine the replication status of a resource:

com.day.cq.replication.ReplicationStatus status = resource.adaptTo(ReplicationStatus.class);

Jörg

Avatar

Level 3

Thankyou Jorg.

I have tried to implement this but it's not giving the status (deactivate/activate) of the node.

/* show replication status of the resource */
ReplicationStatus replicationStatus = parentResource.adaptTo(ReplicationStatus.class);

log.info("ReplicationStatus:::::::::::::::::::::::::::::::" + replicationStatus);

This is what I am getting in response:

ReplicationStatus:::::::::::::::::::::::::::::::com.day.cq.replication.impl.ReplicationStatusImpl@4cee8530

Avatar

Level 3

Thanks Arun for the reply.

The code for generating the JSON based upon some query is already in place (Java Class) But it's a creating a JSON having the activated and deactivated node both.

So, here I am just looking for some option to put condition in my existing Java class so, that it skips out the deactivated node while creating a JSON.

Avatar

Level 3

Thanks Arun for the reply.

The code for generating the JSON based upon some query is already in place (Java Class) But it's a creating a JSON having the activated and deactivated node both.

So, here I am just looking for some option to put condition in my existing Java class so, that it skips out the deactivated node while creating a JSON.

Avatar

Level 3

Thankyou Jorg.

It worked now.

ReplicationStatus replicationStatus = parentResource.adaptTo(ReplicationStatus.class);

log.info("ReplicationStatus parentResource:::::::::::::::::::::::::::::::" + replicationStatus.getLastReplicationAction());