Ignore deactivated nodes in Author | Community
Skip to main content
rahuls80678827
Level 3
Jun 15, 2018 3:45 PM UTC
Solved

Ignore deactivated nodes in Author

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Employee
Jun 17, 2018 12:59 PM UTC

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

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

Jörg

7 replies

rahuls80678827
Level 3
Jun 18, 2018 8:12 AM UTC

Thankyou Jorg.

It worked now.

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

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

Translate
rahuls80678827
Level 3
Jun 18, 2018 5:56 AM UTC

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.

Translate
rahuls80678827
Level 3
Jun 18, 2018 5:55 AM UTC

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.

Translate
rahuls80678827
Level 3
Jun 18, 2018 5:53 AM UTC

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

Translate
joerghoh
joerghohAccepted solution
Employee
Jun 17, 2018 12:59 PM UTC

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

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

Jörg

Translate
arunpatidar
New Participant
Jun 15, 2018 10:49 PM UTC

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%2Fcontent%2F%0D%0At…

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

Translate
Arun Patidar
Employee
Jun 15, 2018 5:25 PM UTC

Hello,

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

Thanks,

Aneet

Translate