Skip to content

Commit

Permalink
Merge pull request #3 from saidone75/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
saidone75 authored May 13, 2024
2 parents 09484ff + f8fe09a commit 1b147f7
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 25 deletions.
50 changes: 50 additions & 0 deletions alfresco.bat
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions alfresco.sh
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions cljdoc-lein-preview.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Empty file.
108 changes: 108 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 1 addition & 19 deletions src/weller/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,4 @@
; along with this program. If not, see <http://www.gnu.org/licenses/>.

(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))
(:gen-class))
20 changes: 15 additions & 5 deletions src/weller/filters.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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.\\
Expand All @@ -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."
Expand Down Expand Up @@ -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)))))
(= (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)))))))
18 changes: 17 additions & 1 deletion test/weller/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit 1b147f7

Please sign in to comment.