How to find preview env agent id in preprocessor interface | Community
Skip to main content
Level 2
April 17, 2024

How to find preview env agent id in preprocessor interface

  • April 17, 2024
  • 1 reply
  • 528 views

Hi guys,

 

We are using preprecosser interface to handle one event. It is using below method.

 

public void preprocess(final ReplicationAction replicationAction, final ReplicationOptions replicationOptions

 

May i know how to get agentid for above method ? Below code i tried but it was throwing null for agent id. Same code works with event handler interface.

 

Event event = replicationAction.toEvent();

        final List<String> agentIdList = (List) event.getProperty("agentIds");

        LOG.info("preprocess agentIdList {}", agentIdList);

        final boolean isPreview = CollectionUtils.isNotEmpty(agentIdList) &&

                                    agentIdList.stream().anyMatch(id -> id.contains("preview"));

        if (isPreview)

{

            return;

        }

 

I want to figure out if the request is for Preview environment or for Publish env using agent ids. Please let me know if any one has inputs for this.

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

1 reply

lukasz-m
Community Advisor
Community Advisor
April 17, 2024

Hi @testtttt1,

You can try to use AgentConfig object from ReplicationAction object, to get agent configuration, and retrieve specific agent id.

replicationAction.getConfig().getAgentId();
testtttt1Author
Level 2
April 17, 2024

Hi @lukasz-m 

 

It is also throwing nulll