Skip to content

Instantly share code, notes, and snippets.


Jeff Potts jpotts

View GitHub Profile
jpotts / team_member.json
Created Mar 2, 2018
Example Team Member JSON
View team_member.json
"data": {
"type": "node--team_member",
"id": "d56fd5ed-65f8-4f31-b4c0-29f33ea67bfb",
"attributes": {
"nid": 16,
"uuid": "d56fd5ed-65f8-4f31-b4c0-29f33ea67bfb",
"vid": 17,
"langcode": "en",
"status": true,
jpotts / headshot.json
Last active Mar 2, 2018
Example Team Member and Headshot JSON
View headshot.json
"data": {
"type": "file--file",
"id": "311f36ae-b233-4db9-84ba-803525307e42",
"attributes": {
"fid": 2,
"uuid": "311f36ae-b233-4db9-84ba-803525307e42",
"langcode": "en",
"filename": "gravatar.png",
"uri": "public://2018-03/gravatar.png",
jpotts / example-object.json
Last active Jun 30, 2016
Example content service object and response
View example-object.json
"id": "someid",
"name": "globalNavSpecialOffersPromo",
"description": "",
"crDate": 1452112197971,
"modDate": 1457469890414,
"pubDate": 1457469840000,
"metadata": {
"pageId": [
jpotts /
Last active Aug 22, 2020
Code snippets that go along with an blog post on Elasticsearch search templates.
Map<String, Object> params = new HashMap<String, Object>();
params.put("search_term", "elasticsearch");
params.put("since", "now-30d");
Template template = new Template("tweets", ScriptService.ScriptType.FILE, MustacheScriptEngineService.NAME, null, params);
SearchRequestBuilder request = client.prepareSearch(INDEX).setTemplate(template);
SearchResponse response = request.execute().actionGet();
jpotts /
Last active Sep 29, 2021
This is a custom Share evaluator that checks if the current user is a member of a group. The group to check is grabbed from a property on the node. The node is specified in the evaluator config. If you know the group to check at compile time, there is already an OOTB evaluator for that.
import java.util.ArrayList;
import org.alfresco.web.evaluator.BaseEvaluator;
import org.alfresco.web.extensibility.SlingshotEvaluatorUtil;
import org.json.simple.JSONObject;
public class MemberOfGroupFromProperty extends BaseEvaluator {
protected SlingshotEvaluatorUtil util = null;
jpotts /
Created Jan 19, 2015
Use a scroll and the bulk api to reindex docs in an Elasticsearch index within the same cluster
public class Reindexer extends BaseElasticsearchUtility {
private static Log logger = LogFactory.getLog(Reindexer.class);
public static void main(String[] args) {
if (args.length != 5) {
jpotts /
Last active Aug 29, 2015
Elasticsearch function score query
public List<Content> fetchContentForPlacements(Date curDate, String relString, String pageId, Metadata meta) throws ContentServiceException {
// check for required parameters
if (pageId == null) {
throw new MissingParameterException(Constants.MSG_PAGE_ID_REQUIRED);
// default the current date to now if it wasn't provided
if (curDate == null) {
curDate = new Date();
jpotts /
Created Nov 25, 2014
Showing how to grab a document, either by ID or by path, from an Alfresco 5.0.a repository, even when the user does not have access to the enclosing folders
package com.alfresco.api.example;
import org.apache.chemistry.opencmis.client.api.Document;
import org.apache.chemistry.opencmis.client.api.Session;
public class GetDocumentExample extends BaseOnPremExample {
jpotts /
Created Nov 13, 2014
Need a better approach to sorting semantic version strings in Elasticsearch
# Delete the example index
curl -XDELETE "http://localhost:9200/sortable-version-test?pretty=true"
# Create a new example index
curl -X POST "http://localhost:9200/sortable-version-test?pretty=true"
# Set the mapping. Assumes version.groovy resides in $ES_HOME/config/scripts
curl -XPOST "http://localhost:9200/sortable-version-test/version/_mapping?pretty=true" -d'
"version": {
jpotts / blog-post.json
Created Nov 3, 2014
Snippet of blog post document mask
View blog-post.json
"Blog Post" : {
"body" : {
"type" : "StructuredText",
"config" : {
"placeholder" : "Start writing your blog post here...",
"minHeight" : "400px",
"imageConstraint" : {
"width" : 640.0