From 72c9637cc3d0c322ac6d4754ad78e990413e4ddb Mon Sep 17 00:00:00 2001 From: Barry d'Hoine Date: Tue, 2 May 2023 22:19:49 +0200 Subject: [PATCH] Add distribute method --- CHANGELOG.md | 4 ++++ .../AemScriptMetaClassExtensionProvider.groovy | 5 +++++ .../apps/groovyconsole/components/console/methods.html | 1 + 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a0090fb..a54397f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add distribute method using Sling Content Distribution: [#39](https://github.com/orbinson/aem-groovy-console/issues/39) + ## [19.0.3] - 2023-02-21 ### Fixed diff --git a/bundle/src/main/groovy/be/orbinson/aem/groovy/console/extension/impl/scriptmetaclass/AemScriptMetaClassExtensionProvider.groovy b/bundle/src/main/groovy/be/orbinson/aem/groovy/console/extension/impl/scriptmetaclass/AemScriptMetaClassExtensionProvider.groovy index 6cc1f935..c696f7cc 100755 --- a/bundle/src/main/groovy/be/orbinson/aem/groovy/console/extension/impl/scriptmetaclass/AemScriptMetaClassExtensionProvider.groovy +++ b/bundle/src/main/groovy/be/orbinson/aem/groovy/console/extension/impl/scriptmetaclass/AemScriptMetaClassExtensionProvider.groovy @@ -53,6 +53,11 @@ class AemScriptMetaClassExtensionProvider implements ScriptMetaClassExtensionPro replicator.replicate(session, ReplicationActionType.DELETE, path, options) } + delegate.distribute { String path, String agentId = "publish", boolean isDeep = false -> + DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.ADD, isDeep, path); + distributor.distribute(agentId, resourceResolver, distributionRequest); + } + delegate.invalidate { String path, String agentId = "publish", boolean isDeep = false -> DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.INVALIDATE, isDeep, path); distributor.distribute(agentId, resourceResolver, distributionRequest); diff --git a/ui.apps/src/main/content/jcr_root/apps/groovyconsole/components/console/methods.html b/ui.apps/src/main/content/jcr_root/apps/groovyconsole/components/console/methods.html index 06b4bec8..3ad7b9eb 100755 --- a/ui.apps/src/main/content/jcr_root/apps/groovyconsole/components/console/methods.html +++ b/ui.apps/src/main/content/jcr_root/apps/groovyconsole/components/console/methods.html @@ -26,6 +26,7 @@

  • deactivate(String path, ReplicationOptions options) - Deactivate the node at the given path with supplied options.
  • delete(String path) - Delete the node at the given path.
  • delete(String path, ReplicationOptions options) - Delete the node at the given path with supplied options.
  • +
  • distribute(String path, String agentId = "publish", boolean isDeep = "false") - Distribute the node at the given path with supplied options. (Only applicable on AEMaaCS)
  • invalidate(String path, String agentId = "publish", boolean isDeep = "false") - Invalidate the node at the given path with supplied options. (Only applicable on AEMaaCS)
  • createQuery(Map predicates) - Create a Query instance from the QueryBuilder for the current JCR session.
  • xpathQuery(String query) - Execute an XPath query using the QueryManager for the current JCR session.