From e5f9c5d27a75678a61b82c7ca03d19093649cc8a Mon Sep 17 00:00:00 2001 From: Roy Teeuwen Date: Tue, 24 Jan 2023 18:49:29 +0100 Subject: [PATCH 1/2] Add invalidate method, replace current invalidate with name delete --- .../AemScriptMetaClassExtensionProvider.groovy | 14 +++++++++++++- .../groovyconsole/components/console/methods.html | 5 +++-- 2 files changed, 16 insertions(+), 3 deletions(-) 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 dd809e56..6cc1f935 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 @@ -8,6 +8,10 @@ import com.day.cq.replication.Replicator import com.day.cq.search.PredicateGroup import com.day.cq.search.QueryBuilder import com.day.cq.wcm.api.PageManager +import org.apache.sling.distribution.DistributionRequest +import org.apache.sling.distribution.Distributor +import org.apache.sling.distribution.DistributionRequestType +import org.apache.sling.distribution.SimpleDistributionRequest import org.osgi.service.component.annotations.Component import org.osgi.service.component.annotations.Reference @@ -22,6 +26,9 @@ class AemScriptMetaClassExtensionProvider implements ScriptMetaClassExtensionPro @Reference private QueryBuilder queryBuilder + @Reference + private Distributor distributor; + @Override Closure getScriptMetaClass(ScriptContext scriptContext) { def resourceResolver = scriptContext.resourceResolver @@ -42,10 +49,15 @@ class AemScriptMetaClassExtensionProvider implements ScriptMetaClassExtensionPro replicator.replicate(session, ReplicationActionType.DEACTIVATE, path, options) } - delegate.invalidate { String path, ReplicationOptions options = null -> + delegate.delete { String path, ReplicationOptions options = null -> replicator.replicate(session, ReplicationActionType.DELETE, path, options) } + delegate.invalidate { String path, String agentId = "publish", boolean isDeep = false -> + DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.INVALIDATE, isDeep, path); + distributor.distribute(agentId, resourceResolver, distributionRequest); + } + delegate.createQuery { Map predicates -> queryBuilder.createQuery(PredicateGroup.create(predicates), session) } 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 54fc058f..06b4bec8 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 @@ -24,8 +24,9 @@

  • activate(String path, ReplicationOptions options) - Activate the node at the given path with supplied options.
  • deactivate(String path) - Deactivate the node at the given path.
  • deactivate(String path, ReplicationOptions options) - Deactivate the node at the given path with supplied options.
  • -
  • invalidate(String path) - Invalidate the node at the given path.
  • -
  • invalidate(String path, ReplicationOptions options) - Invalidate 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.
  • +
  • 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.
  • sql2Query(String query) - Execute an SQL-2 query using the QueryManager for the current JCR session.
  • From ffb5d2508ee5d6f0161cb6e7f5a60e0211f41dae Mon Sep 17 00:00:00 2001 From: Roy Teeuwen Date: Wed, 8 Feb 2023 09:06:13 +0100 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 559a8d9c..4b6a7bb8 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] +### Changed + +- Add invalidate method, replace current invalidate with name delete: [#37](https://github.com/orbinson/aem-groovy-console/pull/37) + ## [18.0.2] - 2023-01-05 ### Changed