Skip to content

Commit

Permalink
Merge pull request #37 from orbinson/feature/fix-invalidate
Browse files Browse the repository at this point in the history
Add invalidate method, replace current invalidate with name delete
  • Loading branch information
royteeuwen authored Feb 8, 2023
2 parents 0892fa6 + 0a42cc8 commit 82a8154
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.3] - 2023-01-05

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ <h4 class="panel-title">
<li>activate(String path, ReplicationOptions options) - <span class="muted">Activate the node at the given path with supplied options.</span></li>
<li>deactivate(String path) - <span class="muted">Deactivate the node at the given path.</span></li>
<li>deactivate(String path, ReplicationOptions options) - <span class="muted">Deactivate the node at the given path with supplied options.</span></li>
<li>invalidate(String path) - <span class="muted">Invalidate the node at the given path.</span></li>
<li>invalidate(String path, ReplicationOptions options) - <span class="muted">Invalidate the node at the given path with supplied options.</span></li>
<li>delete(String path) - <span class="muted">Delete the node at the given path.</span></li>
<li>delete(String path, ReplicationOptions options) - <span class="muted">Delete the node at the given path with supplied options.</span></li>
<li>invalidate(String path, String agentId = "publish", boolean isDeep = "false") - <span class="muted">Invalidate the node at the given path with supplied options. (Only applicable on AEMaaCS)</span></li>
<li>createQuery(Map predicates) - <span class="muted">Create a <a href="https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/search/Query.html" target="_blank">Query</a> instance from the <a href="https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/search/QueryBuilder.html" target="_blank">QueryBuilder</a> for the current JCR session.</span></li>
<li>xpathQuery(String query) - <span class="muted">Execute an XPath query using the <a href="https://developer.adobe.com/experience-manager/reference-materials/spec/jsr170/javadocs/jcr-2.0/javax/jcr/query/QueryManager.html" target="_blank">QueryManager</a> for the current JCR session.</span></li>
<li>sql2Query(String query) - <span class="muted">Execute an SQL-2 query using the <a href="https://developer.adobe.com/experience-manager/reference-materials/spec/jsr170/javadocs/jcr-2.0/javax/jcr/query/QueryManager.html" target="_blank">QueryManager</a> for the current JCR session.</span></li>
Expand Down

0 comments on commit 82a8154

Please sign in to comment.