Skip to content

Commit

Permalink
in-path? predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
saidone75 committed May 24, 2024
1 parent 256fbf6 commit 42ac447
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/weller/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,11 @@
;; authenticate on Alfresco and store ticket
(swap! config assoc :alfresco
(assoc (:alfresco @config) :ticket (get-in (auth/create-ticket (get-in @config [:alfresco :user]) (get-in @config [:alfresco :password])) [:body :entry])))
(t/log! :trace @config))
(t/log! :trace @config))

(defn ticket
;; TODO
;; - validate ticket
;; - if expired request e new one
[]
(get-in @config [:alfresco :ticket]))
13 changes: 13 additions & 0 deletions src/weller/predicates_extra.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns weller.predicates-extra
(:require [cral.model.core :as model]
[cral.api.core.nodes :as nodes]
[weller.config :as c]))

(defn in-path?
[path]
(partial
#(= (get-in
(->> (model/map->GetNodeQueryParams {:include "path"})
(nodes/get-node (c/ticket) (get-in % [:data :resource :id])))
[:body :entry :path :name])
path)))
8 changes: 8 additions & 0 deletions test/weller/filters_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
[weller.events :as events]
[weller.pipe :as pipe]
[weller.predicates :as pred]
[weller.predicates-extra :as xpred]
[weller.test-utils :as tu])
(:import (clojure.lang PersistentVector)
(java.util UUID)))
Expand Down Expand Up @@ -152,4 +153,11 @@
pipe (pipe/make-pipe (pred/property-value? cm/prop-publisher value) #(deliver result %))]
(tu/change-property cm/prop-publisher value)
(is (= (get-in @result [:properties cm/prop-publisher]) value))
(component/stop pipe)))

(deftest in-path-test
(let [result (promise)
pipe (pipe/make-pipe (every-pred (pred/event? events/node-created) (xpred/in-path? "/Company Home/Guest Home")) #(deliver result %))]
(tu/create-then-update-then-delete-node)
(println @result)
(component/stop pipe)))

0 comments on commit 42ac447

Please sign in to comment.