Skip to content

Instantly share code, notes, and snippets.

@dfparker2002
dfparker2002 / curlPackageFilterRules.sh
Created March 19, 2025 23:48 — forked from nateyolles/curlPackageFilterRules.sh
AEM/CQ cURL: Adding include/exclude rules to package filters
# Adding include/exclude rules to CQ/AEM package filters through cURL.
# Through a simple search, you will find numerous lists of CQ/AEM cURL commands.
# However, I haven't seen an example of adding rules to package filters. The
# JSON "rules" key takes an array value. You can leave the array empty if you
# don't need to include any rules. The array is of JSON objects with a
# "modifier" key and value of "include" or "exclude", and a "pattern" key with
# your path or regular expression as the value.
# create package
@dfparker2002
dfparker2002 / aem-jcr-update-sample-script.groovy
Created February 28, 2025 20:56 — forked from Rampai94/aem-jcr-update-sample-script.groovy
Sample script that queries the JCR and updates property
/*This method is used to Query the JCR and find results as per the Query.*/
def buildQuery(parent) {
def queryManager = session.workspace.queryManager;
def statement = 'select * from [nt:file] as t where ISDESCENDANTNODE(['+parent+']) AND NAME() LIKE \'%.jpg\'';
queryManager.createQuery(statement, 'JCR-SQL2');
}
final def query = buildQuery(<replace_parent_path_here>);
final def result = query.execute()
@dfparker2002
dfparker2002 / AEM cURL
Created February 27, 2025 19:28 — forked from joemaffia/AEM cURL
AEM cURL commands
Uninstall a bundle (use http://localhost:4505/system/console/bundles to access the Apache Felix web console)
curl -u admin:admin -daction=uninstall http://localhost:4505/system/console/bundles/"name of bundle"
Install a bundle
curl -u admin:admin -F action=install -F bundlestartlevel=20 -F
bundlefile=@"name of jar.jar" http://localhost:4505/system/console/bundles
Build a bundle
curl -u admin:admin -F bundleHome=/apps/centrica/bundles/name of bundle -F
descriptor=/apps/centrica/bundles/com.centrica.cq.wcm.core-bundle/name_of_bundle.bnd
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
linkcheckertransformer.strictExtensionCheck="{Boolean}false"
linkcheckertransformer.rewriteElements="[a:href,area:href,form:action]"
linkcheckertransformer.disableRewriting="{Boolean}false"
linkcheckertransformer.disableChecking="{Boolean}false"
linkcheckertransformer.stripHtmltExtension="{Boolean}true"
linkcheckertransformer.mapCacheSize="{Long}5000"/>
@dfparker2002
dfparker2002 / we-retail-etc-map-http.json
Created November 4, 2024 15:05 — forked from mickleroy/we-retail-etc-map-http.json
We.Retail Sling Mappings (/etc/map/http)
{
"jcr:primaryType": "sling:Folder",
"weretail.com": {
"jcr:primaryType": "sling:Mapping",
"sling:internalRedirect": [
"/content/we-retail/us/en"
],
"weretail_com_content": {
"jcr:primaryType": "sling:Mapping",
@dfparker2002
dfparker2002 / SlingModelExporter.java
Created November 4, 2024 15:04 — forked from mickleroy/SlingModelExporter.java
Simple Sling model showing the use of the Exporter framework
@Model(
adaptables = Resource.class,
resourceType = "acme/components/sling-model"
)
@Exporter(name = "jackson", extensions = "json")
public class MyModel {
@Inject @Named("jcr:title")
private String title;
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
resource.resolver.searchpath="[/apps,/libs,/apps/foundation/components/primary,/libs/foundation/components/primary]"
resource.resolver.manglenamespaces="{Boolean}true"
resource.resolver.allowDirect="{Boolean}true"
resource.resolver.required.providers="[org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory]"
resource.resolver.virtual="[/:/]"
resource.resolver.mapping="[/-/,/content/we-retail/us/en/-/]"
resource.resolver.map.location="/etc/map"
@dfparker2002
dfparker2002 / DropDownServlet.java
Created May 18, 2023 05:51 — forked from sgaem/DropDownServlet.java
This gist shows the dynamic population of drop down using datasource in AEM.
package com.aem.project.core.servlets;
import com.adobe.cq.commerce.common.ValueMapDecorator;
import com.adobe.granite.ui.components.ds.DataSource;
import com.adobe.granite.ui.components.ds.SimpleDataSource;
import com.adobe.granite.ui.components.ds.ValueMapResource;
import com.day.crx.JcrConstants;
import org.apache.commons.collections4.iterators.TransformIterator;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
---Reactor pom (add dependencies)
<dependency>
<groupId>com.adobe.acs</groupId>
<artifactId>acs-aem-commons-content</artifactId>
<version>3.2.4</version>
<type>content-package</type>
<classifier>min</classifier>
</dependency>
<dependency>
@dfparker2002
dfparker2002 / ReadMe.md
Created June 20, 2022 19:21 — forked from GAM3RG33K/ReadMe.md
A Guide to setup and use Plantuml