Skip to content

Instantly share code, notes, and snippets.

View jpotts's full-sized avatar

Jeff Potts jpotts

View GitHub Profile
jpotts /
Last active January 16, 2024 10:45
Adding an aspect (known in CMIS 1.1 as a "secondary type") by modifying cmis:secondaryObjectTypeIds. This requires that you connect using the CMIS 1.1 service URL. You do not need the Alfresco OpenCMIS Extension when using this approach. Works with Alfresco 4.2.e Community Edition and higher.
List<Object> aspects = doc.getProperty("cmis:secondaryObjectTypeIds").getValues();
if (!aspects.contains("P:cm:geographic")) {
HashMap<String, Object> props = new HashMap<String, Object>();
props.put("cmis:secondaryObjectTypeIds", aspects);
System.out.println("Added aspect");
} else {
System.out.println("Doc already had aspect");
jpotts /
Last active July 18, 2023 14:54
Creating aspect-defined properties in CMIS with Alfresco
package com.someco.cmis.examples;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.Document;
jpotts /
Last active September 29, 2021 07:52
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 / jmeter-results.conf
Created August 30, 2014 21:28
Logstash config that can be used to read in JMeter test results and store them in Elasticsearch
input {
file {
path => [ "/Users/jpotts/Documents/code/es-test/results.csv"]
filter {
if ([message] =~ "responseCode") {
drop { }
} else {
csv {
jpotts /
Last active August 22, 2020 01:39
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 /
Created November 13, 2014 15:39
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 /
Created August 30, 2014 21:24
Apache JMeter that configures test settings as well as the CSV format for the test results
jpotts / team_member.json
Created March 2, 2018 20:53
Example 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 March 2, 2018 20:53
Example Team Member and 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 / fetch-blog-content.js
Created November 2, 2014 03:27
Use the API to fetch blog posts
var Prismic = require('').Prismic;
var testRepo = '';
Prismic.Api(testRepo, function(err, api) {
if (err) console.log(err);
api.form('blogPosts').ref(api.master()).submit(function(err, docs) {
if (err) console.log(err);
for (var i = 0; i < docs.results.length; i++) {