Skip to content

Instantly share code, notes, and snippets.

View nateyolles's full-sized avatar
😄

Nate Yolles nateyolles

😄
View GitHub Profile
@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 / 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 / ConvertResourceToJSON.java
Created December 9, 2015 04:44
Easily turn an AEM/Sling Resource/Node into a JSONObject
package com.nateyolles.aem;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.commons.json.jcr.JsonItemWriter;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
@nateyolles
nateyolles / .content.xml
Created July 13, 2016 05:15
AEM using Granite Render Conditions
<items jcr:primaryType="nt:unstructured">
<widgetAlways
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="This always shows"
name="./widgetAlways"/>
<widgetHeaderChrome
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="This only shows when header &quot;User-Agent&quot; contains &quot;chrome&quot;"
@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 / 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 / Configuration.java
Created May 25, 2017 20:36
OSGi Declarative Services Annotations
package com.nateyolles.aem.osgiannotationdemo.core.services.impl;
import org.apache.commons.lang3.StringUtils;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import org.osgi.service.metatype.annotations.Option;
@ObjectClassDefinition(name = "Annotation Demo Service - OSGi")
public @interface Configuration {
@nateyolles
nateyolles / .content.xml
Created July 13, 2016 05:23
AEM Expression Language
<granite:rendercondition
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple"
expression="${param.biz == 'baz'}"
expression="${empty param.foo}"
expression="${not empty param.foo and not empty param.bar}"
expression="${param['foo'] not eq 'bar'}"
expression="${cookie.cookiename.value eq 'foo'}"
expression="${requestPathInfo.selectorString == 'edit'}"
expression="${requestPathInfo.suffix != '/foo/bar')}"
@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 / 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;