Hi All,
I have created a custom workflow for replicating a particular page/asset to publisher but via a new replication agent.This workflow will be used only by specific set of users.(specialusers)
So I have created 3 users with the required permissions :
1)specialuser-From this user , I will run the workflow for activation (others will not have the access to run).
2)transportuser-This user is for the replication
3)agentuser-to mention as agentId in replication agent.
I am able to successfully run the workflow and replicate to publisher , but in the author instance ,it is showing "admin" as the replicator(in siteadmin).Please find the screenshot attached.
I am using replicator.replicate(session, ReplicationActionType.ACTIVATE, path, opts) for replication.(opts is the ReplicationOption for choosing the Replication agent)
Is there any way to show "specialuser" as the replicator.I browsed a lot but couldn't find any reference.
Also Can someone please help me in understanding the use of AgentId in Replication agent.
Please help me in the above case.
.
Thanks,
Pallavi
Solved! Go to Solution.
Hi Pallavi,
it seems that the user isn't calculated correctly. The reference from the ACS AEM Commons shows how you can fix that. Or you add the "replicatedByWorkflowProcess" as last step into your custom workflow :-)
Jörg
I assume you are obtaining the session by workflowSession.adaptTo(Session.class), if you create a session by logging in to the repository using spacialuser's credentials and use that session, replication will be attributed to that user.
Hi ,
Thanks a lot for the response.
Yes I am obtaining session by WorkflowSession.getSession(),but still not able to obtain specialuser as replicator.
Thanks,
Pallavi
Views
Replies
Total Likes
Hi ,
I tried to set the initiator name as replicator by using node.setProperty(ReplicationStatus.NODE_PROPERTY_LAST_REPLICATED_BY, initiator)
I am not sure if it is a good practice.please suggest if there is any other alternative.
I also found another ACS commons code in the link below :
Thanks,
Pallavi
Views
Replies
Total Likes
Hi Pallavi,
it seems that the user isn't calculated correctly. The reference from the ACS AEM Commons shows how you can fix that. Or you add the "replicatedByWorkflowProcess" as last step into your custom workflow :-)
Jörg
Hi Pallavi,
you need to obtain session from by system user. dont obtain the session from wfsession. The below code should help.
Map<String, Object> param = new HashMap<>()
param.put(ResourceResolverFactory.SUBSERVICE, "SUBSERVICENAME")
resourceResolver = resourceResolverFactory.getServiceResourceResolver(param)
session = resourceResolver.adaptTo(Session.class)
Thanks for your response .
Can you please help me in understanding use of Agent ID in replication agent.
Till now I didn't use the value of Agent ID in my code .(Agent ID is specified in Replication agent with required permissions and everything is working fine.)Is Agent ID something useful while doing dispatcher flush or Akamai level?
Thanks,
Pallavi
Views
Replies
Total Likes
Hi ,
I now understood the context of what you mentioned.
Session userSession = wfsession.getSession().impersonate(new SimpleCredentials(initiator, new char[0]));
Thanks a lot!
Thanks,
Pallavi
Hi Pallavi,
The above is also an option since you have got the session already. But in this case, you would the name would be of the initiator of the workflow as the replicator. But if you want only your special user to be the replicator, then this approach might not work.
Please try the below approach once and see if that works, worth a shot.
Map<String, Object> param = new HashMap<>()
param.put(ResourceResolverFactory.SUBSERVICE, "SUBSERVICENAME")
resourceResolver = resourceResolverFactory.getServiceResourceResolver(param)
session = resourceResolver.adaptTo(Session.class)
Thanks,
Tuhin