Expand my Community achievements bar.

SOLVED

AgentFilter is returning null.

Avatar

Level 4

I have to publish a page programmatically and also doesnot want to create a version as I am creating new version in workflow. But when i try to replicate the page i am getting the below error.  Can anyone help out with this.

The code is as below

Session jcrSession = resolver.adaptTo(Session.class);

                String selectionType = item.getWorkflowData().getMetaDataMap().get("selectType").toString();

                ReplicationOptions options = new ReplicationOptions();

                AgentFilter filter = new AgentFilter() {

                @Override

                 public boolean isIncluded(Agent agent) {

                            return agent.getConfiguration().getAgentUserId().equals(agent.getId());

                   }

                 };

                options.setFilter(filter);

                options.setSuppressVersions(true);

                if("publish".equalsIgnoreCase(selectionType)) {

              replicator.replicate(resolver.adaptTo(Session.class), ReplicationActionType.ACTIVATE, path, options);

                 }else {

                replicator.replicate(resolver.adaptTo(Session.class), ReplicationActionType.DEACTIVATE, path);

                 }               

                jcrSession.save();

                jcrSession.refresh(true);

                session.complete(item, session.getRoutes(item, true).get(0));

24.07.2018 16:55:19.873 *ERROR* [JobHandler: /etc/workflow/instances/server0/2018-07-24/bw-schedule-page-activation_12:/content/component-marketplace/en_US_Test] com.adobe.granite.workflow.core.job.JobHandler Error executing workflow step

com.adobe.granite.workflow.WorkflowException: Process execution resulted in an error

at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:199)

at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:258)

at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:500)

at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:291)

at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:58)

at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:227)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.NullPointerException: null

at com.bestwestern.marketplace.core.models.PublishUnPublishPageOrAsset$1.isIncluded(PublishUnPublishPageOrAsset.java:57)

at com.day.cq.replication.impl.ReplicatorImpl.replicate(ReplicatorImpl.java:375)

at com.bestwestern.marketplace.core.models.PublishUnPublishPageOrAsset.execute(PublishUnPublishPageOrAsset.java:63)

at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:193)

... 8 common frames omitted

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

I think you need to use

           AgentFilter filter = new AgentFilter() {

                 public boolean isIncluded(Agent agent) {

                            return agent.getConfiguration().getAgentId().equals(agent.getId());

                   }

                 };

CQ5.3: How to activate to a specific replication agent

AgentConfig ("The Adobe AEM Quickstart and Web Application.")



Arun Patidar

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi,

I think you need to use

           AgentFilter filter = new AgentFilter() {

                 public boolean isIncluded(Agent agent) {

                            return agent.getConfiguration().getAgentId().equals(agent.getId());

                   }

                 };

CQ5.3: How to activate to a specific replication agent

AgentConfig ("The Adobe AEM Quickstart and Web Application.")



Arun Patidar