Skip to content

Instantly share code, notes, and snippets.

public static void visitRecursively(Node node, Session currentSession) {
try{
NodeIterator list = node.getNodes();
while(list.hasNext()) {
Node childNode = list.nextNode();
// Verify child node for cqPage type
if((childNode.hasProperty("jcr:primaryType")) && (childNode.getProperty("jcr:primaryType").getValue().getString()).equals("cq:Page") ){
@dfparker2002
dfparker2002 / ClientLibUseObject.java
Created May 14, 2019 15:41 — forked from nateyolles/ClientLibUseObject.java
Custom ClientLibUseObject Java-Use POJO to create custom HTML markup
package apps.clientlib_async.sightly.templates;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
import javax.script.Bindings;
@dfparker2002
dfparker2002 / component.html
Created May 14, 2019 15:40 — forked from kevinweber/component.html
HTL/Sightly: "Use and call template" pattern. Put template into separate file for reusability, and pass parameters when calling it. Note that in most cases it's not necessary to pass "properties" to the template because they work even if they're not passed explicitly.
<sly data-sly-use.component="template.html"
data-sly-call="${component.template @ properties=properties}" />
<head data-sly-use.clientLib="${'/libs/granite/sightly/templates/clientlib.html'}">
<!--/* for css+js */-->
<meta data-sly-call="${clientLib.all @ categories='your.clientlib'}" data-sly-unwrap></meta>
<!--/* only js */-->
<meta data-sly-call="${clientLib.js @ categories='your.clientlib'}" data-sly-unwrap></meta>
<!--/* only css */-->
<meta data-sly-call="${clientLib.css @ categories='your.clientlib'}" data-sly-unwrap></meta>
@dfparker2002
dfparker2002 / AbstractIntegrationTest.java
Created March 25, 2019 16:41 — forked from klcodanr/AbstractIntegrationTest.java
An abstract class for creating integration tests to use the Sling Remote Testing Tools to test AEM / Adobe CQ5 projects.
package com.sixdimensions.wcm.cq.it;
import java.io.IOException;
import org.apache.sling.testing.tools.http.RequestExecutor;
import org.apache.sling.testing.tools.sling.SlingClient;
import org.apache.sling.testing.tools.sling.SlingTestBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.adobe.aem.guides.wknd.core.components.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.doReturn;
import static org.mockito.ArgumentMatchers.*;
<%@include file="/libs/foundation/global.jsp"%><%
%><%@page session="false" contentType="text/html; charset=utf-8"
pageEncoding="UTF-8"
import="org.apache.sling.api.resource.*,
com.day.commons.datasource.poolservice.DataSourcePool,
javax.sql.*,
java.sql.*,
java.util.*,
javax.jcr.*,
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.jcr.Item;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<!--Your other properties and build definition -->
<configuration>
<!-- All CQ package you want to install as part of your build -->
<subPackages>
<subPackage>
<groupId>YOUR SHARED GROUPID</groupId>
<artifactId>YOUR SHARED ARTIFACT</artifactId>
import java.util.Comparator;
import javax.jcr.query.Row;
import org.apache.felix.scr.annotations.Component;
import org.apache.sling.api.resource.ValueMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.search.Predicate;
import com.day.cq.search.eval.AbstractPredicateEvaluator;
import com.day.cq.search.eval.EvaluationContext;