diff --git a/alfresco.bat b/alfresco.bat new file mode 100644 index 0000000..990d5ce --- /dev/null +++ b/alfresco.bat @@ -0,0 +1,50 @@ +@ECHO OFF + +SET COMPOSE_FILE_PATH=%CD%\docker\docker-compose.yml + +IF [%1]==[] ( + echo "Usage: %0 {start|stop|purge|tail}" + GOTO END +) + +IF %1==start ( + CALL :start + CALL :tail + GOTO END +) +IF %1==stop ( + CALL :down + GOTO END +) +IF %1==purge ( + CALL:down + CALL:purge + GOTO END +) +IF %1==tail ( + CALL :tail + GOTO END +) + +echo "Usage: %0 {start|stop|purge|tail}" +:END +EXIT /B %ERRORLEVEL% + +:start + docker volume create weller-acs-volume + docker volume create weller-db-volume + docker volume create weller-ass-volume + docker-compose -f "%COMPOSE_FILE_PATH%" up --build -d +EXIT /B 0 +:down + if exist "%COMPOSE_FILE_PATH%" ( + docker-compose -f "%COMPOSE_FILE_PATH%" down + ) +EXIT /B 0 +:tail + docker-compose -f "%COMPOSE_FILE_PATH%" logs -f +EXIT /B 0 +:purge + docker volume rm -f weller-acs-volume + docker volume rm -f weller-db-volume + docker volume rm -f weller-ass-volume diff --git a/alfresco.sh b/alfresco.sh new file mode 100644 index 0000000..3cddf6d --- /dev/null +++ b/alfresco.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +export COMPOSE_FILE_PATH="${PWD}/docker/docker-compose.yml" + +start() { + docker volume create weller-acs-volume + docker volume create weller-db-volume + docker volume create weller-ass-volume + docker-compose -f "$COMPOSE_FILE_PATH" --env-file ./docker/.env up --build -d +} + +down() { + if [ -f "$COMPOSE_FILE_PATH" ]; then + docker-compose -f "$COMPOSE_FILE_PATH" --env-file ./docker/.env down + fi +} + +purge() { + docker volume rm -f weller-acs-volume + docker volume rm -f weller-db-volume + docker volume rm -f weller-ass-volume +} + +tail() { + docker-compose -f "$COMPOSE_FILE_PATH" --env-file ./docker/.env logs -f +} + +tail_all() { + docker-compose -f "$COMPOSE_FILE_PATH" --env-file ./docker/.env logs --tail="all" +} + +case "$1" in + start) + start + tail + ;; + stop) + down + ;; + purge) + down + purge + ;; + tail) + tail + ;; + *) + echo "Usage: $0 {start|stop|purge|tail}" +esac \ No newline at end of file diff --git a/cljdoc-lein-preview.sh b/cljdoc-lein-preview.sh new file mode 100644 index 0000000..be0190e --- /dev/null +++ b/cljdoc-lein-preview.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# get project name +PROJECT=$(cat project.clj | grep defproject | cut -d " " -f 2 | cut -d "/" -f 2) +# get group id +GROUP_ID=$(cat project.clj | grep defproject | cut -d " " -f 2 | cut -d "/" -f 1) +# get version +VERSION=$(cat project.clj | grep defproject | cut -d " " -f 3 | tr -d '"') + +echo "Generating cljdoc for $PROJECT-$VERSION" + +# clean up previous run +sudo rm -rf /tmp/cljdoc +mkdir -p /tmp/cljdoc + +# build and install into local repo +echo "Installing $PROJECT-$VERSION jar and pom into local repo" +lein install + +# ingest into cljdoc +docker run --rm \ + -v $(pwd):/$PROJECT \ + -v $HOME/.m2:/root/.m2 \ + -v /tmp/cljdoc:/app/data \ + --entrypoint clojure \ + cljdoc/cljdoc -Sforce -M:cli ingest \ + --project $GROUP_ID/$PROJECT \ + --version $VERSION \ + --git /$PROJECT \ + +# start server +docker run --rm -p 9000:8000 -v /tmp/cljdoc:/app/data -v $HOME/.m2:/root/.m2 cljdoc/cljdoc diff --git a/docker/.env b/docker/.env new file mode 100644 index 0000000..e4cb1bf --- /dev/null +++ b/docker/.env @@ -0,0 +1,8 @@ +ACS_IMAGE=alfresco/alfresco-content-repository-community +ACS_VERSION=23.2.1 +SHARE_IMAGE=alfresco/alfresco-share +SHARE_VERSION=23.2.1 +ASS_IMAGE=alfresco/alfresco-search-services +ASS_VERSION=2.0.9.1 +ACTIVEMQ_IMAGE=alfresco/alfresco-activemq +ACTIVEMQ_VERSION=5.18-jre17-rockylinux8 \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..224a9f4 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,6 @@ +ARG ACS_IMAGE +ARG ACS_VERSION +FROM ${ACS_IMAGE}:${ACS_VERSION} +ARG TOMCAT_DIR=/usr/local/tomcat +USER root +COPY alfresco-global.properties $TOMCAT_DIR/shared/classes/alfresco-global.properties \ No newline at end of file diff --git a/docker/alfresco-global.properties b/docker/alfresco-global.properties new file mode 100644 index 0000000..e69de29 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..3b14400 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,108 @@ +version: '2' +services: + alfresco: + mem_limit: 1500m + build: + context: . + args: + ACS_IMAGE: ${ACS_IMAGE} + ACS_VERSION: ${ACS_VERSION} + environment: + JAVA_TOOL_OPTIONS: " + -Dencryption.keystore.type=JCEKS + -Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding + -Dencryption.keyAlgorithm=DESede + -Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore + -Dmetadata-keystore.password=mp6yc0UD9e + -Dmetadata-keystore.aliases=metadata + -Dmetadata-keystore.metadata.password=oKIWzVdEdA + -Dmetadata-keystore.metadata.algorithm=DESede + " + JAVA_OPTS: " + -Ddb.driver=org.postgresql.Driver + -Ddb.username=alfresco + -Ddb.password=alfresco + -Ddb.url=jdbc:postgresql://postgres:5432/alfresco + -Dsolr.host=solr6 + -Dsolr.port=8983 + -Dsolr.secureComms=secret + -Dsolr.sharedSecret=secret + -Dsolr.base.url=/solr + -Dindex.subsystem.name=solr6 + -Dshare.host=127.0.0.1 + -Dshare.port=8080 + -Dalfresco.host=localhost + -Dalfresco.port=8080 + -Daos.baseUrlOverwrite=http://localhost:8080/alfresco/aos + -Dmessaging.broker.url=\"failover:(nio://activemq:61616)?timeout=3000&jms.useCompression=true\" + -Ddeployment.method=DOCKER_COMPOSE + -Dtransform.service.enabled=true + -Dtransform.service.url=http://transform-router:8095 + -Dsfs.url=http://shared-file-store:8099/ + -DlocalTransform.core-aio.url=http://transform-core-aio:8090/ + -Dcsrf.filter.enabled=false + -Ddsync.service.uris=http://localhost:9090/alfresco + -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80 + -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000 + " + ports: + - "8000:8000" + - "8080:8080" + volumes: + - cral-acs-volume:/usr/local/tomcat/alf_data + share: + image: ${SHARE_IMAGE}:${SHARE_VERSION} + mem_limit: 512m + environment: + REPO_HOST: alfresco + REPO_PORT: 8080 + ports: + - "8180:8080" + postgres: + image: postgres:16-alpine + mem_limit: 512m + environment: + - POSTGRES_PASSWORD=alfresco + - POSTGRES_USER=alfresco + - POSTGRES_DB=alfresco + command: postgres -c max_connections=300 -c log_min_messages=LOG + ports: + - "5432:5432" + volumes: + - cral-db-volume:/var/lib/postgresql/data + solr6: + image: ${ASS_IMAGE}:${ASS_VERSION} + mem_limit: 1g + environment: + # Solr needs to know how to register itself with Alfresco + SOLR_ALFRESCO_HOST: "alfresco" + SOLR_ALFRESCO_PORT: "8080" + # Alfresco needs to know how to call solr + SOLR_SOLR_HOST: "solr6" + SOLR_SOLR_PORT: "8983" + # Create the default alfresco and archive cores + SOLR_CREATE_ALFRESCO_DEFAULTS: "alfresco,archive" + # HTTPS or SECRET + ALFRESCO_SECURE_COMMS: "secret" + # SHARED SECRET VALUE + JAVA_TOOL_OPTIONS: " + -Dalfresco.secureComms.secret=secret + " + ports: + - "8083:8983" # Browser port + volumes: + - cral-ass-volume:/opt/alfresco-search-services/data + activemq: + image: ${ACTIVEMQ_IMAGE}:${ACTIVEMQ_VERSION} + ports: + - 8161:8161 # Web Console + - 5672:5672 # AMQP + - 61616:61616 # OpenWire + - 61613:61613 # STOMP +volumes: + cral-acs-volume: + external: true + cral-db-volume: + external: true + cral-ass-volume: + external: true \ No newline at end of file diff --git a/src/weller/core.clj b/src/weller/core.clj index 3ad2b89..c91e450 100644 --- a/src/weller/core.clj +++ b/src/weller/core.clj @@ -15,22 +15,4 @@ ; along with this program. If not, see . (ns weller.core - (:require [cral.model.alfresco.cm :as cm] - [taoensso.telemere :as t] - [weller.components.component :as component] - [weller.event-handler :as handler] - [weller.events :as events] - [weller.filters :as filters]) - (:gen-class)) - -(defn -main - [& args] - - (def handler (-> (handler/make-handler) - (handler/add-tap (filters/assoc-type? cm/assoc-original) #(t/log! %)) - (handler/add-tap (filters/event? events/node-updated) #(t/log! %)) - (component/start))) - - (Thread/sleep 30000) - - (component/stop handler)) \ No newline at end of file + (:gen-class)) \ No newline at end of file diff --git a/src/weller/filters.clj b/src/weller/filters.clj index 83e37a0..01de9b0 100644 --- a/src/weller/filters.clj +++ b/src/weller/filters.clj @@ -42,8 +42,9 @@ (aspect-added? cm/asp-versionable) ```" [aspect] - (partial #(and (.contains ^PersistentVector (get-in % [:data :resource :aspect-names]) aspect) - (not (.contains ^PersistentVector (get-in % [:data :resource-before :aspect-names]) aspect))))) + (partial #(and + (.contains ^PersistentVector (get-in % [:data :resource :aspect-names]) aspect) + (not (.contains ^PersistentVector (get-in % [:data :resource-before :aspect-names]) aspect))))) (defn aspect-removed? "Return true when `aspect` has been removed from the node.\\ @@ -52,8 +53,9 @@ (aspect-removed? cm/asp-versionable) ```" [aspect] - (partial #(and (not (.contains ^PersistentVector (get-in % [:data :resource :aspect-names]) aspect)) - (.contains ^PersistentVector (get-in % [:data :resource-before :aspect-names]) aspect)))) + (partial #(and + (not (.contains ^PersistentVector (get-in % [:data :resource :aspect-names]) aspect)) + (.contains ^PersistentVector (get-in % [:data :resource-before :aspect-names]) aspect)))) (defn assoc-type? "Return true when an event correspond to a specific association type." @@ -88,4 +90,12 @@ (partial #(let [resource (get-in % [:data :resource])] (and (= (:node-type resource) (name cm/type-content)) - (= (get-in resource [:content :mime-type]) mime-type))))) \ No newline at end of file + (= (get-in resource [:content :mime-type]) mime-type))))) + +(defn node-aspect? + "Return true when a node has the given `aspect`" + [aspect] + (partial #(let [resource (get-in % [:data :resource])] + (and + (= ((keyword "@type") resource) "NodeResource") + (and (not (nil? (:aspect-names resource))) (.contains ^PersistentVector (:aspect-names resource) (name aspect))))))) \ No newline at end of file diff --git a/test/weller/core_test.clj b/test/weller/core_test.clj index 1499b66..f712cf3 100644 --- a/test/weller/core_test.clj +++ b/test/weller/core_test.clj @@ -16,4 +16,20 @@ (ns weller.core-test (:require [clojure.test :refer :all] - [weller.core :refer :all])) + [cral.model.alfresco.cm :as cm] + [taoensso.telemere :as t] + [weller.components.component :as component] + [weller.core :refer :all] + [weller.event-handler :as handler] + [weller.filters :as filters])) + +(deftest core-test + (def handler (-> (handler/make-handler) + ;(handler/add-tap (filters/assoc-type? cm/assoc-original) #(t/log! %)) + ;(handler/add-tap (filters/event? events/node-updated) #(t/log! %)) + (handler/add-tap (filters/node-aspect? cm/asp-auditable) #(t/log! %)) + (component/start))) + + (Thread/sleep 30000) + + (component/stop handler)) \ No newline at end of file