AgentFilter is returning null. | Community
Skip to main content
New Participant
July 24, 2018
Solved

AgentFilter is returning null.

  • July 24, 2018
  • 1 reply
  • 742 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

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.")

1 reply

arunpatidar
arunpatidarAccepted solution
New Participant
July 24, 2018

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