Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Ignore deactivated nodes in Author

rahuls80678827
Level 3
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
Jörg_Hoh
Correct answer by
Employee
Employee

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
aneeta45259594
Level 5
Level 5

Hello,

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

Thanks,

Aneet

Arun_Patidar
Community Advisor
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

Jörg_Hoh
Correct answer by
Employee
Employee

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

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

Jörg

rahuls80678827
Level 3
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

rahuls80678827
Level 3
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.

rahuls80678827
Level 3
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.

rahuls80678827
Level 3
Level 3

Thankyou Jorg.

It worked now.

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

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