Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add invalidate method, replace current invalidate with name delete #37

Merged
merged 3 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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