04-23.eri-test AEM中的复制API(Adobe Experience Manager)

\n

Replication is a process of activating/publishing a page and it\'s content from author to publish environment. AEM provide replication API to build a custom step that replicates content from the Author instance to the Publisher instance.

\n\n

Replication using Replicator API
\nInitially, We need to create a Replicator instance by using @Reference annotation.
\n

\n\n
@Reference\nprivate Replicator replicator;\n
\n\n\n\n

Next, We need to create a session instance and then pass this object to replicate API. Here I have shared a sample code snippet for creating a session instance.
\n

\n\n
ResourceResolver resolver = request.getResourceResolver();\n        session = resolver.adaptTo(Session.class);\n
\n\n\n\n

Finally, we need to pass the session instance and path to the replication API.
\nHere I have shared an example that will activate/deactivate web page based on a flag.
\n

\n\n
  private void managePageActivation(Session session, String path,boolean isReplicate) \n     {\n\n    try {\n            if (isReplicate) {\n                replicator.replicate(session, ReplicationActionType.ACTIVATE, path);\n                log.info("Page activated: ", path);\n            } else {\n                replicator.replicate(session, ReplicationActionType.DEACTIVATE, path);\n                log.info("Page De-activated: ", path);\n            }\n\n    } catch (ReplicationException e) {\n            log.info("Replication failed "+e.getMessage(), path);\n            e.printStackTrace();\n    }\n}\n\n
\n\n\n\n

In the above function will do the following things,
\n

\n The function will accept session instance, web page link and status for identifying which operation to be performed(Activation or Deactivation). The path is look like this /content/your-project/xxxx/en/user\n\n
\nThen we will call the replicate(Session session, ReplicationActionType type, String path) to replicate the content to the publish instance.\n\n

In my next post, I will explain how to activate/deactivate the content(asset and web page) by reading the path from an excel file.

\n\n

I would like to hear your thoughts and suggestions from you to make it better.

\n\n\n
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值