Skip to content

Instantly share code, notes, and snippets.

@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;
Note 1: The following CQ curl commands assumes a admin:admin username and password.
Note 2: For Windows/Powershell users: use two "" when doing a -F cURL command.
Example: -F"":operation=delete""
Note 3: Quotes around name of package (or name of zip file, or jar) should be included.
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
@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 \
@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);
@dfparker2002
dfparker2002 / gist:477219854476f1054e58
Created March 27, 2016 11:20 — forked from kmb385/gist:5998632
This is an example for StackOverflow to help someone resolve a GSON issue.
import java.lang.reflect.Type;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
public class MapData {
private int id;
private String city;
private String street;