Expand my Community achievements bar.

SOLVED

Customize the CQ-DAM search panel

Avatar

Level 4

Hi masters!

I’m trying to customize the CQ-DAM search panel, in damadmin console. I’m following instructions in [1].

I’ve successfully added a new optionspredicate to add a custom search for ‘activated/deactivated’ assets, looking for a ‘jcr:content/cq:lastReplicationAction’ property, with ‘Activate’ and ‘Deactivate’ values. Nice! smiley

The question is... I would like to add a predicate to filter assets that have a pending activation (thus, assets marked in the ‘Status’ column with a calendar icon, with a message like ‘Task Scheduled…’)

But I don’t know where this information is stored in the JCR repository, and how to define a new predicate with this information. Is it possible?

Do you have any advice?

Thank you very much!

 [1] http://dev.day.com/docs/en/cq/current/dam/extending-cq-dam-search.html

1 Accepted Solution

Avatar

Correct answer by
Level 10

This is the reply from our Eng team:

That is not a simple predicate addition, because pending activation is not directly stored in some jcr property but is derived from jcr:content/cq:lastReplicationAction and then looking at the replication queue.

So, one will have to implement a filtering predicate
https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/search/eval/AbstractPredicateEvaluator.htm...

little bit of code that can help you find it is pending goes like this
replicationStatus = resource.adaptTo(ReplicationStatus.class);

https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/replication/ReplicationStatus.html#isPendi...

Hope this helps.

View solution in original post

11 Replies

Avatar

Level 10

That is a good question. I will pass this question to the Eng team.

Creating a predicate to filter assets that have a pending activation is something that is not documented. But we will add this to the list. 

Avatar

Level 4

Thank you smacdonald2008! I'll be waiting for any news from Eng team. For our customer is important to have a list with the next assets planned to be published. I think it should be a very interesting functionality for many others customers...

Avatar

Level 10

I agree -  this will make a good community article - i will add this to our list to document.

I have passed this question to the Eng team. I am hoping to hear back from them soon. 

Avatar

Level 4

In addition, it would be great to know how to add the 'Status' column to the search panel, because this column is only visible in the 'Digital Assets' panel. Without the 'Status' column in the search panel, we will get the results, but we won't have the information about the planned publish date.

Thank you again :-)

Avatar

Correct answer by
Level 10

This is the reply from our Eng team:

That is not a simple predicate addition, because pending activation is not directly stored in some jcr property but is derived from jcr:content/cq:lastReplicationAction and then looking at the replication queue.

So, one will have to implement a filtering predicate
https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/search/eval/AbstractPredicateEvaluator.htm...

little bit of code that can help you find it is pending goes like this
replicationStatus = resource.adaptTo(ReplicationStatus.class);

https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/replication/ReplicationStatus.html#isPendi...

Hope this helps.

Avatar

Level 4

Hi smacdonald2008.

I've tried with a dummy component to test the ReplicationStatus.isPending() functionality (code at [1]). But the isPending() method always return 'false'. I've tried with a 'no activated' image, but with the activation pending marked in the 'status' column.

For recheck purposes, I've tried with activated images too, with and without pending activation, and getLastReplicationAction() is working fine, but isPending() always return 'false'.

Could you help me? Any advice will be very appreciated.

[1]

<%-- test Replication Status component. test Replication Status Component --%><% %><%@include file="/libs/foundation/global.jsp"%><% %><%@page session="false" %><% %><%@page import="org.apache.sling.api.resource.Resource"%><% %><%@page import="com.day.cq.replication.ReplicationStatus"%><% %><%@page import="javax.jcr.Session"%><% %><cq:defineObjects /><% // TODO add you code here //Session session = currentNode.getSession(); //Resource res = resourceResolver.getResource("/content/dam/test/Hydrangeas.jpg"); Resource res = resourceResolver.getResource("/content/dam/test/Lighthouse.jpg"); ReplicationStatus replicationStatus = res.adaptTo(ReplicationStatus.class); %><h1>test Replication Status component</h1> res.getPath() = <%=res.getPath()%><br/> res.getName() = <%=res.getName()%><br/> replicationStatus.isPending() = <%=replicationStatus.isPending()%><br/> replicationStatus.getLastReplicationAction() = <%=replicationStatus.getLastReplicationAction()%><br/>

Avatar

Level 4

Hi smacdonald2008!

Have you been able to ask the last question to Eng. Team (about the 'isPending()' method)?

Could you help me, please? Any advise will be veru appreciated!

Thank you very much!

Avatar

Level 10

With your code - you can never get a return value of true?  I will pass this to the Eng team again.

Avatar

Level 10

Are you using the right user session ?   All damadmin uses same API & indicates status so should work.  Try with admin session instead of user session & verify.

Avatar

Level 4

@smacdonald2008: Correct: I never get a return value of true. This is a screenshot of the images referenced in the code:

[img]image1.png[/img]

As you could see, both images has pending activation. One of them is published, and the other is not published.

 

@Sham HC: I've made the tests with admin user, so I suppose the user session should not be the problem. Correct?

 

Thank you very much to both.

Avatar

Level 10

I could not reproduce. File a daycare & get official help.