Skip to content

Instantly share code, notes, and snippets.

View nateyolles's full-sized avatar
😄

Nate Yolles nateyolles

😄
View GitHub Profile
@nateyolles
nateyolles / curlPackageFilterRules.sh
Last active November 2, 2023 16:30
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
@nateyolles
nateyolles / AemResourceResolutionServlet.java
Created October 9, 2015 03:44
Get the HTML markup for a resource in AEM / CQ.
package com.nateyolles.aem;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.engine.SlingRequestProcessor;
@nateyolles
nateyolles / SlingResourceResolutionServlet.java
Created October 9, 2015 04:29
Get the HTML markup for a resource in Apache Sling.
package com.nateyolles.sling;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.engine.SlingRequestProcessor;
@nateyolles
nateyolles / OsgiConfigurationServiceImpl.java
Created October 12, 2015 02:01
AEM / Sling service to read and write OSGi config properties
package com.nateyolles.sling.publick.services.impl;
import java.io.IOException;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
@nateyolles
nateyolles / OsgiConfigurationServiceConsumerExampleImpl.java
Last active October 15, 2015 18:57
Example component consuming the custom OsgiConfigurationService service
package com.nateyolles.sling.publick.services.impl;
import java.util.HashMap;
import java.util.Map;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
@nateyolles
nateyolles / OsgiConfigExampleServlet.java
Created October 15, 2015 18:54
Example servlet reading and updated OSGi configs in Adobe Experience Manager
package com.nateyolles.aem;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.cm.Configuration;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@nateyolles
nateyolles / curlDialogCheckboxes.sh
Created November 17, 2015 01:46
cURL simulations of submitted AEM component dialogs using SlingPostServlet suffixes
# Simulated checked checkbox. The value is saved as a Boolean type with the value of true.
curl http://localhost:4502/test -u admin:admin -Fcheck="true" -Fcheck@TypeHint="Boolean"
# Simulated unchecked checkbox. No value for "check" is submitted and the JCR property value remains unchanged.
curl http://localhost:4502/test -u admin:admin -Fcheck@TypeHint="Boolean"
# Simulated unchecked checkbox with Delete suffix. The JCR property is removed.
curl http://localhost:4502/test -u admin:admin -Fcheck@TypeHint="Boolean" -Fcheck@Delete="true"
# Simulated unchecked checkbox with TypeHint, DefaultValue and UseDefaultWhenMissing suffixes.
@nateyolles
nateyolles / aemTouchCheckboxDialog.xml
Last active April 12, 2023 03:00
AEM Touch UI component dialog checkboxes
<!-- Checked checkbox will result in a String property of "true" -->
<myCheckbox
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/checkbox"
text="My Checkbox"
name="./myCheckbox"
value="true"/>
<!-- Checked checkbox will result in a Boolean property of true-->
<myBooleanCheckbox
@nateyolles
nateyolles / aemClassicSelectionCheckboxDialog.xml
Last active July 5, 2022 15:53
AEM Classic UI component dialog checkboxes using the selection xtype
<!-- Checked checkbox will result in a String property of "true" -->
<myCheckbox
jcr:primaryType="cq:Widget"
fieldLabel="My Checkbox"
name="./myCheckbox"
type="checkbox"
xtype="selection"/>
<!-- Checked checkbox will result in a Boolean property of true-->
<myBooleanCheckbox
@nateyolles
nateyolles / aemClassicCheckboxDialog.xml
Created November 17, 2015 03:18
AEM Classic UI component dialog checkboxes using the checkbox xtype
<!-- Checked checkbox will result in a String property of "on" -->
<myCheckbox
jcr:primaryType="cq:Widget"
fieldLabel="My Checkbox"
name="./myCheckbox"
xtype="checkbox"/>
<!-- Checked checkbox will result in a Boolean property of true -->
<myBooleanCheckbox
jcr:primaryType="cq:Widget"