Skip to content

Instantly share code, notes, and snippets.

@dfparker2002
dfparker2002 / gist:264e14b0febcb98b9078
Last active December 20, 2015 22:57 — forked from auniverseaway/gist:21800b9a7848b2bf880c
Maven AEM Archetype 10 install command
mvn archetype:generate \
-DarchetypeRepository=https://repo.adobe.com/nexus/content/groups/public/ \
-DarchetypeGroupId=com.adobe.granite.archetypes \
-DarchetypeArtifactId=aem-project-archetype \
-DarchetypeVersion=10 \
-DgroupId=my-group-id \
-DartifactId=myproject \
-DappsFolderName=myproject \
-DartifactName="My Project" \

-DcomponentGroupName: aemslice \

@dfparker2002
dfparker2002 / SecureLoggingUtil.java
Created December 31, 2015 13:02 — forked from sachin-handiekar/SecureLoggingUtil.java
Masking Sensitive Information in CXF Logging Interceptor for incoming/outgoing SOAP request. (http://www.sachinhandiekar.com/2014/11/cxf-logging-interceptor-masking.html)
package com.sachinhandiekar.examples.cxf.logging;
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
@dfparker2002
dfparker2002 / mvn-archetype-aem-6
Created January 15, 2016 01:15 — forked from kuckmc01/mvn-archetype-aem-6
AEM 6.0 ready project using Maven Archetype and Terminal
#!/bin/bash
# Maven archetype that will create an AEM 6.0 ready project
# Might need to change permissions in order to run
# If all else fails, copy and paste everything below this line into the terminal
mvn archetype:generate \
-DarchetypeRepository=https://repo.adobe.com/nexus/content/groups/public/ \
-DarchetypeGroupId=com.adobe.granite.archetypes \
-DarchetypeArtifactId=aem-project-archetype \
-DarchetypeVersion=10 \

Offline Oak compaction with debug logging:

  1. Install the latest Oak hotfix to your AEM instance:
  1. Download the oak-run version matching your oak version: https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/
  2. Upload the oak-run jar file to your server
  3. Create a file logback-compaction.xml (on the server in the same folder as the oak-run jar)
@dfparker2002
dfparker2002 / nodelist-iteration.js
Created January 22, 2016 09:16 — forked from bendc/nodelist-iteration.js
ES6: Iterating over a NodeList
var elements = document.querySelectorAll("div"),
callback = (el) => { console.log(el); };
// Spread operator
[...elements].forEach(callback);
// Array.from()
Array.from(elements).forEach(callback);
// for...of statement
@dfparker2002
dfparker2002 / MyJobConsumerTest.java
Created February 11, 2016 20:29 — forked from thomashartm/MyJobConsumerTest.java
Example mock verification test snippet ... using Mockito in an AEM related unit test
package net.thartm.someservice.jobs;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.List;
@dfparker2002
dfparker2002 / CQ5 XPath Queries (Content)
Created February 11, 2016 20:33 — forked from thomashartm/CQ5 XPath Queries (Content)
A collection of CQ5 related JCR queries in the XPath query language. Some of these queries might be project specific but are a nice blueprint for similar requriements.
Nodes with a certain attribute
//element(*)[jcr:content/@includePageInTools='true']
News without PubDate
//*[@cq:template="/apps/sampleproject/templates/newspage" and not(@pubdate)]
Pages without UUID
/jcr:root/content//element(*,cq:PageContent)[not(@uuid)]
Find Pages with component
#!/bin/bash
# first argument: file
# second argument: searchstring
#
find "$1" -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} '$2'' \;
@dfparker2002
dfparker2002 / Test.java
Created February 12, 2016 08:30 — forked from justinedelson/Test.java
How to make a http request to get the auth token in AEM
import java.io.IOException;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
public class Test {
def applyRestriction(path, prefix) {
def acl = getAcl(path)
def restrictions = new HashMap<String, Value>()
def values = new Value[1]
values[0] = session.getValueFactory().createValue(prefix)
restrictions.put("rep:prefixes", values)
acl.addEntry(principal, privileges, false, emptyMap, restrictions)
acMgr.setPolicy(acl.getPath(), acl);